FE-Project
Loading...
Searching...
No Matches
mod_dg_driver.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module SCALE-DG (a main routine of regional/global model)
3!!
4!! @par Description
5!! SCALE: Scalable Computing by Advanced Library and Environment
6!! SCALE-DG: Regional / global model with atmospheric dynamical core based on DGM
7!!
8!! @author Yuta Kawai, Team SCALE
9!!
10!<
11!-------------------------------------------------------------------------------
12#include "scaleFElib.h"
14 !-----------------------------------------------------------------------------
15 !
16 !++ used modules
17 !
18 use scale_precision
19 use scale_io
20 use scale_prof
21 use scale_prc
22
25 use scale_file_history, only: &
26 file_history_set_nowdate
28 file_monitor_meshfield_write
29
30 use mod_atmos_component, only: &
32 use mod_ocean_component, only: &
34 use mod_cpl_component, only: &
36 use mod_user, only: &
37 user
38
39 !-----------------------------------------------------------------------------
40 implicit none
41 private
42 !-----------------------------------------------------------------------------
43 !
44 !++ included parameters
45 !
46#include "scale-dg.h"
47
48 !-----------------------------------------------------------------------------
49 !
50 !++ Public procedure
51 !
52 public :: dg_driver
53 !-----------------------------------------------------------------------------
54 !
55 !++ Public parameters & variables
56 !
57 !-----------------------------------------------------------------------------
58 !
59 !++ Private procedure
60 !
61 !-----------------------------------------------------------------------------
62 !
63 !++ Private parameters & variables
64 !
65 character(len=H_MID), private, parameter :: MODELNAME = "SCALE-DG ver. "//version
66
67 type(AtmosComponent) :: atmos
68 type(OceanComponent) :: ocean
69 type(CouplerComponent) :: coupler
70 type(User) :: user_
71
72contains
73!OCL SERIAL
74 subroutine dg_driver( &
75 comm_world, cnf_fname, &
76 path, add_path )
77
78 use scale_time_manager, only: &
80 time_nowdate, time_nowsubsec, time_nowstep, time_nstep, &
82
83 implicit none
84
85 integer, intent(in) :: comm_world
86 character(len=*), intent(in) :: cnf_fname
87 character(len=*), intent(in) :: path
88 logical, intent(in) :: add_path
89
90 integer :: myrank
91 integer :: fpm_counter
92 logical :: ismaster
93 logical :: sign_exit
94 !---------------------------------------------------------------------------
95
96 !########## Initial setup ##########
97
98 ! setup standard I/O
99 if ( add_path .and. path /= "" ) then
100 call io_setup( modelname, trim(path)//cnf_fname, prefix=path )
101 else
102 call io_setup( modelname, trim(path)//cnf_fname )
103 end if
104
105 ! setup MPI
106 call prc_local_setup( comm_world, & ! [IN]
107 myrank, & ! [OUT]
108 ismaster ) ! [OUT]
109
110 ! setup Log
111 call io_log_setup( myrank, ismaster )
112
113 call initialize
114
115 !###########################################################################
116
117 !########## main ##########
118
119#ifdef FIPP
120 call fipp_start
121#endif
122
123 log_newline
124 log_progress(*) 'START TIMESTEP'
125 call prof_setprefx('MAIN')
126 call prof_rapstart('Main_Loop', 0)
127
128 do
129
130 !*******************************************
131
132 ! report current time
134
135 if (time_doresume) then
136 ! set state from restart file
137 call restart_read
138 ! history & monitor file output
139 call file_monitor_meshfield_write('MAIN', time_nowstep)
141 end if
142
143 !* Advance time *********************************
144
146 call file_history_set_nowdate( time_nowdate, time_nowsubsec, time_nowstep )
147
148 !* change to next state *************************
149
150 !- USER
151 call user_%update_pre( atmos )
152
153 if ( ocean%IsActivated() .and. ocean%time_manager%do_step ) call ocean%update()
154 if ( atmos%IsActivated() .and. atmos%time_manager%do_step ) call atmos%update()
155 call user_%update( atmos )
156
157 !* restart and monitor output *******************
158 if ( atmos%IsActivated() ) call atmos%vars%Monitor()
159 call restart_write
160 call file_monitor_meshfield_write('MAIN', time_nowstep)
161
162
163 !* calc tendencies and diagnostics *************
164
165 if ( atmos %IsActivated() .and. atmos%time_manager%do_step ) call atmos%calc_tendency( force=.false. )
166 if ( ocean %IsActivated() .and. ocean%time_manager%do_step ) call ocean%calc_tendency( force=.false. )
167 if ( coupler%IsActivated() .and. atmos%time_manager%do_step ) call atmos%calc_tendency_from_sflux(force=.false.)
168 call user_%calc_tendency( atmos )
169
170 !* output history files *************************
171
172 if ( atmos%IsActivated() ) call atmos%vars%History()
173 if ( atmos%dyn_proc%IsActivated() ) call atmos%dyn_proc%dyn_vars%History()
174 if ( atmos%phy_tb_proc%IsActivated() ) call atmos%phy_tb_proc%vars%History()
175 if ( atmos%phy_mp_proc%IsActivated() ) call atmos%phy_mp_proc%vars%History()
176 if ( atmos%phy_sfc_proc%IsActivated() ) call atmos%phy_sfc_proc%vars%History()
177 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%History()
178 if ( atmos%phy_bl_proc%IsActivated() ) call atmos%phy_bl_proc%vars%History()
179 if ( atmos%phy_cp_proc%IsActivated() ) call atmos%phy_cp_proc%vars%History()
180
181 if ( ocean%IsActivated() ) call ocean%vars%History()
182
184
185 !*******************************************
186 if (time_doend) exit
187
188 if( io_l ) call flush(io_fid_log)
189 end do
190
191 call prof_rapend('Main_Loop', 0)
192
193 log_progress(*) 'END TIMESTEP'
194 log_newline
195
196#ifdef FIPP
197 call fipp_stop
198#endif
199
200 !########## Finalize ##########
201 call finalize
202
203 return
204 end subroutine dg_driver
205
206 !----------------------------
207
208!OCL SERIAL
209 subroutine initialize()
210
211 use scale_const, only: const_setup
212 use scale_calendar, only: calendar_setup
213 use scale_random, only: random_setup
214 use scale_atmos_hydrometeor, only: atmos_hydrometeor_setup
215 use scale_time_manager, only: time_dtsec
216
217 use scale_time_manager, only: &
220 use scale_meshfield_statistics, only: &
223 restart_file, &
226 file_monitor_meshfield_setup
227 implicit none
228
229 !----------------------------------------------
230
231 ! namelist compatibility check
232 !call ADMIN_versioncheck
233
234 ! setup PROF
235 call prof_setup
236
237 call prof_setprefx('INIT')
238 call prof_rapstart('Initialize', 0)
239
240 ! setup constants
241 call const_setup
242
243 ! setup calendar & initial time
244 call calendar_setup
245
246 ! setup random number
247 call random_setup
248
249 ! setup tracer index
250 call atmos_hydrometeor_setup
251
252 ! setup a module for restart file
254 call time_manager_init( &
255 setup_timeintegration = .true., &
256 restart_in_basename = restart_file%in_basename )
257
258 ! setup statistics
260
261 ! setup monitor
262 call file_monitor_meshfield_setup( time_dtsec )
263
264 ! setup sub-models
265 call atmos%setup()
266 call ocean%setup()
267 call coupler%setup()
268 call user_%setup( atmos )
269
270 call coupler%evaluate_activation( ocean )
271 call atmos%set_coupler( coupler )
272 call ocean%set_coupler( coupler )
273
274 call atmos%setup_vars()
275
276 if ( ocean%IsActivated() ) call ocean%setup_vars()
277 if ( coupler%IsActivated() ) call coupler%setup_vars( atmos%mesh%ptr_mesh, ocean%mesh%ptr_mesh )
278
279 ! report information of time intervals
281
282 !----------------------------------------
283
284 call prof_rapend('Initialize', 0)
285
286 return
287 end subroutine initialize
288
289!OCL SERIAL
290 subroutine finalize()
291 use scale_file, only: &
292 file_close_all
298 file_monitor_meshfield_final
299 use scale_time_manager, only: &
301 implicit none
302
303 !----------------------------------------------
304 call prof_setprefx('FIN')
305 call prof_rapstart('All', 1)
306
307 call prof_rapstart('Monit', 2)
308 call file_monitor_meshfield_final
309 call prof_rapend ('Monit', 2)
310
311 !-
312 call prof_rapstart('File', 2)
315 call prof_rapend ('File', 2)
316
317 ! finalization sub-models
318 call atmos%finalize()
319 call ocean%finalize()
320 call coupler%finalize()
321 call user_%final()
322
323 !-
325
326 call prof_rapend ('All', 1)
327 call prof_rapreport
328
329 return
330 end subroutine finalize
331
332!OCL SERIAL
333 subroutine restart_read()
334 implicit none
335 !----------------------------------------
336
337 !- read restart data
338
339 if ( atmos%isActivated() ) then
340 call atmos%vars%Read_restart_file( atmos%mesh, atmos%dyn_proc%dyncore_driver )
341 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Read_restart_file()
342 end if
343 if ( ocean%isActivated() ) then
344 call ocean%vars%Read_restart_file( ocean%mesh )
345 end if
346
347 !- Setup surface condition
348
349 if ( atmos%isActivated() ) call atmos%set_surface( countup=.false. )
350 if ( ocean%isActivated() ) call ocean%set_surface( countup=.false. )
351
352 !- Calculate the tendencies
353
354 if ( atmos%IsActivated() ) call atmos%calc_tendency( force= .true. )
355 if ( ocean%IsActivated() ) call ocean%calc_tendency( force= .true. )
356 if ( coupler%IsActivated() ) call atmos%calc_tendency_from_sflux(force=.true.)
357
358 call user_%calc_tendency( atmos )
359
360 !- History & Monitor
361
362 if ( atmos%isActivated() ) then
363 call atmos%vars%History()
364 if ( atmos%phy_sfc_proc%IsActivated() ) call atmos%phy_sfc_proc%vars%History()
365 if ( atmos%phy_tb_proc%IsActivated() ) call atmos%phy_tb_proc%vars%History()
366 if ( atmos%phy_mp_proc%IsActivated() ) call atmos%phy_mp_proc%vars%History()
367 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%History()
368 if ( atmos%phy_bl_proc%IsActivated() ) call atmos%phy_bl_proc%vars%History()
369 if ( atmos%phy_cp_proc%IsActivated() ) call atmos%phy_cp_proc%vars%History()
370 call atmos%vars%Monitor()
371 end if
372
373 if ( ocean%isActivated() ) then
374 call ocean%vars%History()
375 end if
376
377 return
378 end subroutine restart_read
379
380!OCL SERIAL
381 subroutine restart_write()
384 implicit none
385
386 logical :: is_restart_write_atmos
387 logical :: is_restart_write_ocean
388 !----------------------------------------
389
390 if ( .not. restart_file%flag_output ) return
391
392 is_restart_write_atmos = atmos%isActivated() .and. atmos%time_manager%do_restart
393 is_restart_write_ocean = ocean%isActivated() .and. ocean%time_manager%do_restart
394
395 !- Preprocess
396 if ( is_restart_write_atmos ) then
397 call atmos%vars%Write_restart_file_prep()
398 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Write_restart_file_prep()
399 end if
400 if ( is_restart_write_ocean ) then
401 call ocean%vars%Write_restart_file_prep()
402 end if
403
404 !- Write
405 if ( is_restart_write_atmos ) then
406 call atmos%vars%Write_restart_file()
407 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Write_restart_file()
408 end if
409 if ( is_restart_write_ocean ) then
410 call ocean%vars%Write_restart_file()
411 end if
412
413 !- Postprocess
414 if ( is_restart_write_atmos ) then
415 call atmos%vars%Write_restart_file_post()
416 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Write_restart_file_post()
417 end if
418 if ( is_restart_write_ocean ) call ocean%vars%Write_restart_file_post()
419
420 return
421 end subroutine restart_write
422
423
424end module mod_dg_driver
module Atmosphere component
module Coupler component
module SCALE-DG (a main routine of regional/global model)
subroutine, public dg_driver(comm_world, cnf_fname, path, add_path)
module Oceanic component
module USER
Definition mod_user.F90:12
subroutine, public file_history_meshfield_write()
Write history data to the file.
subroutine, public file_history_meshfield_finalize()
Finalize the file history module.
subroutine, public file_restart_meshfield_finalize()
Finalize the main restart file.
subroutine, public file_restart_meshfield_setup()
Setup the main restart file.
type(file_restart_meshfield), public restart_file
An object to manage main restart file.
module FElib / Data / Statistics
subroutine, public meshfield_statistics_setup()
Setup.
Module common / time.
subroutine, public time_manager_advance()
subroutine, public time_manager_report_timeintervals()
subroutine, public time_manager_checkstate()
subroutine, public time_manager_final()
logical, public time_doresume
subroutine, public time_manager_init(setup_timeintegration, restart_in_basename)
Derived type to manage atmospheric component.
Derived type to manage coupler component.
Derived type to manage oceanic component.