37 module procedure monitor_in_3d
38 end interface monitor_in
43 end interface monitor_put
53 private :: monitor_writeheader
59 integer :: monitor_fid = -1
61 character(len=H_LONG) :: monitor_out_basename =
'monitor' 62 logical :: monitor_usedevation = .true.
63 integer :: monitor_step_interval = 1
65 real(DP) :: monitor_dt
67 integer,
parameter :: monitor_req_max = 1000
68 integer :: monitor_nreqs = 0
69 character(len=H_SHORT) :: monitor_reqs(monitor_req_max)
72 character(len=H_SHORT) :: name
73 character(len=H_MID) :: desc
74 character(len=H_SHORT) :: unit
81 integer :: monitor_nitems = 0
82 type(item),
allocatable :: monitor_items(:)
85 character(len=H_SHORT) :: name
90 real(RP),
allocatable :: area(:,:)
91 real(RP) :: total_area
92 real(RP),
allocatable :: volume(:,:,:)
93 real(RP) :: total_volume
95 integer,
parameter :: monitor_dim_max = 30
96 integer :: monitor_ndims = 0
97 type(dim_type) :: monitor_dims(monitor_dim_max)
108 real(DP),
intent(in) :: dt
110 namelist / param_monitor / &
111 monitor_out_basename, &
112 monitor_usedevation, &
113 monitor_step_interval
115 character(len=H_SHORT) :: NAME
117 namelist / monitor_item / &
125 log_info(
"MONITOR_setup",*)
'Setup' 131 log_info(
'MONITOR_setup',*)
'Not found namelist. Default used.' 132 elseif( ierr > 0 )
then 133 log_error(
'MONITOR_setup',*)
'Not appropriate names in namelist PARAM_MONITOR. Check!' 136 log_nml(param_monitor)
140 do n = 1, monitor_req_max
144 monitor_nreqs = n - 1
146 if ( monitor_nreqs > monitor_req_max )
then 147 log_error(
'MONITOR_setup',*)
'request of monitor file is exceed! n >', monitor_req_max
149 elseif( monitor_nreqs == 0 )
then 150 log_info(
'MONITOR_setup',*)
'No monitor file specified.' 153 log_info(
'MONITOR_setup',*)
'Number of requested monitor item : ', monitor_nreqs
154 log_info(
'MONITOR_setup',*)
'Monitor output interval [step] : ', monitor_step_interval
155 log_info(
'MONITOR_setup',*)
'Use deviation from first step? : ', monitor_usedevation
158 allocate( monitor_items(monitor_nreqs) )
161 do n = 1, monitor_nreqs
169 log_nml(monitor_item)
172 monitor_reqs(n) = name
184 KA, KS, KE, IA, IS, IE, JA, JS, JE, &
185 dim_type, dim_size, &
187 volume, total_volume )
188 integer,
intent(in) :: KA, KS, KE
189 integer,
intent(in) :: IA, IS, IE
190 integer,
intent(in) :: JA, JS, JE
192 character(len=*),
intent(in) :: dim_type
193 integer,
intent(in) :: dim_size
194 real(RP),
intent(in),
optional :: area(ia,ja)
195 real(RP),
intent(in),
optional :: total_area
196 real(RP),
intent(in),
optional :: volume(ka,ia,ja)
197 real(RP),
intent(in),
optional :: total_volume
201 monitor_ndims = monitor_ndims + 1
204 monitor_dims(n)%name = dim_type
205 monitor_dims(n)%dim_size = dim_size
207 monitor_dims(n)%KA = ka
208 monitor_dims(n)%KS = ks
209 monitor_dims(n)%KE = ke
210 monitor_dims(n)%IA = ia
211 monitor_dims(n)%IS = is
212 monitor_dims(n)%IE = ie
213 monitor_dims(n)%JA = ja
214 monitor_dims(n)%JS = js
215 monitor_dims(n)%JE = je
217 if ( dim_size >= 2 )
then 218 allocate( monitor_dims(n)%area(ia,ja) )
219 monitor_dims(n)%area(:,:) = area(:,:)
220 monitor_dims(n)%total_area = total_area
223 if ( dim_size >= 3 )
then 224 allocate( monitor_dims(n)%volume(ka,ia,ja) )
225 monitor_dims(n)%volume(:,:,:) = volume(:,:,:)
226 monitor_dims(n)%total_volume = total_volume
243 character(len=*),
intent(in) :: name
244 character(len=*),
intent(in) :: desc
245 character(len=*),
intent(in) :: unit
247 integer,
intent(out) :: itemid
249 integer,
intent(in),
optional :: ndims
250 character(len=*),
intent(in),
optional :: dim_type
251 logical,
intent(in),
optional :: isflux
253 integer :: n, reqid, dimid
257 do itemid = 1, monitor_nitems
258 if ( name == monitor_items(itemid)%name )
return 261 do reqid = 1, monitor_nreqs
262 if ( name == monitor_reqs(reqid) )
then 263 monitor_nitems = monitor_nitems + 1
264 itemid = monitor_nitems
267 monitor_items(itemid)%name = name
268 monitor_items(itemid)%desc = desc
269 monitor_items(itemid)%unit = unit
272 if (
present(dim_type) )
then 273 do n = 1, monitor_ndims
274 if ( monitor_dims(n)%name == dim_type )
then 279 if ( dimid < 0 )
then 280 log_error(
'MONITOR_reg',*)
'dim_type (', trim(dim_type),
') must be registerd by MONITOR_set_dim' 283 else if (
present(ndims) )
then 284 do n = 1, monitor_ndims
285 if ( monitor_dims(n)%dim_size == ndims )
then 290 if ( dimid == -1 )
then 291 log_error(
'MONITOR_reg',
'(a,i1,a)')
'dim_type of ', ndims,
'D must be registerd with MONITOR_set_dim' 296 do n = 1, monitor_ndims
297 if ( monitor_dims(n)%dim_size == 3 )
then 302 if ( dimid == -1 )
then 303 log_error(
'MONITOR_reg',*)
'dim_type or ndims must be specified' 308 monitor_items(itemid)%dimid = dimid
310 monitor_items(itemid)%var = 0.0_dp
311 monitor_items(itemid)%var0 = 0.0_dp
312 monitor_items(itemid)%first = .true.
313 if (
present(isflux) )
then 314 monitor_items(itemid)%flux = isflux
316 monitor_items(itemid)%flux = .false.
320 log_info(
'MONOTOR_reg',
'(A,I3)')
' Item registration No.= ', itemid
321 log_info_cont(*)
'Name : ', trim(monitor_items(itemid)%name)
322 log_info_cont(*)
'Description : ', trim(monitor_items(itemid)%desc)
323 log_info_cont(*)
'Unit : ', trim(monitor_items(itemid)%unit)
324 log_info_cont(*)
'Dimension type : ', trim(monitor_dims(monitor_items(itemid)%dimid)%name)
325 log_info_cont(*)
'Integ. with dt? : ', monitor_items(itemid)%flux
343 integer,
intent(in) :: itemid
344 real(RP),
intent(in) :: var(:,:)
350 if( itemid <= 0 )
return 352 dimid = monitor_items(itemid)%dimid
354 call statistics_total( monitor_dims(dimid)%IA, monitor_dims(dimid)%IS, monitor_dims(dimid)%IE, &
355 monitor_dims(dimid)%JA, monitor_dims(dimid)%JS, monitor_dims(dimid)%JE, &
356 var(:,:), monitor_items(itemid)%name, &
357 monitor_dims(dimid)%area(:,:), monitor_dims(dimid)%total_area, &
358 log_suppress = .true., &
361 if ( monitor_items(itemid)%flux )
then 362 if ( monitor_items(itemid)%first )
then 363 monitor_items(itemid)%var = total * monitor_dt
364 monitor_items(itemid)%first = .false.
366 monitor_items(itemid)%var = monitor_items(itemid)%var + total * monitor_dt
369 if ( monitor_usedevation )
then 370 if ( monitor_items(itemid)%first )
then 371 monitor_items(itemid)%var = 0.0_rp
372 monitor_items(itemid)%var0 = total
373 monitor_items(itemid)%first = .false.
375 monitor_items(itemid)%var = total - monitor_items(itemid)%var0
378 monitor_items(itemid)%var = total
393 integer,
intent(in) :: itemid
394 real(RP),
intent(in) :: var(:,:,:)
401 if( itemid <= 0 )
return 403 dimid = monitor_items(itemid)%dimid
406 call statistics_total( monitor_dims(dimid)%KA, monitor_dims(dimid)%KS, monitor_dims(dimid)%KE, &
407 monitor_dims(dimid)%IA, monitor_dims(dimid)%IS, monitor_dims(dimid)%IE, &
408 monitor_dims(dimid)%JA, monitor_dims(dimid)%JS, monitor_dims(dimid)%JE, &
409 var(:,:,:), monitor_items(itemid)%name, &
410 monitor_dims(dimid)%volume(:,:,:), monitor_dims(dimid)%total_volume, &
411 log_suppress = .true., &
414 if ( monitor_items(itemid)%flux )
then 415 if ( monitor_items(itemid)%first )
then 416 monitor_items(itemid)%var = total * monitor_dt
417 monitor_items(itemid)%first = .false.
419 monitor_items(itemid)%var = monitor_items(itemid)%var + total * monitor_dt
422 if ( monitor_usedevation )
then 423 if ( monitor_items(itemid)%first )
then 424 monitor_items(itemid)%var = 0.0_rp
425 monitor_items(itemid)%var0 = total
426 monitor_items(itemid)%first = .false.
428 monitor_items(itemid)%var = total - monitor_items(itemid)%var0
431 monitor_items(itemid)%var = total
447 real(RP),
intent(in) :: var(:,:)
448 character(len=*),
intent(in) :: name
449 character(len=*),
intent(in) :: desc
450 character(len=*),
intent(in) :: unit
452 integer,
intent(in),
optional :: ndims
453 character(len=*),
intent(in),
optional :: dim_type
454 logical,
intent(in),
optional :: isflux
461 ndims=ndims, dim_type=dim_type, &
463 call monitor_put( itemid, var(:,:) )
470 subroutine monitor_in_3d( &
477 real(RP),
intent(in) :: var(:,:,:)
478 character(len=*),
intent(in) :: name
479 character(len=*),
intent(in) :: desc
480 character(len=*),
intent(in) :: unit
482 integer,
intent(in),
optional :: ndims
483 character(len=*),
intent(in),
optional :: dim_type
484 logical,
intent(in),
optional :: isflux
491 ndims=ndims, dim_type=dim_type, &
493 call monitor_put( itemid, var(:,:,:) )
496 end subroutine monitor_in_3d
502 character(len=*),
intent(in) :: memo
503 integer ,
intent(in) :: nowstep
505 logical,
save :: firsttime = .true.
510 if( monitor_nitems == 0 )
return 516 call monitor_writeheader
519 if ( monitor_fid > 0 )
then 521 if ( mod(nowstep-1,monitor_step_interval) == 0 )
then 522 log_progress(*)
'output monitor' 524 write(monitor_fid,
'(A,i7,A,A4,A)',advance=
'no')
'STEP=',nowstep,
' (',memo,
')' 525 do n = 1, monitor_nitems
526 write(monitor_fid,
'(A,ES15.8)',advance=
'no')
' ', monitor_items(n)%var
540 subroutine monitor_writeheader
547 character(len=H_LONG) :: fname
555 log_info(
'MONITOR_writeheader',*)
'Output item list ' 556 log_info_cont(*)
'Number of monitor item :', monitor_nreqs
557 log_info_cont(
'(2A)')
'NAME :description ', &
558 ':UNIT :dimension_type' 559 log_info_cont(
'(2A)')
'=======================================================================', &
560 '===============================' 561 do n = 1, monitor_nitems
562 log_info_cont(
'(A24,A48,A16,A16)') monitor_items(n)%name, monitor_items(n)%desc, monitor_items(n)%unit, monitor_dims(monitor_items(n)%dimid)%name
564 log_info_cont(
'(2A)')
'=======================================================================', &
565 '===============================' 573 if ( monitor_l )
then 578 open( unit = monitor_fid, &
579 file = trim(fname), &
580 form =
'formatted', &
582 if ( ierr /= 0 )
then 583 log_error(
'MONITOR_writeheader',*)
'File open error! :', trim(fname)
588 log_info(
'MONITOR_writeheader',*)
'Open ASCII file for monitor, name : ', trim(fname)
590 write(monitor_fid,
'(A)',advance=
'no')
' ' 591 do n = 1, monitor_nitems
592 write(monitor_fid,
'(A16)',advance=
'no') monitor_items(n)%name
599 end subroutine monitor_writeheader
608 character(len=H_LONG) :: fname
613 if ( monitor_fid > 0 )
then 617 log_info(
'MONITOR_finalize',*)
'Close ASCII file for monitor, name : ', trim(fname)
622 do n = 1, monitor_ndims
623 if ( monitor_dims(n)%dim_size >= 2 )
deallocate( monitor_dims(n)%area )
624 if ( monitor_dims(n)%dim_size >= 3 )
deallocate( monitor_dims(n)%volume )
628 if (
allocated(monitor_items) )
deallocate( monitor_items )
subroutine monitor_put_3d(itemid, var)
Put total value to the monitor buffer.
subroutine, public monitor_set_dim(KA, KS, KE, IA, IS, IE, JA, JS, JE, dim_type, dim_size, area, total_area, volume, total_volume)
Set area and volume.
integer, public io_fid_nml
Log file ID (only for output namelist)
integer, public io_fid_conf
Config file ID.
subroutine, public monitor_write(memo, nowstep)
Flush monitor buffer to formatted file.
logical, public io_log_allnode
output log for each node?
integer function, public io_get_available_fid()
search & get available file ID
integer, public prc_myrank
process num in local communicator
subroutine, public prc_abort
Abort Process.
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
subroutine monitor_put_2d(itemid, var)
Put total value to the monitor buffer.
subroutine, public monitor_finalize
Close file.
logical, public prc_ismaster
master process in local communicator?
subroutine monitor_in_2d(var, name, desc, unit, ndims, dim_type, isflux)
Wrapper routine of MONITOR_reg+MONITOR_put.
subroutine, public monitor_setup(dt)
Setup.
subroutine, public io_make_idstr(outstr, instr, ext, rank, isrgn)
generate process specific filename
subroutine, public monitor_reg(name, desc, unit, itemid, ndims, dim_type, isflux)
Search existing item, or matching check between requested and registered item.
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
integer, public io_fid_log
Log file ID.