35 integer,
parameter :: LOG_NONE = 0
36 integer,
parameter :: LOG_ERROR = 1
37 integer,
parameter :: LOG_WARN = 2
38 integer,
parameter :: LOG_INFO = 3
39 integer,
parameter :: LOG_DEBUG = 4
41 integer,
parameter :: STDERR = 0
42 integer,
parameter :: STDOUT = 6
56 integer,
private :: log_ilevel = log_info
58 logical,
private :: log_master
59 #if defined(PGI) || defined(SX) 60 logical,
public :: log_master_nml
62 logical,
private :: log_master_nml
64 logical,
private :: log_opened = .false.
76 integer,
intent(in) :: fid_conf
77 integer,
intent(in),
optional :: fid_log
78 logical,
intent(in),
optional :: master
79 integer,
intent(in),
optional :: fid_nml
80 logical,
intent(in),
optional :: master_nml
82 character(len=5) :: log_level =
'I' 83 character(len=100) :: log_file =
"LOG_" 87 namelist / param_dc_log / &
91 character(len=LOG_LMSG) :: message
98 if (
present(master) ) log_master = master
99 log_master_nml = log_master
100 if (
present(master_nml) ) log_master_nml = master_nml
102 call date_and_time(log_file(4:11), log_file(12:21))
106 read(fid_conf,nml=param_dc_log,iostat=ierr)
109 call log(
'E',
'xxx Not appropriate names in namelist PARAM_DC_LOG. Check!')
112 if (
present(fid_log) )
then 117 file = trim(log_file), &
118 form =
'formatted', &
120 if ( ierr /= 0 )
then 121 call log(
'E',
'xxx File open error! :' // trim(log_file))
127 if (
present(fid_nml) )
then 131 #if defined(PGI) || defined(SX) 132 if ( log_master_nml )
write(
log_fid_nml,nml=param_dc_log)
134 write(message,nml=param_dc_log)
138 select case (trim(log_level))
139 case (
'E',
'e',
'ERROR',
'error')
140 log_ilevel = log_error
141 case (
'W',
'w',
'WARN',
'warn')
142 log_ilevel = log_warn
143 case (
'I',
'i',
'INFO',
'info')
144 log_ilevel = log_info
145 case (
'D',
'd',
'DEBUG',
'debug')
146 log_ilevel = log_debug
148 call log(
'E',
'xxx LOG_LEVEL is invalid. Check!')
156 if ( log_opened )
close(
log_fid)
166 character(len=*),
intent(in) :: type
167 character(len=*),
intent(in) :: message
169 select case (trim(type))
171 if ( log_ilevel >= log_error )
call logput(message)
172 write(stderr,*) trim(message)
175 if ( log_ilevel >= log_warn )
call logput(message)
177 if ( log_ilevel >= log_info )
call logput(message)
179 if ( log_ilevel >= log_debug )
call logput(message)
181 write(stderr,*)
'BUG: wrong log level' 192 character(len=*) :: message
194 if ( log_master )
write(
log_fid, *) trim(message)
197 end subroutine logput
204 character(len=*),
intent(in) :: type
205 character(len=*),
intent(in) :: message
207 select case (trim(type))
209 if ( log_ilevel >= log_error )
call logput_nml(message)
210 write(stderr,*) trim(message)
213 if ( log_ilevel >= log_warn )
call logput_nml(message)
215 if ( log_ilevel >= log_info )
call logput_nml(message)
217 if ( log_ilevel >= log_debug )
call logput_nml(message)
219 write(stderr,*)
'BUG: wrong log level' 227 subroutine logput_nml( &
230 character(len=*) :: message
232 if ( log_master_nml )
write(
log_fid_nml, *) trim(message)
235 end subroutine logput_nml
integer, parameter, public log_lmsg
subroutine, public log_nml(type, message)
integer, public log_fid_nml
subroutine, public log(type, message)
subroutine, public logfinalize
subroutine, public loginit(fid_conf, fid_log, master, fid_nml, master_nml)