SCALE-RM
mod_rm_driver.f90
Go to the documentation of this file.
1 !-------------------------------------------------------------------------------
14 !-------------------------------------------------------------------------------
16  !-----------------------------------------------------------------------------
17  !
18  !++ used modules
19  !
20  use dc_log, only: &
21  loginit
22  use gtool_file, only: &
24  use scale_precision
25  use scale_stdio
26  use scale_prof
27  !-----------------------------------------------------------------------------
28  implicit none
29  private
30  !-----------------------------------------------------------------------------
31  !
32  !++ included parameters
33  !
34 #include "scale-rm.h"
35  !-----------------------------------------------------------------------------
36  !
37  !++ Public procedure
38  !
39  public :: scalerm
40 
41  !-----------------------------------------------------------------------------
42  !
43  !++ Public parameters & variables
44  !
45  !-----------------------------------------------------------------------------
46  !
47  !++ Private procedure
48  !
49  !-----------------------------------------------------------------------------
50  !
51  !++ Private parameters & variables
52  !
53  character(len=H_MID), private, parameter :: MODELNAME = "SCALE-RM ver. "//version
54 
55  !-----------------------------------------------------------------------------
56 contains
57  !-----------------------------------------------------------------------------
59  subroutine scalerm( &
60  comm_world, &
61  intercomm_parent, &
62  intercomm_child, &
63  cnf_fname )
64  use scale_process, only: &
66  use scale_rm_process, only: &
67  prc_setup
68  use scale_const, only: &
70  use scale_calendar, only: &
72  use scale_random, only: &
74  use scale_grid_index, only: &
76  use scale_grid, only: &
77  grid_setup, &
78  dx, &
79  dy
80  use scale_grid_nest, only: &
82  use scale_land_grid_index, only: &
84  use scale_land_grid, only: &
86  use scale_urban_grid_index, only: &
88  use scale_urban_grid, only: &
90  use scale_fileio, only: &
91  fileio_setup, &
93  use scale_comm, only: &
94  comm_setup , &
96  use scale_topography, only: &
98  use scale_landuse, only: &
100  use scale_grid_real, only: &
101  real_setup
102  use scale_gridtrans, only: &
104  use scale_interpolation, only: &
106  use scale_rm_statistics, only: &
107  stat_setup
108  use scale_history, only: &
109  hist_setup, &
110  hist_write
111  use scale_monitor, only: &
112  monit_setup, &
113  monit_write, &
115  use scale_external_input, only: &
117  use scale_atmos_hydrostatic, only: &
119  use scale_atmos_thermodyn, only: &
121  use scale_atmos_hydrometeor, only: &
123  use scale_atmos_saturation, only: &
125  use scale_bulkflux, only: &
127  use scale_roughness, only: &
129 
130  use mod_atmos_driver, only: &
132  use mod_admin_restart, only: &
135  use mod_admin_time, only: &
143  time_doresume, &
144  time_doend
145  use mod_atmos_admin, only: &
147  atmos_do
148  use mod_atmos_vars, only: &
150  atmos_sw_check => atmos_restart_check, &
152  use mod_atmos_driver, only: &
154  atmos_driver, &
156  use mod_ocean_admin, only: &
158  ocean_do
159  use mod_ocean_vars, only: &
161  use mod_ocean_driver, only: &
164  use mod_land_admin, only: &
166  land_do
167  use mod_land_vars, only: &
169  use mod_land_driver, only: &
172  use mod_urban_admin, only: &
174  urban_do
175  use mod_urban_vars, only: &
177  use mod_urban_driver, only: &
180  use mod_cpl_admin, only: &
182  use mod_cpl_vars, only: &
184  use mod_user, only: &
185  user_config, &
186  user_setup, &
187  user_step
188  implicit none
189 
190  integer, intent(in) :: comm_world
191  integer, intent(in) :: intercomm_parent
192  integer, intent(in) :: intercomm_child
193  character(len=*), intent(in) :: cnf_fname
194 
195  integer :: myrank
196  logical :: ismaster
197  !---------------------------------------------------------------------------
198 
199  !########## Initial setup ##########
200 
201  ! setup standard I/O
202  call io_setup( modelname, .true., cnf_fname )
203 
204  ! setup MPI
205  call prc_local_setup( comm_world, & ! [IN]
206  myrank, & ! [OUT]
207  ismaster ) ! [OUT]
208 
209  ! setup Log
210  call io_log_setup( myrank, ismaster )
211  call loginit( io_fid_conf, &
212  io_fid_log, io_l, &
213  io_fid_nml, io_nml )
214 
215  ! setup process
216  call prc_setup
217 
218  ! setup PROF
219  call prof_setup
220 
221 
222  ! profiler start
223  call prof_setprefx('INIT')
224  call prof_rapstart('Initialize', 0)
225 
226 
227  ! setup constants
228  call const_setup
229 
230  ! setup calendar
231  call calendar_setup
232 
233  ! setup random number
234  call random_setup
235 
236  ! setup horizontal/vertical grid coordinates (cartesian,idealized)
237  call grid_index_setup
238  call grid_setup
239 
241  call land_grid_setup
242 
244  call urban_grid_setup
245 
246  ! setup submodel administrator
247  call atmos_admin_setup
248  call ocean_admin_setup
249  call land_admin_setup
250  call urban_admin_setup
251  call cpl_admin_setup
252 
253  ! setup tracer index
255  call atmos_driver_config
256  call user_config
257 
258  ! setup file I/O
259  call fileio_setup
260 
261  ! setup mpi communication
262  call comm_setup
263 
264  ! setup topography
265  call topo_setup
266  ! setup land use category index/fraction
267  call landuse_setup
268  ! setup grid coordinates (real world)
269  call real_setup
270 
271  ! setup grid transfer metrics (uses in ATMOS_dynamics)
272  call gtrans_setup
273  ! setup Z-ZS interpolation factor (uses in History)
274  call interp_setup
275 
276  ! setup restart
278  ! setup time
279  call admin_time_setup( setup_timeintegration = .true. )
280  ! setup statistics
281  call stat_setup
282  ! setup history I/O
283  call hist_setup
284  ! setup monitor I/O
285  call monit_setup
286  ! setup external in
287  call extin_setup( 'RM' )
288 
289  ! setup nesting grid
290  call nest_setup ( intercomm_parent, intercomm_child )
291 
292  ! setup common tools
296 
297  call bulkflux_setup( sqrt(dx**2+dy**2) )
298  call roughness_setup
299 
300  ! setup variable container
301  call atmos_vars_setup
302  call ocean_vars_setup
303  call land_vars_setup
304  call urban_vars_setup
305  call cpl_vars_setup
306 
307  ! setup submodel driver
308  call atmos_driver_setup
309  call ocean_driver_setup
310  call land_driver_setup
311  call urban_driver_setup
312 
313  call user_setup
314 
315  call prof_rapend('Initialize', 0)
316 
317  !########## main ##########
318 
319 #ifdef FIPP
320  call fipp_start
321 #endif
322 #ifdef PAPI
323  call prof_papi_rapstart
324 #endif
325 
326  if( io_l ) write(io_fid_log,*)
327  if( io_l ) write(io_fid_log,*) '++++++ START TIMESTEP ++++++'
328  call prof_setprefx('MAIN')
329  call prof_rapstart('Main_Loop', 0)
330 
331  do
332 
333  ! report current time
335 
336  if ( time_doresume ) then
337  ! resume state from restart files
338  call resume_state
339 
340  ! history&monitor file output
341  call monit_write('MAIN')
342  call hist_write ! if needed
343  end if
344 
345 
346  ! time advance
347  call admin_time_advance
348 
349  ! user-defined procedure
350  call user_step
351 
352  ! change to next state
353  if( ocean_do .AND. time_doocean_step ) call ocean_driver
354  if( land_do .AND. time_doland_step ) call land_driver
355  if( urban_do .AND. time_dourban_step ) call urban_driver
356  if( atmos_do .AND. time_doatmos_step ) call atmos_driver
357 
358  ! history&monitor file output
359  call monit_write('MAIN')
360  call hist_write
361 
362  ! restart output
364 
365  if( time_doend ) exit
366 
367  if( io_l ) call flush(io_fid_log)
368 
369  enddo
370 
371  call prof_rapend('Main_Loop', 0)
372 
373  if( io_l ) write(io_fid_log,*) '++++++ END TIMESTEP ++++++'
374  if( io_l ) write(io_fid_log,*)
375 
376 
377  call prof_setprefx('FIN')
378 
379  call prof_rapstart('All', 1)
380 
382 
383 #ifdef FIPP
384  call fipp_stop
385 #endif
386 #ifdef PAPI
387  call prof_papi_rapstop
388 #endif
389 
390  !########## Finalize ##########
391 
392  ! check data
393  if( atmos_sw_check ) call atmos_vars_restart_check
394 
395  call prof_rapstart('Monit', 2)
396  call monit_finalize
397  call prof_rapend ('Monit', 2)
398 
399  call prof_rapstart('File', 2)
400  ! clean up resource allocated for I/O
401  call fileio_cleanup
402 
403  call comm_cleanup
404 
405  call filecloseall
406  call prof_rapend ('File', 2)
407 
408  call prof_rapend ('All', 1)
409 
410  call prof_rapreport
411 #ifdef PAPI
412  call prof_papi_rapreport
413 #endif
414 
415  return
416  end subroutine scalerm
417 
418  !-----------------------------------------------------------------------------
419  subroutine resume_state
420  use mod_atmos_driver, only: &
424  use mod_ocean_driver, only: &
427  use mod_land_driver, only: &
430  use mod_urban_driver, only: &
433  use mod_atmos_vars, only: &
437  use mod_ocean_vars, only: &
439  use mod_land_vars, only: &
441  use mod_urban_vars, only: &
443  use mod_user, only: &
444  user_resume0, &
446  use mod_atmos_admin, only: &
447  atmos_do
448  use mod_ocean_admin, only: &
449  ocean_do
450  use mod_land_admin, only: &
451  land_do
452  use mod_urban_admin, only: &
453  urban_do
454  use mod_admin_restart, only: &
456  implicit none
457  !---------------------------------------------------------------------------
458 
459  ! read restart data
460  call admin_restart_read
461 
462  ! setup user-defined procedure before setup of other components
463  call user_resume0
464 
465  if ( atmos_do ) then
466  ! calc diagnostics
469  endif
470 
471  ! setup surface condition
472  if( atmos_do ) call atmos_surface_set( countup=.false. )
473  if( ocean_do ) call ocean_surface_set( countup=.false. )
474  if( land_do ) call land_surface_set ( countup=.false. )
475  if( urban_do ) call urban_surface_set( countup=.false. )
476 
477  ! setup submodel driver
478  if( atmos_do ) call atmos_driver_resume1
479  if( ocean_do ) call ocean_driver_resume
480  if( land_do ) call land_driver_resume
481  if( urban_do ) call urban_driver_resume
482  if( atmos_do ) call atmos_driver_resume2
483 
484  ! setup user-defined procedure
485  call user_resume
486 
487  return
488  end subroutine resume_state
489 
490 end module mod_rm_driver
module ATMOS admin
module Land admin
subroutine, public nest_setup(inter_parent, inter_child)
Setup.
subroutine, public monit_finalize
Close file.
module GTOOL_FILE
Definition: gtool_file.f90:17
subroutine, public interp_setup
Setup.
subroutine, public prof_setup
Definition: scale_prof.F90:102
real(rp), public dy
length in the main region [m]: y
subroutine, public atmos_surface_set(countup)
Set surface boundary condition.
module ATMOSPHERE / Saturation adjustment
logical, public time_dourban_step
execute urban component in this step?
subroutine, public prof_setprefx(prefxname)
Definition: scale_prof.F90:138
subroutine, public atmos_saturation_setup
Setup.
module DC_Log
Definition: dc_log.f90:14
subroutine, public urban_grid_index_setup
Setup.
logical, public time_doend
finish program in this step?
subroutine, public ocean_driver_setup
Setup.
module GRID (nesting system)
subroutine, public user_step
User step.
Definition: mod_user.f90:148
real(rp), public dx
length in the main region [m]: x
module URBAN driver
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:61
module USER
Definition: mod_user.f90:14
subroutine, public landuse_setup
Setup.
subroutine, public random_setup
Setup.
subroutine, public scalerm(comm_world, intercomm_parent, intercomm_child, cnf_fname)
Setup.
subroutine, public roughness_setup
subroutine, public prc_setup
Setup Processor topology.
logical, public ocean_do
subroutine, public land_vars_setup
Setup.
module ATMOSPHERIC Variables
subroutine, public urban_vars_restart_read
Read urban restart.
subroutine, public fileio_setup
Setup.
module STDIO
Definition: scale_stdio.F90:12
subroutine, public grid_index_setup
Setup.
subroutine, public extin_setup(model)
Setup.
module GRID (cartesian) for land
subroutine, public atmos_driver_config
Config.
subroutine, public filecloseall
module URBAN Variables
subroutine, public io_log_setup(myrank, is_master)
Setup LOG.
module FILE I/O (netcdf)
subroutine, public land_admin_setup
Setup.
module Statistics
subroutine, public urban_surface_set(countup)
Set surface boundary to other model.
subroutine, public land_vars_restart_read
Read land restart.
module SCALE-RM (a main routine of regional model)
module grid index
logical, public io_nml
output log or not? (for namelist, this process)
Definition: scale_stdio.F90:62
subroutine, public admin_time_setup(setup_TimeIntegration)
Setup.
subroutine, public admin_restart_setup
Setup.
subroutine, public land_driver_resume
Resume.
subroutine, public real_setup
Setup.
subroutine, public topo_setup
Setup.
subroutine, public urban_grid_setup
Setup.
module GRIDTRANS
module GRID (cartesian) for urban
logical, public time_doocean_step
execute ocean component in this step?
subroutine, public calendar_setup
Setup.
module GRID (real space)
module LANDUSE
logical, public time_doresume
resume in this step?
subroutine, public land_driver_setup
Setup.
module OCEAN driver
subroutine, public cpl_vars_setup
Setup.
subroutine, public ocean_surface_set(countup)
Put surface boundary to other model.
subroutine, public hist_write
Flush history buffer to file.
module COUPLER Variables
module MONITOR
subroutine, public urban_driver
Urban step.
subroutine, public atmos_vars_setup
Setup.
module ATMOSPHERE driver
subroutine, public const_setup
Setup.
subroutine, public io_setup(MODELNAME, call_from_launcher, fname_in)
Setup.
Definition: scale_stdio.F90:88
logical, public atmos_do
subroutine, public comm_cleanup
module COMMUNICATION
Definition: scale_comm.F90:23
subroutine, public ocean_driver_resume
Resume.
module ATMOSPHERE / Hydrostatic barance
subroutine, public atmos_driver_resume1
Resume.
subroutine, public stat_setup
Setup.
module PROCESS
subroutine, public urban_driver_resume
Resume.
module Ocean admin
subroutine, public land_grid_setup
Setup.
subroutine, public atmos_thermodyn_setup
Setup.
subroutine, public atmos_driver_setup
Setup.
subroutine, public ocean_driver
Ocean step.
subroutine, public ocean_vars_restart_read
Read ocean restart.
module LAND Variables
module administrator for restart
subroutine, public urban_vars_setup
Setup.
subroutine, public urban_driver_setup
Setup.
module CONSTANT
Definition: scale_const.F90:14
module EXTERNAL INPUT
subroutine, public gtrans_setup
Setup.
subroutine, public ocean_admin_setup
Setup.
module GRID (cartesian)
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:156
subroutine, public fileio_cleanup
deallocate buffers
module RM PROCESS
subroutine, public hist_setup
Setup.
subroutine, public admin_restart_write
Write data to restart files.
subroutine, public land_grid_index_setup
Setup.
module profiler
Definition: scale_prof.F90:10
subroutine, public monit_write(memo)
Flush monitor buffer to formatted file.
logical, public atmos_restart_check
Check value consistency?
module Surface bulk flux
subroutine, public atmos_hydrometeor_setup
Setup.
module ATMOSPHERE / Thermodynamics
subroutine, public user_resume
Resuming operation.
Definition: mod_user.f90:133
subroutine, public admin_time_advance
Advance the time & evaluate restart & stop.
subroutine, public atmos_driver_finalize
Finalize.
subroutine, public cpl_admin_setup
Setup.
subroutine, public user_config
Config before setup of other components.
Definition: mod_user.f90:56
subroutine, public atmos_vars_history_setpres
Set pressure for history output.
logical, public time_doatmos_step
execute atmosphere component in this step?
module PRECISION
subroutine resume_state
subroutine, public monit_setup
Setup.
subroutine, public atmos_admin_setup
Setup.
subroutine, public ocean_vars_setup
Setup.
module HISTORY
module TOPOGRAPHY
module ADMIN TIME
module CALENDAR
subroutine, public atmos_driver
advance atmospheric state
module land grid index
subroutine, public prc_local_setup(comm, myrank, ismaster)
Setup MPI.
module Surface roughness length
integer, public io_fid_conf
Config file ID.
Definition: scale_stdio.F90:55
subroutine, public comm_setup
Setup.
Definition: scale_comm.F90:165
subroutine, public urban_admin_setup
Setup.
subroutine, public user_setup
Setup before setup of other components.
Definition: mod_user.f90:85
subroutine, public user_resume0
Resuming operation, before calculating tendency.
Definition: mod_user.f90:118
subroutine, public bulkflux_setup(dx)
module RANDOM
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
module Coupler admin
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:204
subroutine, public atmos_vars_restart_check
Check and compare between last data and sample data.
module Urban admin
logical, public urban_do
subroutine, public atmos_driver_resume2
Setup.
module LAND driver
logical, public time_doland_step
execute land component in this step?
subroutine, public land_surface_set(countup)
Put surface boundary to other model.
module OCEAN Variables
integer, public io_fid_nml
Log file ID (only for output namelist)
Definition: scale_stdio.F90:57
logical, public land_do
subroutine, public atmos_hydrostatic_setup
Setup.
subroutine, public atmos_vars_restart_read
Read restart of atmospheric variables.
subroutine, public admin_restart_read
Read from restart files.
module INTERPOLATION
subroutine, public atmos_vars_diagnostics
Calc diagnostic variables.
subroutine, public grid_setup
Setup.
subroutine, public admin_time_checkstate
Evaluate component execution.
subroutine, public prof_rapreport
Report raptime.
Definition: scale_prof.F90:246
module urban grid index
subroutine, public land_driver
Land step.
subroutine, public loginit(fid_conf, fid_log, master, fid_nml, master_nml)
Definition: dc_log.f90:75