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: &
130  use mod_admin_time, only: &
142  time_doresume, &
143  time_doend
144  use mod_atmos_admin, only: &
146  atmos_do
147  use mod_atmos_vars, only: &
149  atmos_sw_restart => atmos_restart_output, &
151  atmos_sw_check => atmos_restart_check, &
153  use mod_atmos_driver, only: &
155  atmos_driver, &
157  use mod_ocean_admin, only: &
159  ocean_do
160  use mod_ocean_vars, only: &
162  ocean_sw_restart => ocean_restart_output, &
164  use mod_ocean_driver, only: &
167  use mod_land_admin, only: &
169  land_do
170  use mod_land_vars, only: &
171  land_vars_setup, &
172  land_sw_restart => land_restart_output, &
174  use mod_land_driver, only: &
177  use mod_urban_admin, only: &
179  urban_do
180  use mod_urban_vars, only: &
182  urban_sw_restart => urban_restart_output, &
184  use mod_urban_driver, only: &
187  use mod_cpl_admin, only: &
189  use mod_cpl_vars, only: &
191  use mod_user, only: &
192  user_setup, &
193  user_step
194  implicit none
195 
196  integer, intent(in) :: comm_world
197  integer, intent(in) :: intercomm_parent
198  integer, intent(in) :: intercomm_child
199  character(len=H_LONG), intent(in) :: cnf_fname
200 
201  integer :: myrank
202  logical :: ismaster
203  !---------------------------------------------------------------------------
204 
205  !########## Initial setup ##########
206 
207  ! setup standard I/O
208  call io_setup( modelname, .true., cnf_fname )
209 
210  ! setup MPI
211  call prc_local_setup( comm_world, & ! [IN]
212  myrank, & ! [OUT]
213  ismaster ) ! [OUT]
214 
215  ! setup Log
216  call io_log_setup( myrank, ismaster )
218 
219  ! setup process
220  call prc_setup
221 
222  ! setup PROF
223  call prof_setup
224 
225 
226  ! profiler start
227  call prof_setprefx('INIT')
228  call prof_rapstart('Initialize', 0)
229 
230 
231  ! setup constants
232  call const_setup
233 
234  ! setup calendar
235  call calendar_setup
236 
237  ! setup random number
238  call random_setup
239 
240  ! setup horizontal/vertical grid coordinates (cartesian,idealized)
241  call grid_index_setup
242  call grid_setup
243 
245  call land_grid_setup
246 
248  call urban_grid_setup
249 
250  ! setup tracer index
251  call tracer_setup
252 
253  ! setup file I/O
254  call fileio_setup
255 
256  ! setup mpi communication
257  call comm_setup
258 
259  ! setup topography
260  call topo_setup
261  ! setup land use category index/fraction
262  call landuse_setup
263  ! setup grid coordinates (real world)
264  call real_setup
265 
266  ! setup grid transfer metrics (uses in ATMOS_dynamics)
267  call gtrans_setup
268  ! setup Z-ZS interpolation factor (uses in History)
269  call interp_setup
270 
271  ! setup restart
273  ! setup time
274  call admin_time_setup( setup_timeintegration = .true. )
275  ! setup statistics
276  call stat_setup
277  ! setup history I/O
278  call hist_setup
279  ! setup monitor I/O
280  call monit_setup
281  ! setup external in
282  call extin_setup
283 
284  ! setup nesting grid
285  call nest_setup ( intercomm_parent, intercomm_child )
286 
287  ! setup common tools
291 
292  call bulkflux_setup
293  call roughness_setup
294 
295  ! setup submodel administrator
296  call atmos_admin_setup
297  call ocean_admin_setup
298  call land_admin_setup
299  call urban_admin_setup
300  call cpl_admin_setup
301 
302  ! setup variable container
303  call atmos_vars_setup
304  call ocean_vars_setup
305  call land_vars_setup
306  call urban_vars_setup
307  call cpl_vars_setup
308 
309  ! setup submodel driver
310  call atmos_driver_setup
311  call ocean_driver_setup
312  call land_driver_setup
313  call urban_driver_setup
314 
315  call user_setup
316 
317  call prof_rapend('Initialize', 0)
318 
319  !########## main ##########
320 
321 #ifdef _FIPP_
322  call fipp_start
323 #endif
324 #ifdef _PAPI_
325  call prof_papi_rapstart
326 #endif
327 
328  if( io_l ) write(io_fid_log,*)
329  if( io_l ) write(io_fid_log,*) '++++++ START TIMESTEP ++++++'
330  call prof_setprefx('MAIN')
331  call prof_rapstart('Main_Loop', 0)
332 
333  do
334 
335  ! report current time
337 
338  if ( time_doresume ) then
339  ! resume state from restart files
340  call resume_state
341 
342  ! history&monitor file output
343  call hist_write ! if needed
344  call monit_write('MAIN')
345  end if
346 
347 
348  ! time advance
349  call admin_time_advance
350 
351  ! user-defined procedure
352  call user_step
353 
354  ! change to next state
355  if( ocean_do .AND. time_doocean_step ) call ocean_driver
356  if( land_do .AND. time_doland_step ) call land_driver
357  if( urban_do .AND. time_dourban_step ) call urban_driver
358  if( atmos_do .AND. time_doatmos_step ) call atmos_driver
359 
360  ! history&monitor file output
361  call hist_write
362  call monit_write('MAIN')
363 
364  ! restart output
365  ! if( OCEAN_sw_restart .AND. TIME_DOOCEAN_restart ) call OCEAN_vars_restart_write
366  ! if( LAND_sw_restart .AND. TIME_DOLAND_restart ) call LAND_vars_restart_write
367  ! if( URBAN_sw_restart .AND. TIME_DOURBAN_restart ) call URBAN_vars_restart_write
368  ! if( ATMOS_sw_restart .AND. TIME_DOATMOS_restart ) call ATMOS_vars_restart_write
369  call admin_restart
370 
371  if( time_doend ) exit
372 
373  if( io_l ) call flush(io_fid_log)
374 
375  enddo
376 
377  call prof_rapend('Main_Loop', 0)
378 
379  if( io_l ) write(io_fid_log,*) '++++++ END TIMESTEP ++++++'
380  if( io_l ) write(io_fid_log,*)
381 
382 
383  call prof_setprefx('FIN')
384 
385  call prof_rapstart('All', 1)
386 
388 
389 #ifdef _FIPP_
390  call fipp_stop
391 #endif
392 #ifdef _PAPI_
393  call prof_papi_rapstop
394 #endif
395 
396  !########## Finalize ##########
397 
398  ! check data
399  if( atmos_sw_check ) call atmos_vars_restart_check
400 
401  call prof_rapstart('Monit', 2)
402  call monit_finalize
403  call prof_rapend ('Monit', 2)
404 
405  call comm_cleanup
406 
407  call prof_rapstart('File', 2)
408  call filecloseall
409  call prof_rapend ('File', 2)
410 
411  call prof_rapend ('All', 1)
412 
413  call prof_rapreport
414 #ifdef _PAPI_
415  call prof_papi_rapreport
416 #endif
417 
418  return
419  end subroutine scalerm
420 
421 
422  subroutine resume_state
423  use mod_atmos_driver, only: &
427  use mod_ocean_driver, only: &
430  use mod_land_driver, only: &
433  use mod_urban_driver, only: &
436  use mod_atmos_vars, only: &
439  use mod_ocean_vars, only: &
441  use mod_land_vars, only: &
443  use mod_urban_vars, only: &
445  use mod_user, only: &
446  user_resume0, &
448  use mod_atmos_admin, only: &
449  atmos_do
450  use mod_ocean_admin, only: &
451  ocean_do
452  use mod_land_admin, only: &
453  land_do
454  use mod_urban_admin, only: &
455  urban_do
456  implicit none
457 
458  ! read restart data
463 
464  ! setup user-defined procedure before setup of other components
465  call user_resume0
466 
467  ! calc diagnostics
469 
470  ! setup surface condition
471  if( atmos_do ) call atmos_surface_set( countup=.false. )
472  if( ocean_do ) call ocean_surface_set( countup=.false. )
473  if( land_do ) call land_surface_set ( countup=.false. )
474  if( urban_do ) call urban_surface_set( countup=.false. )
475 
476  ! setup submodel driver
477  if( atmos_do ) call atmos_driver_resume1
478  if( ocean_do ) call ocean_driver_resume
479  if( land_do ) call land_driver_resume
480  if( urban_do ) call urban_driver_resume
481  if( atmos_do ) call atmos_driver_resume2
482 
483  ! setup user-defined procedure
484  call user_resume
485 
486  return
487  end subroutine resume_state
488 
489 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:84
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 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 admin_restart
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.