39 module procedure monit_in_3d
40 end interface monit_in
43 module procedure monit_put_2d
45 end interface monit_put
55 private :: monit_writeheader
61 integer :: MONIT_FID = -1
63 character(len=H_LONG) :: MONITOR_OUT_BASENAME =
'monitor' 64 logical :: MONITOR_USEDEVATION = .true.
65 integer :: MONITOR_STEP_INTERVAL = 1
67 integer,
parameter :: MONIT_req_limit = 1000
68 integer :: MONIT_req_nmax = 0
69 character(len=H_SHORT) :: MONIT_req_item(MONIT_req_limit)
71 integer :: MONIT_id_count = 0
72 character(len=H_SHORT),
allocatable :: MONIT_item (:)
73 character(len=H_MID) ,
allocatable :: MONIT_desc (:)
74 character(len=H_SHORT),
allocatable :: MONIT_unit (:)
75 character(len=H_SHORT),
allocatable :: MONIT_ktype(:)
76 integer,
allocatable :: MONIT_kmax (:)
77 real(RP),
allocatable :: MONIT_var (:)
78 real(RP),
allocatable :: MONIT_var0 (:)
79 logical,
allocatable :: MONIT_first(:)
80 logical,
allocatable :: MONIT_flux (:)
82 real(RP),
parameter :: eps = 1.e-10_rp
93 namelist / param_monitor / &
94 monitor_out_basename, &
95 monitor_usedevation, &
98 character(len=H_SHORT) :: item
100 namelist / monititem / &
108 if(
io_l )
write(
io_fid_log,*)
'++++++ Module[MONITOR] / Categ[IO] / Origin[SCALElib]' 114 if(
io_l )
write(
io_fid_log,*)
'*** Not found namelist. Default used.' 115 elseif( ierr > 0 )
then 116 write(*,*)
'xxx Not appropriate names in namelist PARAM_MONITOR. Check!' 123 do n = 1, monit_req_limit
127 monit_req_nmax = n - 1
130 if ( monit_req_nmax > monit_req_limit )
then 131 if(
io_l )
write(
io_fid_log,*)
'*** request of monitor file is exceed! n >', monit_req_limit
132 elseif( monit_req_nmax == 0 )
then 136 if(
io_l )
write(
io_fid_log,*)
'*** Number of requested monitor item: ', monit_req_nmax
137 if(
io_l )
write(
io_fid_log,*)
'*** Monitor output interval [step] : ', monitor_step_interval
138 if(
io_l )
write(
io_fid_log,*)
'*** Use deviation from first step? : ', monitor_usedevation
141 allocate( monit_item(monit_req_nmax) )
142 allocate( monit_desc(monit_req_nmax) )
143 allocate( monit_unit(monit_req_nmax) )
144 allocate( monit_ktype(monit_req_nmax) )
145 allocate( monit_kmax(monit_req_nmax) )
146 allocate( monit_var(monit_req_nmax) )
147 allocate( monit_var0(monit_req_nmax) )
148 allocate( monit_first(monit_req_nmax) )
149 allocate( monit_flux(monit_req_nmax) )
152 do n = 1, monit_req_nmax
161 monit_req_item(n) = item
178 integer,
intent(out) :: itemid
179 character(len=*),
intent(in) :: item
180 character(len=*),
intent(in) :: desc
181 character(len=*),
intent(in) :: unit
182 integer,
intent(in) :: ndim
183 logical,
intent(in) :: isflux
185 character(len=8) :: lname
187 integer :: n, nmax, reqid
192 nmax = min( monit_id_count, monit_req_nmax )
194 if ( item == monit_item(n) )
then 200 if ( itemid < 0 )
then 201 do n = 1, monit_req_nmax
202 if ( item == monit_req_item(n) )
then 203 monit_id_count = monit_id_count + 1
204 itemid = monit_id_count
208 monit_item(itemid) = trim(item)
209 monit_desc(itemid) = trim(desc)
210 monit_unit(itemid) = trim(unit)
211 if ( ndim == 2 )
then 212 monit_ktype(itemid) =
'ZSFC' 213 monit_kmax(itemid) = 1
214 elseif( ndim == 3 )
then 215 write(lname,
'(A,I4.4)')
'ZDEF',
kmax 216 monit_ktype(itemid) = lname
217 monit_kmax(itemid) =
kmax 219 monit_var(itemid) = 0.0_rp
220 monit_var0(itemid) = 0.0_rp
221 monit_first(itemid) = .true.
222 monit_flux(itemid) = isflux
225 if(
io_l )
write(
io_fid_log,
'(1x,A,I3)')
' *** [MONIT] Item registration No.= ', itemid
226 if(
io_l )
write(
io_fid_log,*)
' ] Name : ', trim(monit_item(itemid))
227 if(
io_l )
write(
io_fid_log,*)
' ] Description : ', trim(monit_desc(itemid))
228 if(
io_l )
write(
io_fid_log,*)
' ] Unit : ', trim(monit_unit(itemid))
229 if(
io_l )
write(
io_fid_log,*)
' ] Vert. type : ', trim(monit_ktype(itemid))
230 if(
io_l )
write(
io_fid_log,*)
' ] # of layer : ', monit_kmax(itemid)
231 if(
io_l )
write(
io_fid_log,*)
' ] Integ. with dt? : ', monit_flux(itemid)
241 subroutine monit_put_2d( &
250 integer,
intent(in) :: itemid
251 real(RP),
intent(in) :: var(:,:)
256 if( itemid <= 0 )
return 258 call stat_total( total, var(:,:), monit_item(itemid) )
260 if ( monit_flux(itemid) )
then 261 if ( monit_first(itemid) )
then 262 monit_var(itemid) = total * dt
263 monit_first(itemid) = .false.
265 monit_var(itemid) = monit_var(itemid) + total * dt
268 if ( monitor_usedevation )
then 269 if ( monit_first(itemid) )
then 270 monit_var(itemid) = 0.0_rp
271 monit_var0(itemid) = total
272 monit_first(itemid) = .false.
274 monit_var(itemid) = total - monit_var0(itemid)
277 monit_var(itemid) = total
282 end subroutine monit_put_2d
295 integer,
intent(in) :: itemid
296 real(RP),
intent(in) :: var(:,:,:)
301 if( itemid <= 0 )
return 303 call stat_total( total, var(:,:,:), monit_item(itemid) )
305 if ( monit_flux(itemid) )
then 306 if ( monit_first(itemid) )
then 307 monit_var(itemid) = total * dt
308 monit_first(itemid) = .false.
310 monit_var(itemid) = monit_var(itemid) + total * dt
313 if ( monitor_usedevation )
then 314 if ( monit_first(itemid) )
then 315 monit_var(itemid) = 0.0_rp
316 monit_var0(itemid) = total
317 monit_first(itemid) = .false.
319 monit_var(itemid) = total - monit_var0(itemid)
322 monit_var(itemid) = total
340 real(RP),
intent(in) :: var(:,:)
341 character(len=*),
intent(in) :: item
342 character(len=*),
intent(in) :: desc
343 character(len=*),
intent(in) :: unit
344 integer,
intent(in) :: ndim
345 logical,
intent(in) :: isflux
350 call monit_reg( itemid, item, desc, unit, ndim, isflux )
351 call monit_put( itemid, var(:,:) )
358 subroutine monit_in_3d( &
367 real(RP),
intent(in) :: var(:,:,:)
368 character(len=*),
intent(in) :: item
369 character(len=*),
intent(in) :: desc
370 character(len=*),
intent(in) :: unit
371 integer,
intent(in) :: ndim
372 logical,
intent(in) :: isflux
377 call monit_reg( itemid, item, desc, unit, ndim, isflux )
378 call monit_put( itemid, var(:,:,:) )
381 end subroutine monit_in_3d
390 character(len=*),
intent(in) :: memo
392 logical,
save :: firsttime = .true.
397 if( monit_id_count == 0 )
return 403 call monit_writeheader
406 if ( monit_fid > 0 )
then 408 if ( mod(nowstep-1,monitor_step_interval) == 0 )
then 411 write(monit_fid,
'(A,i7,A,A4,A)',advance=
'no')
'STEP=',nowstep,
' (',memo,
')' 412 do n = 1, monit_id_count
413 write(monit_fid,
'(A,ES15.8)',advance=
'no')
' ',monit_var(n)
427 subroutine monit_writeheader
434 character(len=H_LONG) :: fname
443 if(
io_l )
write(
io_fid_log,*)
'*** Number of monitor item :', monit_req_nmax
446 if(
io_l )
write(
io_fid_log,
'(1x,2A)')
'=======================================================================', &
447 '==========================' 448 do n = 1, monit_id_count
449 if(
io_l )
write(
io_fid_log,
'(1x,A24,A48,A16,A16)') monit_item(n), monit_desc(n), monit_unit(n), monit_ktype(n)
451 if(
io_l )
write(
io_fid_log,
'(1x,2A)')
'=======================================================================', &
452 '==========================' 465 open( unit = monit_fid, &
466 file = trim(fname), &
467 form =
'formatted', &
469 if ( ierr /= 0 )
then 470 write(*,*)
'xxx File open error! :', trim(fname)
475 if(
io_l )
write(
io_fid_log,*)
'*** Open ASCII file for monitor, name : ', trim(fname)
477 write(monit_fid,
'(A)',advance=
'no')
' ' 478 do n = 1, monit_id_count
479 write(monit_fid,
'(A16)',advance=
'no') monit_item(n)
486 end subroutine monit_writeheader
495 character(len=H_LONG) :: fname
498 if ( monit_fid > 0 )
then 502 if(
io_l )
write(
io_fid_log,*)
'*** Close ASCII file for monitor, name : ', trim(fname)
integer, public time_nowstep
current step [number]
subroutine, public monit_finalize
Close file.
logical, public prc_ismaster
master process in local communicator?
subroutine, public prc_mpistop
Abort MPI.
logical, public io_l
output log or not? (this process)
subroutine, public io_make_idstr(outstr, instr, ext, rank, isrgn)
generate process specific filename
logical, public io_nml
output log or not? (for namelist, this process)
subroutine monit_in_2d(var, item, desc, unit, ndim, isflux)
Wrapper routine of MONIT_reg+MONIT_put.
integer function, public io_get_available_fid()
search & get available file ID
real(dp), public time_dtsec
time interval of model [sec]
subroutine, public monit_reg(itemid, item, desc, unit, ndim, isflux)
Search existing item, or matching check between requested and registered item.
integer, public kmax
of computational cells: z, local
logical, public io_log_allnode
output log for each node?
integer, public prc_myrank
process num in local communicator
subroutine monit_put_3d(itemid, var)
Put total value to the monitor buffer.
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
subroutine, public monit_write(memo)
Flush monitor buffer to formatted file.
subroutine, public monit_setup
Setup.
integer, public io_fid_conf
Config file ID.
integer, public io_fid_log
Log file ID.
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
integer, public io_fid_nml
Log file ID (only for output namelist)