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

module MONITOR More...

Functions/Subroutines

subroutine, public monit_setup
 Setup. More...
 
subroutine, public monit_reg (itemid, item, desc, unit, ndim, isflux)
 Search existing item, or matching check between requested and registered item. More...
 
subroutine monit_put_3d (itemid, var)
 Put total value to the monitor buffer. More...
 
subroutine monit_in_2d (var, item, desc, unit, ndim, isflux)
 Wrapper routine of MONIT_reg+MONIT_put. More...
 
subroutine, public monit_write (memo)
 Flush monitor buffer to formatted file. More...
 
subroutine, public monit_finalize
 Close file. More...
 

Detailed Description

module MONITOR

Description
Monitor output module
Author
Team SCALE
History
  • 2012-03-22 (H.Yashiro) [new]
NAMELIST
  • PARAM_MONITOR
    nametypedefault valuecomment
    MONITOR_OUT_BASENAME character(len=H_LONG) 'monitor' filename of monitor output
    MONITOR_USEDEVATION logical .true. use deviation from first step?
    MONITOR_STEP_INTERVAL integer 1 step interval

  • MONITITEM
    nametypedefault valuecomment
    ITEM character(len=*) name of the item

History Output
No history output

Function/Subroutine Documentation

◆ monit_setup()

subroutine, public scale_monitor::monit_setup ( )

Setup.

Definition at line 89 of file scale_monitor.F90.

References scale_stdio::io_fid_conf, scale_stdio::io_fid_log, scale_stdio::io_l, scale_stdio::io_lnml, and scale_process::prc_mpistop().

Referenced by mod_rm_driver::scalerm().

89  use scale_process, only: &
91  implicit none
92 
93  namelist / param_monitor / &
94  monitor_out_basename, &
95  monitor_usedevation, &
96  monitor_step_interval
97 
98  character(len=H_SHORT) :: item
99 
100  namelist / monititem / &
101  item
102 
103  integer :: ierr
104  integer :: n
105  !---------------------------------------------------------------------------
106 
107  if( io_l ) write(io_fid_log,*)
108  if( io_l ) write(io_fid_log,*) '++++++ Module[MONITOR] / Categ[IO] / Origin[SCALElib]'
109 
110  !--- read namelist
111  rewind(io_fid_conf)
112  read(io_fid_conf,nml=param_monitor,iostat=ierr)
113  if( ierr < 0 ) then !--- missing
114  if( io_l ) write(io_fid_log,*) '*** Not found namelist. Default used.'
115  elseif( ierr > 0 ) then !--- fatal error
116  write(*,*) 'xxx Not appropriate names in namelist PARAM_MONITOR. Check!'
117  call prc_mpistop
118  endif
119  if( io_lnml ) write(io_fid_log,nml=param_monitor)
120 
121  ! listup monitor request
122  rewind(io_fid_conf)
123  do n = 1, monit_req_limit
124  read(io_fid_conf,nml=monititem,iostat=ierr)
125  if( ierr /= 0 ) exit
126  enddo
127  monit_req_nmax = n - 1
128 
129  if( io_l ) write(io_fid_log,*)
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
133  if( io_l ) write(io_fid_log,*) '*** No monitor file specified.'
134  return
135  else
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
139  endif
140 
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) )
150 
151  rewind(io_fid_conf)
152  do n = 1, monit_req_nmax
153  ! set default
154  item = 'unknown'
155 
156  read(io_fid_conf,nml=monititem,iostat=ierr)
157  if( ierr /= 0 ) exit
158 
159  monit_req_item(n) = item
160  enddo
161 
162  return
subroutine, public prc_mpistop
Abort MPI.
module PROCESS
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ monit_reg()

subroutine, public scale_monitor::monit_reg ( integer, intent(out)  itemid,
character(len=*), intent(in)  item,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
integer, intent(in)  ndim,
logical, intent(in)  isflux 
)

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

Parameters
[out]itemidindex number of the item
[in]itemname of the item
[in]descdescription of the item
[in]unitunit of the item
[in]ndimdimension of the item
[in]isfluxneed to integrate value?

Definition at line 174 of file scale_monitor.F90.

References scale_stdio::io_fid_log, scale_stdio::io_l, scale_grid_index::kmax, and scale_time::time_dtsec.

Referenced by mod_atmos_vars::atmos_vars_setup(), and monit_in_2d().

174  implicit none
175 
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
182 
183  character(len=8) :: lname
184 
185  integer :: n, nmax, reqid
186  !---------------------------------------------------------------------------
187 
188  !--- search existing item
189  itemid = -1
190  nmax = min( monit_id_count, monit_req_nmax )
191  do n = 1, nmax
192  if ( item == monit_item(n) ) then ! match existing item
193  itemid = n
194  return
195  endif
196  enddo
197 
198  if ( itemid < 0 ) then ! request-register matching check
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
203  reqid = n
204 
205  ! new file registration
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
216  endif
217  monit_var(itemid) = 0.0_rp
218  monit_var0(itemid) = 0.0_rp
219  monit_first(itemid) = .true.
220  monit_flux(itemid) = isflux
221 
222  if( io_l ) write(io_fid_log,*)
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)
230  endif
231  enddo
232  endif
233 
234  return
integer, public kmax
of computational cells: z
Here is the caller graph for this function:

◆ monit_put_3d()

subroutine scale_monitor::monit_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 287 of file scale_monitor.F90.

References scale_time::time_dtsec.

287  use scale_time, only: &
288  dt => time_dtsec
289  use scale_rm_statistics, only: &
290  stat_total
291  implicit none
292 
293  integer, intent(in) :: itemid
294  real(RP), intent(in) :: var(:,:,:)
295 
296  real(RP) :: total
297  !---------------------------------------------------------------------------
298 
299  if( itemid <= 0 ) return
300 
301  call stat_total( total, var(:,:,:), monit_item(itemid) )
302 
303  if ( monit_flux(itemid) ) then
304  if ( monit_first(itemid) ) then
305  monit_var(itemid) = total * dt ! first put
306  monit_first(itemid) = .false.
307  else
308  monit_var(itemid) = monit_var(itemid) + total * dt ! integrate by last put
309  endif
310  else
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.
316  else
317  monit_var(itemid) = total - monit_var0(itemid) ! overwrite by last put
318  endif
319  else
320  monit_var(itemid) = total ! overwrite by last put
321  endif
322  endif
323 
324  return
module Statistics
real(dp), public time_dtsec
time interval of model [sec]
Definition: scale_time.F90:36
module TIME
Definition: scale_time.F90:15

◆ monit_in_2d()

subroutine scale_monitor::monit_in_2d ( real(rp), dimension(:,:), intent(in)  var,
character(len=*), intent(in)  item,
character(len=*), intent(in)  desc,
character(len=*), intent(in)  unit,
integer, intent(in)  ndim,
logical, intent(in)  isflux 
)

Wrapper routine of MONIT_reg+MONIT_put.

Parameters
[in]varvalue
[in]itemname of the item
[in]descdescription of the item
[in]unitunit of the item
[in]ndimdimension of the item
[in]isfluxneed to integrate values?

Definition at line 336 of file scale_monitor.F90.

References monit_reg().

336  implicit none
337 
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
344 
345  integer :: itemid
346  !---------------------------------------------------------------------------
347 
348  call monit_reg( itemid, item, desc, unit, ndim, isflux )
349  call monit_put( itemid, var(:,:) )
350 
351  return
Here is the call graph for this function:

◆ monit_write()

subroutine, public scale_monitor::monit_write ( character(len=4), intent(in)  memo)

Flush monitor buffer to formatted file.

Parameters
[in]memonote

Definition at line 384 of file scale_monitor.F90.

References scale_stdio::io_fid_log, scale_stdio::io_get_available_fid(), scale_stdio::io_l, scale_stdio::io_log_allnode, scale_stdio::io_make_idstr(), scale_process::prc_ismaster, scale_process::prc_mpistop(), scale_process::prc_myrank, scale_prof::prof_rapend(), scale_prof::prof_rapstart(), and scale_time::time_nowstep.

Referenced by mod_rm_driver::scalerm().

384  use scale_time, only: &
385  nowstep => time_nowstep
386  implicit none
387 
388  character(len=4), intent(in) :: memo
389 
390  logical, save :: firsttime = .true.
391 
392  integer :: n
393  !---------------------------------------------------------------------------
394 
395  if( monit_id_count == 0 ) return
396 
397  call prof_rapstart('FILE_O_ASCII', 2)
398 
399  if (firsttime) then
400  firsttime = .false.
401  call monit_writeheader
402  endif
403 
404  if ( monit_fid > 0 ) then
405 
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)
410  enddo
411  write(monit_fid,*)
412  endif
413 
414  endif
415 
416  call prof_rapend ('FILE_O_ASCII', 2)
417 
418  return
integer, public time_nowstep
current step [number]
Definition: scale_time.F90:70
module TIME
Definition: scale_time.F90:15
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:132
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:178
Here is the call graph for this function:
Here is the caller graph for this function:

◆ monit_finalize()

subroutine, public scale_monitor::monit_finalize ( )

Close file.

Definition at line 488 of file scale_monitor.F90.

References scale_stdio::io_fid_log, scale_stdio::io_l, scale_stdio::io_make_idstr(), and scale_process::prc_myrank.

Referenced by mod_rm_driver::scalerm().

488  use scale_process, only: &
489  prc_myrank
490  implicit none
491 
492  character(len=H_LONG) :: fname
493  !---------------------------------------------------------------------------
494 
495  if ( monit_fid > 0 ) then
496  close(monit_fid)
497 
498  call io_make_idstr(fname,trim(monitor_out_basename),'pe',prc_myrank)
499  if( io_l ) write(io_fid_log,*) '*** [MONITOR] File Close'
500  if( io_l ) write(io_fid_log,*) '*** closed filename: ', fname
501  endif
502 
503  return
module PROCESS
integer, public prc_myrank
process num in local communicator
Here is the call graph for this function:
Here is the caller graph for this function: