SCALE-RM
Data Types | Functions/Subroutines
scale_monitor Module Reference

module MONITOR More...

Functions/Subroutines

subroutine, public monitor_setup (dt)
 Setup. More...
 
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. More...
 
subroutine, public monitor_reg (name, desc, unit, itemid, ndims, dim_type, is_tendency)
 Search existing item, or matching check between requested and registered item. More...
 
subroutine monitor_put_2d (itemid, var)
 Put total value to the monitor buffer. More...
 
subroutine monitor_put_3d (itemid, var)
 Put total value to the monitor buffer. More...
 
subroutine monitor_in_2d (var, name, desc, unit, ndims, dim_type, is_tendency)
 Wrapper routine of MONITOR_reg+MONITOR_put. More...
 
subroutine, public monitor_write (memo, nowstep)
 Flush monitor buffer to formatted file. More...
 
subroutine, public monitor_finalize
 Close file. More...
 

Detailed Description

module MONITOR

Description
Monitor output module
Author
Team SCALE
NAMELIST
  • PARAM_MONITOR
    nametypedefault valuecomment
    MONITOR_OUT_BASENAME character(len=H_LONG) 'monitor' filename of monitor output
    MONITOR_USEDEVIATION logical .true. use deviation from first step?
    MONITOR_GLOBAL_SUM logical .true. global or local sum
    MONITOR_STEP_INTERVAL integer 1 step interval

  • MONITOR_ITEM
    nametypedefault valuecomment
    NAME character(len=*) name

History Output
No history output

Function/Subroutine Documentation

◆ monitor_setup()

subroutine, public scale_monitor::monitor_setup ( real(dp), intent(in)  dt)

Setup.

Definition at line 105 of file scale_monitor.F90.

105  use scale_prc, only: &
106  prc_abort
107  implicit none
108 
109  real(DP), intent(in) :: dt
110 
111  namelist / param_monitor / &
112  monitor_out_basename, &
113  monitor_usedeviation, &
114  monitor_global_sum, &
115  monitor_step_interval
116 
117  character(len=H_SHORT) :: NAME
118 
119  namelist / monitor_item / &
120  name
121 
122  integer :: ierr
123  integer :: n
124  !---------------------------------------------------------------------------
125 
126  log_newline
127  log_info("MONITOR_setup",*) 'Setup'
128 
129  !--- read namelist
130  rewind(io_fid_conf)
131  read(io_fid_conf,nml=param_monitor,iostat=ierr)
132  if( ierr < 0 ) then !--- missing
133  log_info('MONITOR_setup',*) 'Not found namelist. Default used.'
134  elseif( ierr > 0 ) then !--- fatal error
135  log_error('MONITOR_setup',*) 'Not appropriate names in namelist PARAM_MONITOR. Check!'
136  call prc_abort
137  endif
138  log_nml(param_monitor)
139 
140  ! listup monitor request
141  rewind(io_fid_conf)
142  do n = 1, monitor_req_max
143  read(io_fid_conf,nml=monitor_item,iostat=ierr)
144  if( ierr /= 0 ) exit
145  enddo
146  monitor_nreqs = n - 1
147 
148  if ( monitor_nreqs > monitor_req_max ) then
149  log_error('MONITOR_setup',*) 'request of monitor file is exceed! n >', monitor_req_max
150  call prc_abort
151  elseif( monitor_nreqs == 0 ) then
152  log_info('MONITOR_setup',*) 'No monitor file specified.'
153  return
154  else
155  log_info('MONITOR_setup',*) 'Number of requested monitor item : ', monitor_nreqs
156  log_info('MONITOR_setup',*) 'Monitor output interval [step] : ', monitor_step_interval
157  log_info('MONITOR_setup',*) 'Use deviation from first step? : ', monitor_usedeviation
158  endif
159 
160  allocate( monitor_items(monitor_nreqs) )
161 
162  rewind(io_fid_conf)
163  do n = 1, monitor_nreqs
164  ! set default
165  name = 'unknown'
166 
167  read(io_fid_conf,nml=monitor_item,iostat=ierr)
168  if( ierr /= 0 ) exit
169 
170  if ( io_fid_nml /= io_fid_log ) then
171  log_nml(monitor_item)
172  end if
173 
174  monitor_reqs(n) = name
175  enddo
176 
177 
178  monitor_dt = dt
179 
180  return

References scale_io::io_fid_conf, scale_io::io_fid_log, scale_io::io_fid_nml, and scale_prc::prc_abort().

Referenced by scale_monitor_cartesc::monitor_cartesc_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_set_dim()

subroutine, public scale_monitor::monitor_set_dim ( integer, intent(in)  KA,
integer, intent(in)  KS,
integer, intent(in)  KE,
integer, intent(in)  IA,
integer, intent(in)  IS,
integer, intent(in)  IE,
integer, intent(in)  JA,
integer, intent(in)  JS,
integer, intent(in)  JE,
character(len=*), intent(in)  dim_type,
integer, intent(in)  dim_size,
real(rp), dimension(ia,ja), intent(in), optional  area,
real(rp), intent(in), optional  total_area,
real(rp), dimension(ka,ia,ja), intent(in), optional  volume,
real(rp), intent(in), optional  total_volume 
)

Set area and volume.

Definition at line 190 of file scale_monitor.F90.

190  integer, intent(in) :: KA, KS, KE
191  integer, intent(in) :: IA, IS, IE
192  integer, intent(in) :: JA, JS, JE
193 
194  character(len=*), intent(in) :: dim_type
195  integer, intent(in) :: dim_size
196  real(RP), intent(in), optional :: area(IA,JA)
197  real(RP), intent(in), optional :: total_area
198  real(RP), intent(in), optional :: volume(KA,IA,JA)
199  real(RP), intent(in), optional :: total_volume
200 
201  integer :: n
202 
203  monitor_ndims = monitor_ndims + 1
204  n = monitor_ndims
205 
206  monitor_dims(n)%name = dim_type
207  monitor_dims(n)%dim_size = dim_size
208 
209  monitor_dims(n)%KA = ka
210  monitor_dims(n)%KS = ks
211  monitor_dims(n)%KE = ke
212  monitor_dims(n)%IA = ia
213  monitor_dims(n)%IS = is
214  monitor_dims(n)%IE = ie
215  monitor_dims(n)%JA = ja
216  monitor_dims(n)%JS = js
217  monitor_dims(n)%JE = je
218 
219  if ( dim_size >= 2 ) then
220  allocate( monitor_dims(n)%area(ia,ja) )
221  monitor_dims(n)%area(:,:) = area(:,:)
222  monitor_dims(n)%total_area = total_area
223  end if
224 
225  if ( dim_size >= 3 ) then
226  allocate( monitor_dims(n)%volume(ka,ia,ja) )
227  monitor_dims(n)%volume(:,:,:) = volume(:,:,:)
228  monitor_dims(n)%total_volume = total_volume
229  end if
230 
231  return

Referenced by scale_monitor_cartesc::monitor_cartesc_setup().

Here is the caller graph for this function:

◆ monitor_reg()

subroutine, public scale_monitor::monitor_reg ( character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
integer, intent(out)  itemid,
integer, intent(in), optional  ndims,
character(len=*), intent(in), optional  dim_type,
logical, intent(in), optional  is_tendency 
)

Search existing item, or matching check between requested and registered item.

Parameters
[in]namename of the item
[in]descdescription of the item
[in]unitunit of the item
[out]itemidindex number of the item
[in]ndims# of dimension
[in]dim_typedimension type
[in]is_tendencyneed to integrate value?

Definition at line 241 of file scale_monitor.F90.

241  use scale_prc, only: &
242  prc_abort
243  implicit none
244 
245  character(len=*), intent(in) :: name
246  character(len=*), intent(in) :: desc
247  character(len=*), intent(in) :: unit
248 
249  integer, intent(out) :: itemid
250 
251  integer, intent(in), optional :: ndims
252  character(len=*), intent(in), optional :: dim_type
253  logical, intent(in), optional :: is_tendency
254 
255  integer :: n, reqid, dimid
256  !---------------------------------------------------------------------------
257 
258  !--- search existing item
259  do itemid = 1, monitor_nitems
260  if ( name == monitor_items(itemid)%name ) return ! match existing item
261  enddo
262 
263  do reqid = 1, monitor_nreqs
264  if ( name == monitor_reqs(reqid) ) then
265  monitor_nitems = monitor_nitems + 1
266  itemid = monitor_nitems
267 
268  ! new file registration
269  monitor_items(itemid)%name = name
270  monitor_items(itemid)%desc = desc
271  monitor_items(itemid)%unit = unit
272 
273  dimid = -1
274  if ( present(dim_type) ) then
275  do n = 1, monitor_ndims
276  if ( monitor_dims(n)%name == dim_type ) then
277  dimid = n
278  exit
279  end if
280  end do
281  if ( dimid < 0 ) then
282  log_error('MONITOR_reg',*) 'dim_type (', trim(dim_type), ') must be registerd by MONITOR_set_dim'
283  call prc_abort
284  end if
285  else if ( present(ndims) ) then
286  do n = 1, monitor_ndims
287  if ( monitor_dims(n)%dim_size == ndims ) then
288  dimid = n
289  exit
290  end if
291  end do
292  if ( dimid == -1 ) then
293  log_error('MONITOR_reg','(a,i1,a)') 'dim_type of ', ndims, 'D must be registerd with MONITOR_set_dim'
294  call prc_abort
295  end if
296  else
297  ! ndims = 3 is assumed as default
298  do n = 1, monitor_ndims
299  if ( monitor_dims(n)%dim_size == 3 ) then
300  dimid = n
301  exit
302  end if
303  end do
304  if ( dimid == -1 ) then
305  log_error('MONITOR_reg',*) 'dim_type or ndims must be specified'
306  call prc_abort
307  end if
308  end if
309 
310  monitor_items(itemid)%dimid = dimid
311 
312  monitor_items(itemid)%var = 0.0_dp
313  monitor_items(itemid)%var0 = 0.0_dp
314  monitor_items(itemid)%first = .true.
315  if ( present(is_tendency) ) then
316  monitor_items(itemid)%tendency = is_tendency
317  else
318  monitor_items(itemid)%tendency = .false.
319  end if
320 
321  log_newline
322  log_info('MONOTOR_reg','(A,I3)') ' Item registration No.= ', itemid
323  log_info_cont(*) 'Name : ', trim(monitor_items(itemid)%name)
324  log_info_cont(*) 'Description : ', trim(monitor_items(itemid)%desc)
325  log_info_cont(*) 'Unit : ', trim(monitor_items(itemid)%unit)
326  log_info_cont(*) 'Dimension type : ', trim(monitor_dims(monitor_items(itemid)%dimid)%name)
327  log_info_cont(*) 'Integ. with dt? : ', monitor_items(itemid)%tendency
328 
329  return
330  end if
331  end do
332 
333  itemid = -1 ! not found
334 
335  return

References scale_prc::prc_abort().

Referenced by scale_atmos_dyn_tstep_large_fvm_heve::atmos_dyn_tstep_large_fvm_heve_setup(), mod_atmos_phy_mp_driver::atmos_phy_mp_driver_setup(), mod_atmos_phy_tb_driver::atmos_phy_tb_driver_setup(), mod_atmos_vars::atmos_vars_setup(), mod_land_vars::land_vars_setup(), monitor_in_2d(), mod_ocean_vars::ocean_vars_setup(), and mod_urban_vars::urban_vars_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_put_2d()

subroutine scale_monitor::monitor_put_2d ( integer, intent(in)  itemid,
real(rp), dimension(:,:), intent(in)  var 
)

Put total value to the monitor buffer.

Parameters
[in]itemidindex number of the item
[in]varvalue

Definition at line 342 of file scale_monitor.F90.

342  use scale_statistics, only: &
343  statistics_total
344  implicit none
345  integer, intent(in) :: itemid
346  real(RP), intent(in) :: var(:,:)
347 
348  integer :: dimid
349  real(DP) :: total
350  !---------------------------------------------------------------------------
351 
352  if( itemid <= 0 ) return
353 
354  dimid = monitor_items(itemid)%dimid
355 
356  call statistics_total( monitor_dims(dimid)%IA, monitor_dims(dimid)%IS, monitor_dims(dimid)%IE, &
357  monitor_dims(dimid)%JA, monitor_dims(dimid)%JS, monitor_dims(dimid)%JE, &
358  var(:,:), monitor_items(itemid)%name, & ! (in)
359  monitor_dims(dimid)%area(:,:), monitor_dims(dimid)%total_area, & ! (in)
360  log_suppress = .true., global = monitor_global_sum, & ! (in)
361  sum = total ) ! (out)
362 
363  if ( monitor_items(itemid)%tendency ) then
364  if ( monitor_items(itemid)%first ) then
365  monitor_items(itemid)%var = 0.0_rp
366  monitor_items(itemid)%first = .false.
367  else
368  monitor_items(itemid)%var = monitor_items(itemid)%var + total * monitor_dt ! integrate by last put
369  endif
370  else
371  if ( monitor_usedeviation ) then
372  if ( monitor_items(itemid)%first ) then
373  monitor_items(itemid)%var = 0.0_rp
374  monitor_items(itemid)%var0 = total
375  monitor_items(itemid)%first = .false.
376  else
377  monitor_items(itemid)%var = total - monitor_items(itemid)%var0 ! overwrite by last put
378  endif
379  else
380  monitor_items(itemid)%var = total ! overwrite by last put
381  endif
382  endif
383 
384  return

◆ monitor_put_3d()

subroutine scale_monitor::monitor_put_3d ( integer, intent(in)  itemid,
real(rp), dimension(:,:,:), intent(in)  var 
)

Put total value to the monitor buffer.

Parameters
[in]itemidindex number of the item
[in]varvalue

Definition at line 391 of file scale_monitor.F90.

391  use scale_statistics, only: &
392  statistics_total
393  implicit none
394 
395  integer, intent(in) :: itemid
396  real(RP), intent(in) :: var(:,:,:)
397 
398  integer :: dimid
399 
400  real(DP) :: total
401  !---------------------------------------------------------------------------
402 
403  if( itemid <= 0 ) return
404 
405  dimid = monitor_items(itemid)%dimid
406 
407 
408  call statistics_total( monitor_dims(dimid)%KA, monitor_dims(dimid)%KS, monitor_dims(dimid)%KE, &
409  monitor_dims(dimid)%IA, monitor_dims(dimid)%IS, monitor_dims(dimid)%IE, &
410  monitor_dims(dimid)%JA, monitor_dims(dimid)%JS, monitor_dims(dimid)%JE, &
411  var(:,:,:), monitor_items(itemid)%name, & ! (in)
412  monitor_dims(dimid)%volume(:,:,:), monitor_dims(dimid)%total_volume, & ! (in)
413  log_suppress = .true., global = monitor_global_sum, & ! (in)
414  sum = total ) ! (out)
415 
416  if ( monitor_items(itemid)%tendency ) then
417  if ( monitor_items(itemid)%first ) then
418  monitor_items(itemid)%var = total * monitor_dt ! first put
419  monitor_items(itemid)%first = .false.
420  else
421  monitor_items(itemid)%var = monitor_items(itemid)%var + total * monitor_dt ! integrate by last put
422  endif
423  else
424  if ( monitor_usedeviation ) then
425  if ( monitor_items(itemid)%first ) then
426  monitor_items(itemid)%var = 0.0_rp
427  monitor_items(itemid)%var0 = total
428  monitor_items(itemid)%first = .false.
429  else
430  monitor_items(itemid)%var = total - monitor_items(itemid)%var0 ! overwrite by last put
431  endif
432  else
433  monitor_items(itemid)%var = total ! overwrite by last put
434  endif
435  endif
436 
437  return

◆ monitor_in_2d()

subroutine scale_monitor::monitor_in_2d ( real(rp), dimension(:,:), intent(in)  var,
character(len=*), intent(in)  name,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
integer, intent(in), optional  ndims,
character(len=*), intent(in), optional  dim_type,
logical, intent(in), optional  is_tendency 
)

Wrapper routine of MONITOR_reg+MONITOR_put.

Parameters
[in]varvalue
[in]descdescription
[in]ndims# of dimension
[in]dim_typedimension type
[in]is_tendencyneed to integrate values?

Definition at line 447 of file scale_monitor.F90.

447  implicit none
448 
449  real(RP), intent(in) :: var(:,:)
450  character(len=*), intent(in) :: name
451  character(len=*), intent(in) :: desc
452  character(len=*), intent(in) :: unit
453 
454  integer, intent(in), optional :: ndims
455  character(len=*), intent(in), optional :: dim_type
456  logical, intent(in), optional :: is_tendency
457 
458  integer :: itemid
459  !---------------------------------------------------------------------------
460 
461  call monitor_reg( name, desc, unit, & ! (in)
462  itemid, & ! (out)
463  ndims=ndims, dim_type=dim_type, & ! (in)
464  is_tendency=is_tendency ) ! (in)
465  call monitor_put( itemid, var(:,:) )
466 
467  return

References monitor_reg().

Here is the call graph for this function:

◆ monitor_write()

subroutine, public scale_monitor::monitor_write ( character(len=*), intent(in)  memo,
integer, intent(in)  nowstep 
)

Flush monitor buffer to formatted file.

Parameters
[in]memonote

Definition at line 503 of file scale_monitor.F90.

503  implicit none
504  character(len=*), intent(in) :: memo
505  integer , intent(in) :: nowstep
506 
507  logical, save :: firsttime = .true.
508 
509  integer :: n
510  !---------------------------------------------------------------------------
511 
512  if( monitor_nitems == 0 ) return
513 
514  call prof_rapstart('FILE_O_ASCII', 2)
515 
516  if (firsttime) then
517  firsttime = .false.
518  call monitor_writeheader
519  endif
520 
521  if ( monitor_fid > 0 ) then
522 
523  if ( mod(nowstep-1,monitor_step_interval) == 0 ) then
524  log_progress(*) 'output monitor'
525 
526  write(monitor_fid,'(A,i7,A,A4,A)',advance='no') 'STEP=',nowstep,' (',memo,')'
527  do n = 1, monitor_nitems
528  write(monitor_fid,'(A,ES15.8)',advance='no') ' ', monitor_items(n)%var
529  enddo
530  write(monitor_fid,*)
531  endif
532 
533  endif
534 
535  call prof_rapend ('FILE_O_ASCII', 2)
536 
537  return

References scale_io::io_get_available_fid(), scale_io::io_log_allnode, scale_io::io_make_idstr(), scale_prc::prc_abort(), scale_prc::prc_ismaster, scale_prc::prc_myrank, scale_prof::prof_rapend(), and scale_prof::prof_rapstart().

Referenced by mod_rm_driver::rm_driver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ monitor_finalize()

subroutine, public scale_monitor::monitor_finalize

Close file.

Definition at line 610 of file scale_monitor.F90.

610  use scale_prc, only: &
611  prc_myrank
612  implicit none
613 
614  character(len=H_LONG) :: fname
615 
616  integer :: n
617  !---------------------------------------------------------------------------
618 
619  if ( monitor_fid > 0 ) then
620  call io_make_idstr(fname,trim(monitor_out_basename),'pe',prc_myrank)
621 
622  log_newline
623  log_info('MONITOR_finalize',*) 'Close ASCII file for monitor, name : ', trim(fname)
624 
625  close(monitor_fid)
626  endif
627 
628  do n = 1, monitor_ndims
629  if ( monitor_dims(n)%dim_size >= 2 ) deallocate( monitor_dims(n)%area )
630  if ( monitor_dims(n)%dim_size >= 3 ) deallocate( monitor_dims(n)%volume )
631  end do
632  monitor_ndims = 0
633 
634  if ( allocated(monitor_items) ) deallocate( monitor_items )
635  monitor_nitems = 0
636 
637  return

References scale_io::io_make_idstr(), and scale_prc::prc_myrank.

Referenced by mod_rm_driver::rm_driver().

Here is the call graph for this function:
Here is the caller graph for this function:
scale_statistics
module Statistics
Definition: scale_statistics.F90:11
scale_prc::prc_abort
subroutine, public prc_abort
Abort Process.
Definition: scale_prc.F90:342
scale_prc::prc_myrank
integer, public prc_myrank
process num in local communicator
Definition: scale_prc.F90:90
scale_prc
module PROCESS
Definition: scale_prc.F90:11