34 integer,
parameter :: log_none = 0
35 integer,
parameter :: log_error = 1
36 integer,
parameter :: log_warn = 2
37 integer,
parameter :: log_info = 3
38 integer,
parameter :: log_debug = 4
40 integer,
parameter :: stderr = 0
41 integer,
parameter :: stdout = 6
54 integer,
private :: log_ilevel = log_info
56 logical,
private :: log_master = .true.
57 logical,
private :: log_opened = .false.
67 integer,
intent(in) :: fid_conf
68 integer,
intent(in),
optional :: fid_log
69 logical,
intent(in),
optional :: master
71 character(len=5) :: LOG_LEVEL =
'I' 72 character(len=100) :: LOG_FILE =
"LOG_" 76 namelist / param_dc_log / &
81 if (
present(master) ) log_master = master
83 call date_and_time(log_file(4:11), log_file(12:21))
87 read(fid_conf,nml=param_dc_log,iostat=ierr)
90 call log(
'E',
'xxx Not appropriate names in namelist PARAM_DC_LOG. Check!')
93 if (
present(fid_log) )
then 97 file = trim(log_file), &
100 if ( ierr /= 0 )
then 101 call log(
'E',
'xxx File open error! :' // trim(log_file))
106 select case (trim(log_level))
107 case (
'E',
'e',
'ERROR',
'error')
108 log_ilevel = log_error
109 case (
'W',
'w',
'WARN',
'warn')
110 log_ilevel = log_warn
111 case (
'I',
'i',
'INFO',
'info')
112 log_ilevel = log_info
113 case (
'D',
'd',
'DEBUG',
'debug')
114 log_ilevel = log_debug
116 call log(
'E',
'xxx LOG_LEVEL is invalid. Check!')
124 if ( log_opened )
close(
log_fid)
134 character(len=*),
intent(in) :: type
135 character(len=*),
intent(in) :: message
137 select case (trim(type))
139 if ( log_ilevel >= log_error )
call logput(message)
140 write(stderr,*) trim(message)
143 if ( log_ilevel >= log_warn )
call logput(message)
145 if ( log_ilevel >= log_info )
call logput(message)
147 if ( log_ilevel >= log_debug )
call logput(message)
149 write(stderr,*)
'BUG: wrong log level' 160 character(len=*) :: message
162 if ( log_master )
write(
log_fid, *) trim(message)
165 end subroutine logput
integer, parameter, public log_lmsg
subroutine, public loginit(fid_conf, fid_log, master)
subroutine, public log(type, message)
subroutine, public logfinalize