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
159 monit_req_item(n) = item
176 integer,
intent(out) :: itemid
177 character(len=*),
intent(in) :: item
178 character(len=*),
intent(in) :: desc
179 character(len=*),
intent(in) :: unit
180 integer,
intent(in) :: ndim
181 logical,
intent(in) :: isflux
183 character(len=8) :: lname
185 integer :: n, nmax, reqid
190 nmax = min( monit_id_count, monit_req_nmax )
192 if ( item == monit_item(n) )
then 198 if ( itemid < 0 )
then 199 do n = 1, monit_req_nmax
200 if ( item == monit_req_item(n) )
then 201 monit_id_count = monit_id_count + 1
202 itemid = monit_id_count
206 monit_item(itemid) = trim(item)
207 monit_desc(itemid) = trim(desc)
208 monit_unit(itemid) = trim(unit)
209 if ( ndim == 2 )
then 210 monit_ktype(itemid) =
'ZSFC' 211 monit_kmax(itemid) = 1
212 elseif( ndim == 3 )
then 213 write(lname,
'(A,I4.4)')
'ZDEF',
kmax 214 monit_ktype(itemid) = lname
215 monit_kmax(itemid) =
kmax 217 monit_var(itemid) = 0.0_rp
218 monit_var0(itemid) = 0.0_rp
219 monit_first(itemid) = .true.
220 monit_flux(itemid) = isflux
223 if(
io_l )
write(
io_fid_log,
'(1x,A,I3)')
' *** [MONIT] Item registration No.= ', itemid
224 if(
io_l )
write(
io_fid_log,*)
' ] Name : ', trim(monit_item(itemid))
225 if(
io_l )
write(
io_fid_log,*)
' ] Description : ', trim(monit_desc(itemid))
226 if(
io_l )
write(
io_fid_log,*)
' ] Unit : ', trim(monit_unit(itemid))
227 if(
io_l )
write(
io_fid_log,*)
' ] Vert. type : ', trim(monit_ktype(itemid))
228 if(
io_l )
write(
io_fid_log,*)
' ] # of layer : ', monit_kmax(itemid)
229 if(
io_l )
write(
io_fid_log,*)
' ] Integ. with dt? : ', monit_flux(itemid)
239 subroutine monit_put_2d( &
248 integer,
intent(in) :: itemid
249 real(RP),
intent(in) :: var(:,:)
254 if( itemid <= 0 )
return 256 call stat_total( total, var(:,:), monit_item(itemid) )
258 if ( monit_flux(itemid) )
then 259 if ( monit_first(itemid) )
then 260 monit_var(itemid) = total * dt
261 monit_first(itemid) = .false.
263 monit_var(itemid) = monit_var(itemid) + total * dt
266 if ( monitor_usedevation )
then 267 if ( monit_first(itemid) )
then 268 monit_var(itemid) = 0.0_rp
269 monit_var0(itemid) = total
270 monit_first(itemid) = .false.
272 monit_var(itemid) = total - monit_var0(itemid)
275 monit_var(itemid) = total
280 end subroutine monit_put_2d
293 integer,
intent(in) :: itemid
294 real(RP),
intent(in) :: var(:,:,:)
299 if( itemid <= 0 )
return 301 call stat_total( total, var(:,:,:), monit_item(itemid) )
303 if ( monit_flux(itemid) )
then 304 if ( monit_first(itemid) )
then 305 monit_var(itemid) = total * dt
306 monit_first(itemid) = .false.
308 monit_var(itemid) = monit_var(itemid) + total * dt
311 if ( monitor_usedevation )
then 312 if ( monit_first(itemid) )
then 313 monit_var(itemid) = 0.0_rp
314 monit_var0(itemid) = total
315 monit_first(itemid) = .false.
317 monit_var(itemid) = total - monit_var0(itemid)
320 monit_var(itemid) = total
338 real(RP),
intent(in) :: var(:,:)
339 character(len=*),
intent(in) :: item
340 character(len=*),
intent(in) :: desc
341 character(len=*),
intent(in) :: unit
342 integer,
intent(in) :: ndim
343 logical,
intent(in) :: isflux
348 call monit_reg( itemid, item, desc, unit, ndim, isflux )
349 call monit_put( itemid, var(:,:) )
356 subroutine monit_in_3d( &
365 real(RP),
intent(in) :: var(:,:,:)
366 character(len=*),
intent(in) :: item
367 character(len=*),
intent(in) :: desc
368 character(len=*),
intent(in) :: unit
369 integer,
intent(in) :: ndim
370 logical,
intent(in) :: isflux
375 call monit_reg( itemid, item, desc, unit, ndim, isflux )
376 call monit_put( itemid, var(:,:,:) )
379 end subroutine monit_in_3d
388 character(len=4),
intent(in) :: memo
390 logical,
save :: firsttime = .true.
395 if( monit_id_count == 0 )
return 401 call monit_writeheader
404 if ( monit_fid > 0 )
then 406 if ( mod(nowstep-1,monitor_step_interval) == 0 )
then 407 write(monit_fid,
'(A,i7,A,A,A)',advance=
'no')
'STEP=',nowstep,
' (',memo,
')' 408 do n = 1, monit_id_count
409 write(monit_fid,
'(A,ES15.8)',advance=
'no')
' ',monit_var(n)
423 subroutine monit_writeheader
430 character(len=H_LONG) :: fname
439 if(
io_l )
write(
io_fid_log,*)
'*** Number of monitor item :', monit_req_nmax
443 if(
io_l )
write(
io_fid_log,
'(1x,A,A)')
'=====================================================', &
444 '=====================================================' 445 do n = 1, monit_id_count
446 if(
io_l )
write(
io_fid_log,
'(1x,A,A,A,A)') monit_item(n), monit_desc(n), monit_unit(n), monit_ktype(n)
448 if(
io_l )
write(
io_fid_log,
'(1x,A,A)')
'=====================================================', &
449 '=====================================================' 462 open( unit = monit_fid, &
463 file = trim(fname), &
464 form =
'formatted', &
466 if ( ierr /= 0 )
then 467 write(*,*)
'xxx File open error! :', trim(fname)
472 if(
io_l )
write(
io_fid_log,*)
'*** Write monitor. filename : ', fname
474 write(monit_fid,
'(A)',advance=
'no')
' ' 475 do n = 1, monit_id_count
476 write(monit_fid,
'(A,A16)',advance=
'no') monit_item(n)
483 end subroutine monit_writeheader
492 character(len=H_LONG) :: fname
495 if ( monit_fid > 0 )
then 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
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
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.
logical, public io_lnml
output log or not? (for namelist, this process)
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.