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: &
78  use scale_grid_nest, only: &
80  use scale_land_grid_index, only: &
82  use scale_land_grid, only: &
84  use scale_urban_grid_index, only: &
86  use scale_urban_grid, only: &
88  use scale_tracer, only: &
90  use scale_fileio, only: &
92  use scale_comm, only: &
93  comm_setup , &
95  use scale_topography, only: &
97  use scale_landuse, only: &
99  use scale_grid_real, only: &
100  real_setup
101  use scale_gridtrans, only: &
103  use scale_interpolation, only: &
105  use scale_rm_statistics, only: &
106  stat_setup
107  use scale_history, only: &
108  hist_setup, &
109  hist_write
110  use scale_monitor, only: &
111  monit_setup, &
112  monit_write, &
114  use scale_external_input, only: &
116  use scale_atmos_hydrostatic, only: &
118  use scale_atmos_thermodyn, only: &
120  use scale_atmos_saturation, only: &
122  use scale_bulkflux, only: &
124  use scale_roughness, only: &
126 
127  use mod_admin_restart, only: &
129  use mod_admin_time, only: &
141  time_doresume, &
142  time_doend
143  use mod_atmos_admin, only: &
145  atmos_do
146  use mod_atmos_vars, only: &
148  atmos_sw_restart => atmos_restart_output, &
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  ocean_sw_restart => ocean_restart_output, &
163  use mod_ocean_driver, only: &
166  use mod_land_admin, only: &
168  land_do
169  use mod_land_vars, only: &
170  land_vars_setup, &
171  land_sw_restart => land_restart_output, &
173  use mod_land_driver, only: &
176  use mod_urban_admin, only: &
178  urban_do
179  use mod_urban_vars, only: &
181  urban_sw_restart => urban_restart_output, &
183  use mod_urban_driver, only: &
186  use mod_cpl_admin, only: &
188  use mod_cpl_vars, only: &
190  use mod_user, only: &
191  user_setup, &
192  user_step
193  implicit none
194 
195  integer, intent(in) :: comm_world
196  integer, intent(in) :: intercomm_parent
197  integer, intent(in) :: intercomm_child
198  character(len=H_LONG), intent(in) :: cnf_fname
199 
200  integer :: myrank
201  logical :: ismaster
202  !---------------------------------------------------------------------------
203 
204  !########## Initial setup ##########
205 
206  ! setup standard I/O
207  call io_setup( modelname, .true., cnf_fname )
208 
209  ! setup MPI
210  call prc_local_setup( comm_world, & ! [IN]
211  myrank, & ! [OUT]
212  ismaster ) ! [OUT]
213 
214  ! setup Log
215  call io_log_setup( myrank, ismaster )
217 
218  ! setup process
219  call prc_setup
220 
221  ! setup PROF
222  call prof_setup
223 
224 
225  ! profiler start
226  call prof_setprefx('INIT')
227  call prof_rapstart('Initialize', 0)
228 
229 
230  ! setup constants
231  call const_setup
232 
233  ! setup calendar
234  call calendar_setup
235 
236  ! setup random number
237  call random_setup
238 
239  ! setup horizontal/vertical grid coordinates (cartesian,idealized)
240  call grid_index_setup
241  call grid_setup
242 
244  call land_grid_setup
245 
247  call urban_grid_setup
248 
249  ! setup tracer index
250  call tracer_setup
251 
252  ! setup file I/O
253  call fileio_setup
254 
255  ! setup mpi communication
256  call comm_setup
257 
258  ! setup topography
259  call topo_setup
260  ! setup land use category index/fraction
261  call landuse_setup
262  ! setup grid coordinates (real world)
263  call real_setup
264 
265  ! setup grid transfer metrics (uses in ATMOS_dynamics)
266  call gtrans_setup
267  ! setup Z-ZS interpolation factor (uses in History)
268  call interp_setup
269 
270  ! setup restart
272  ! setup time
273  call admin_time_setup( setup_timeintegration = .true. )
274  ! setup statistics
275  call stat_setup
276  ! setup history I/O
277  call hist_setup
278  ! setup monitor I/O
279  call monit_setup
280  ! setup external in
281  call extin_setup
282 
283  ! setup nesting grid
284  call nest_setup ( intercomm_parent, intercomm_child )
285 
286  ! setup common tools
290 
291  call bulkflux_setup
292  call roughness_setup
293 
294  ! setup submodel administrator
295  call atmos_admin_setup
296  call ocean_admin_setup
297  call land_admin_setup
298  call urban_admin_setup
299  call cpl_admin_setup
300 
301  ! setup variable container
302  call atmos_vars_setup
303  call ocean_vars_setup
304  call land_vars_setup
305  call urban_vars_setup
306  call cpl_vars_setup
307 
308  ! setup submodel driver
309  call atmos_driver_setup
310  call ocean_driver_setup
311  call land_driver_setup
312  call urban_driver_setup
313 
314  call user_setup
315 
316  call prof_rapend('Initialize', 0)
317 
318  !########## main ##########
319 
320 #ifdef _FIPP_
321  call fipp_start
322 #endif
323 #ifdef _PAPI_
324  call prof_papi_rapstart
325 #endif
326 
327  if( io_l ) write(io_fid_log,*)
328  if( io_l ) write(io_fid_log,*) '++++++ START TIMESTEP ++++++'
329  call prof_setprefx('MAIN')
330  call prof_rapstart('Main_Loop', 0)
331 
332  do
333 
334  ! report current time
336 
337  if ( time_doresume ) then
338  ! resume state from restart files
339  call resume_state
340 
341  ! history&monitor file output
342  call hist_write ! if needed
343  call monit_write('MAIN')
344  end if
345 
346 
347  ! time advance
348  call admin_time_advance
349 
350  ! user-defined procedure
351  call user_step
352 
353  ! change to next state
354  if( ocean_do .AND. time_doocean_step ) call ocean_driver
355  if( land_do .AND. time_doland_step ) call land_driver
356  if( urban_do .AND. time_dourban_step ) call urban_driver
357  if( atmos_do .AND. time_doatmos_step ) call atmos_driver
358 
359  ! history&monitor file output
360  call hist_write
361  call monit_write('MAIN')
362 
363  ! restart output
364  if( ocean_sw_restart .AND. time_doocean_restart ) call ocean_vars_restart_write
365  if( land_sw_restart .AND. time_doland_restart ) call land_vars_restart_write
366  if( urban_sw_restart .AND. time_dourban_restart ) call urban_vars_restart_write
367  if( atmos_sw_restart .AND. time_doatmos_restart ) call atmos_vars_restart_write
368 
369  if( time_doend ) exit
370 
371  if( io_l ) call flush(io_fid_log)
372 
373  enddo
374 
375  call prof_rapend('Main_Loop', 0)
376 
377  if( io_l ) write(io_fid_log,*) '++++++ END TIMESTEP ++++++'
378  if( io_l ) write(io_fid_log,*)
379 
380 
381  call prof_setprefx('FIN')
382 
383  call prof_rapstart('All', 1)
384 
386 
387 #ifdef _FIPP_
388  call fipp_stop
389 #endif
390 #ifdef _PAPI_
391  call prof_papi_rapstop
392 #endif
393 
394  !########## Finalize ##########
395 
396  ! check data
397  if( atmos_sw_check ) call atmos_vars_restart_check
398 
399  call prof_rapstart('Monit', 2)
400  call monit_finalize
401  call prof_rapend ('Monit', 2)
402 
403  call comm_cleanup
404 
405  call prof_rapstart('File', 2)
406  call filecloseall
407  call prof_rapend ('File', 2)
408 
409  call prof_rapend ('All', 1)
410 
411  call prof_rapreport
412 #ifdef _PAPI_
413  call prof_papi_rapreport
414 #endif
415 
416  return
417  end subroutine scalerm
418 
419 
420  subroutine resume_state
421  use mod_atmos_driver, only: &
425  use mod_ocean_driver, only: &
428  use mod_land_driver, only: &
431  use mod_urban_driver, only: &
434  use mod_atmos_vars, only: &
438  use mod_ocean_vars, only: &
440  use mod_land_vars, only: &
442  use mod_urban_vars, only: &
444  use mod_user, only: &
445  user_resume0, &
447  use mod_atmos_admin, only: &
448  atmos_do
449  use mod_ocean_admin, only: &
450  ocean_do
451  use mod_land_admin, only: &
452  land_do
453  use mod_urban_admin, only: &
454  urban_do
455  implicit none
456 
457  ! read restart data
462 
463  ! setup user-defined procedure before setup of other components
464  call user_resume0
465 
466  ! calc diagnostics
468 
469  ! first monitor
470  if( atmos_do ) call atmos_vars_monitor
471 
472  ! setup surface condition
473  if( atmos_do ) call atmos_surface_set( countup=.false. )
474  if( ocean_do ) call ocean_surface_set( countup=.false. )
475  if( land_do ) call land_surface_set ( countup=.false. )
476  if( urban_do ) call urban_surface_set( countup=.false. )
477 
478  ! setup submodel driver
479  if( atmos_do ) call atmos_driver_resume1
480  if( ocean_do ) call ocean_driver_resume
481  if( land_do ) call land_driver_resume
482  if( urban_do ) call urban_driver_resume
483  if( atmos_do ) call atmos_driver_resume2
484 
485  ! setup user-defined procedure
486  call user_resume
487 
488  return
489  end subroutine resume_state
490 
491 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:79
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:114
logical, public land_restart_output
output restart file?
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:106
module URBAN driver
logical, public io_l
output log or not? (this process)
Definition: scale_stdio.F90:59
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 ocean_vars_restart_write
Write ocean restart.
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.
subroutine, public atmos_vars_restart_write
Write restart of atmospheric variables.
module STDIO
Definition: scale_stdio.F90:12
logical, public time_doatmos_restart
execute atmosphere restart output in this step?
logical, public time_doocean_restart
execute ocean restart output in this step?
subroutine, public grid_index_setup
Setup.
module GRID (cartesian) for land
subroutine, public filecloseall
module URBAN Variables
subroutine, public io_log_setup(myrank, is_master)
Setup LOG.
subroutine, public loginit(fid_conf, fid_log, master)
Definition: dc_log.f90:66
module FILE I/O (netcdf)
subroutine, public land_admin_setup
Setup.
module Statistics
logical, public atmos_restart_output
output restart file?
subroutine, public urban_surface_set(countup)
Set surface boundary to other model.
subroutine, public urban_vars_restart_write
Write urban restart.
subroutine, public land_vars_restart_read
Read land restart.
module SCALE-RM (a main routine of regional model)
module grid index
subroutine, public bulkflux_setup
module TRACER
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 tracer_setup
Setup.
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:85
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.
logical, public time_dourban_restart
execute urban restart output in this step?
logical, public urban_restart_output
output restart file?
module GRID (cartesian)
subroutine, public prof_rapstart(rapname_base, level)
Start raptime.
Definition: scale_prof.F90:132
module RM PROCESS
subroutine, public atmos_vars_monitor
monitor output
subroutine, public hist_setup
Setup.
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
module ATMOSPHERE / Thermodynamics
subroutine, public user_resume
Resuming operation.
Definition: mod_user.f90:97
subroutine, public admin_time_advance
Advance the time & evaluate restart & stop.
subroutine, public atmos_driver_finalize
Finalize.
subroutine, public cpl_admin_setup
Setup.
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
logical, public time_doland_restart
execute land restart output in this step?
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:55
subroutine, public user_resume0
Resuming operation, before calculating tendency.
Definition: mod_user.f90:88
module RANDOM
logical, public ocean_restart_output
output restart file?
integer, public io_fid_log
Log file ID.
Definition: scale_stdio.F90:56
subroutine, public land_vars_restart_write
Write land restart.
module Coupler admin
subroutine, public prof_rapend(rapname_base, level)
Save raptime.
Definition: scale_prof.F90:178
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
logical, public land_do
subroutine, public atmos_hydrostatic_setup
Setup.
subroutine, public atmos_vars_restart_read
Read restart of atmospheric variables.
subroutine, public extin_setup
Setup.
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:220
module urban grid index
subroutine, public land_driver
Land step.