FE-Project
Loading...
Searching...
No Matches
mod_dg_prep.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module SCALE-DG prep
3!!
4!! @par Description
5!! This program is driver of preprocess tools
6!! 1) boundary data (e.g. topography, land use index)
7!! 2) initial data for ideal/real test cases
8!!
9!! @author Team SCALE
10!!
11!<
12!-------------------------------------------------------------------------------
13#include "scaleFElib.h"
15 !-----------------------------------------------------------------------------
16 !
17 !++ used modules
18 !
19 use scale_precision
20 use scale_io
21 use scale_prof
22 use scale_prc
23
24 use mod_atmos_component, only: &
26 use mod_ocean_component, only: &
28 use mod_cpl_component, only: &
30
33 use scale_file_history, only: &
34 file_history_set_nowdate
35
36 use mod_user, only: &
37 user
38 use mod_mktopo, only: &
40 use mod_mkinit, only: &
41 mkinit
42
43 !-----------------------------------------------------------------------------
44 implicit none
45 private
46 !-----------------------------------------------------------------------------
47 !
48 !++ included parameters
49 !
50#include "scale-dg.h"
51
52 !-----------------------------------------------------------------------------
53 !
54 !++ Public procedure
55 !
56 public :: dg_prep
57 !-----------------------------------------------------------------------------
58 !
59 !++ Public parameters & variables
60 !
61 !-----------------------------------------------------------------------------
62 !
63 !++ Private procedure
64 !
65 !-----------------------------------------------------------------------------
66 !
67 !++ Private parameters & variables
68 !
69 character(len=H_MID), private, parameter :: MODELNAME = "SCALE-DG ver. "//version
70
71 type(AtmosComponent) :: atmos
72 type(OceanComponent) :: ocean
73 type(CouplerComponent) :: coupler
74 type(User) :: user_
75
76contains
77 subroutine dg_prep( &
78 comm_world, cnf_fname, path, add_path )
79
80 use scale_time_manager, only: &
82 time_nowdate, time_nowsubsec, time_nowstep, time_nstep, &
84
85 implicit none
86
87 integer, intent(in) :: comm_world
88 character(len=*), intent(in) :: cnf_fname
89 character(len=*), intent(in) :: path
90 logical, intent(in) :: add_path
91
92
93 integer :: myrank
94 logical :: ismaster
95
96 logical :: output
97 logical :: output_topo
98 !---------------------------------------------------------------------------
99
100 !########## Initial setup ##########
101
102#ifdef SCALE_DEVELOP
103 ! setup standard I/O
104 if ( add_path .and. path /= "" ) then
105 call io_setup( modelname, trim(path)//cnf_fname, prefix=path )
106 else
107#endif
108 call io_setup( modelname, trim(path)//cnf_fname )
109#ifdef SCALE_DEVELOP
110 end if
111#endif
112
113 ! setup MPI
114 call prc_local_setup( comm_world, & ! [IN]
115 myrank, & ! [OUT]
116 ismaster ) ! [OUT]
117
118 ! setup Log
119 call io_log_setup( myrank, ismaster )
120
121 call initialize()
122
123 !###########################################################################
124
125 !########## main ##########
126 call prof_setprefx('MAIN')
127 call prof_rapstart('Main_prep', 0)
128
129 !- Execute preprocess
130
131 !- Execute mktopo
132 call prof_rapstart('MkTopo',1)
133 call mktopo( output_topo, &
134 atmos%mesh, atmos%mesh%topography )
135 call prof_rapend ('MkTopo',1)
136
137 !- Re-setup
138 call atmos%mesh%Setup_vcoordinate()
139
140 !- Execute mkinit
141 call prof_rapstart('MkInit',1)
142 call mkinit( output, &
143 atmos%mesh, &
144 atmos%vars%container%PROGVARS_manager, &
145 atmos%vars%container%AUXVARS_manager, &
146 atmos%vars%container%QTRCVARS_manager )
147
148! call USER_mkinit( atmos )
149 call user_%mkinit( atmos )
150 if ( atmos%dyn_proc%dyncore_driver%ENTOT_CONSERVE_SCHEME_FLAG ) then
151 call set_total_energy( atmos%vars%container%PROGVARS_manager, &
152 atmos%vars%container%AUXVARS_manager, atmos%mesh )
153 end if
154
155 if ( ocean%IsActivated() ) call user_%mkinit_ocn( ocean )
156
157 call prof_rapend ('MkInit',1)
158 call prof_rapend('Main_prep', 0)
159
160 !- Output
161
162 if ( output_topo ) call mktopo_write( atmos%mesh, atmos%mesh%topography )
163
164 if ( output ) then
165 call prof_rapstart('MkInit_restart',1)
166 call restart_write()
167 call prof_rapend ('MkInit_restart',1)
168 end if
169
170 !########## Finalize ##########
171 call user_%mkfinal()
172 call finalize()
173
174 return
175 end subroutine dg_prep
176
177 !----------------------------
178
179 subroutine initialize()
180
181 use scale_const, only: const_setup
182 use scale_calendar, only: calendar_setup
183 use scale_random, only: random_setup
184 use scale_atmos_hydrometeor, only: atmos_hydrometeor_setup
185
189
190 use mod_mktopo, only: mktopo_setup
191 use mod_mkinit, only: mkinit_setup
192
193 implicit none
194
195 !----------------------------------------------
196
197 ! namelist compatibility check
198 !call ADMIN_versioncheck
199
200 ! setup PROF
201 call prof_setup
202
203 call prof_setprefx('INIT')
204 call prof_rapstart('Initialize', 0)
205
206 ! setup constants
207 call const_setup
208
209 ! setup calendar & initial time
210 call calendar_setup
211 call time_manager_init( .false. )
212
213 ! setup random number
214 call random_setup
215
216 ! setup tracer index
217 call atmos_hydrometeor_setup
218
219 ! setup a module for restart file
221
222 ! setup submodels
223 call atmos%setup()
224 call ocean%setup()
225 call coupler%setup()
226 call coupler%evaluate_activation( ocean )
227 call user_%setup( atmos )
228
229 call atmos%setup_vars()
230 call atmos%set_coupler( coupler )
231
232 if ( ocean%IsActivated() ) call ocean%setup_vars()
233 if ( coupler%IsActivated() ) call coupler%setup_vars( atmos%mesh%ptr_mesh, ocean%mesh%ptr_mesh )
234
235 ! setup mktopo
236 call mktopo_setup
237
238 ! setup mkinit
239 call mkinit_setup()
240
241 call prof_rapend('Initialize', 0)
242
243 return
244 end subroutine initialize
245
246 subroutine finalize()
252 implicit none
253
254 !----------------------------------------------
255 call prof_setprefx('FIN')
256 call prof_rapstart('All', 1)
257
258 !-
259 call prof_rapstart('File', 2)
262 call prof_rapend ('File', 2)
263
264 ! finalization submodels
265 call atmos%finalize()
266 call ocean%finalize()
267 call coupler%finalize()
268
269 !-
270 call time_manager_final()
271
272 call prof_rapend ('All', 1)
273 call prof_rapreport()
274
275 return
276 end subroutine finalize
277
278 subroutine set_total_energy( atm_prgvars_manager, & ! (inout)
279 atm_auxvars_manager, model_mesh )
280
288
289 use mod_atmos_mesh, only: atmosmesh
290 use mod_atmos_vars, only: &
291 atmosvars_getlocalmeshprgvars
292
293 implicit none
294
295 class(modelvarmanager), intent(inout) :: atm_prgvars_manager
296 class(modelvarmanager), intent(inout) :: atm_auxvars_manager
297 class(atmosmesh), target, intent(in) :: model_mesh
298
299 class(localmeshfieldbase), pointer :: ddens, momx, momy, momz, therm
300 class(localmeshfieldbase), pointer :: dens_hyd, pres_hyd
301 class(localmeshfieldbase), pointer :: rtot, cptot, cvtot
302
303 integer :: n
304 integer :: ke
305 class(localmesh3d), pointer :: lcmesh3d
306 class(meshbase3d), pointer :: mesh
307
308 real(rp), allocatable :: drhot_save(:,:)
309 real(rp), allocatable :: rhot_hyd_save(:,:)
310 !---------------------------------------------------------------------------
311
312 mesh => model_mesh%ptr_mesh
313 do n=1, mesh%LOCAL_MESH_NUM
314 call atmosvars_getlocalmeshprgvars( n, &
315 mesh, atm_prgvars_manager, atm_auxvars_manager, &
316 ddens, momx, momy, momz, therm, &
317 dens_hyd, pres_hyd, rtot, cvtot, cptot, &
318 lcmesh3d )
319
320 allocate( drhot_save(lcmesh3d%refElem3D%Np,lcmesh3d%NeA) )
321 allocate( rhot_hyd_save(lcmesh3d%refElem3D%Np,lcmesh3d%NeA) )
322
323 !$omp parallel do
324 do ke=lcmesh3d%NeS, lcmesh3d%NeE
325 drhot_save(:,ke) = therm%val(:,ke)
326 end do
327
329 pres_hyd%val, lcmesh3d, lcmesh3d%refElem3D )
330
332 ddens%val, momx%val, momy%val, momz%val, drhot_save, &
333 dens_hyd%val, pres_hyd%val, rhot_hyd_save, &
334 rtot%val, cvtot%val, cptot%val, &
335 lcmesh3d, lcmesh3d%refElem3D )
336
337 deallocate( drhot_save )
338 end do
339
340 return
341 end subroutine set_total_energy
342
343 subroutine restart_write
344 implicit none
345
346 logical :: is_restart_write_atmos
347 logical :: is_restart_write_ocean
348 !----------------------------------------
349
350 is_restart_write_atmos = atmos%IsActivated()
351 is_restart_write_ocean = ocean%IsActivated()
352
353 !- Preprocess
354 if ( is_restart_write_atmos ) then
355 call atmos%vars%Write_restart_file_prep()
356 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Write_restart_file_prep()
357 end if
358 if ( is_restart_write_ocean ) call ocean%vars%Write_restart_file_prep()
359
360 !- Write
361 if ( is_restart_write_atmos ) then
362 call atmos%vars%Write_restart_file()
363 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Write_restart_file()
364 end if
365 if ( is_restart_write_ocean ) call ocean%vars%Write_restart_file()
366
367 !- Postprocess
368 if ( is_restart_write_atmos ) then
369 call atmos%vars%Write_restart_file_post()
370 if ( atmos%phy_rd_proc%IsActivated() ) call atmos%phy_rd_proc%vars%Write_restart_file_post()
371 end if
372 if ( is_restart_write_ocean ) call ocean%vars%Write_restart_file_post()
373
374 return
375 end subroutine restart_write
376
377end module mod_dg_prep
module Atmosphere component
module Atmosphere / Mesh
module Atmosphere / Variables
module Coupler component
module SCALE-DG prep
subroutine, public dg_prep(comm_world, cnf_fname, path, add_path)
module INITIAL
subroutine, public mkinit_setup
Setup.
subroutine, public mkinit(output, model_mesh, atm_prgvars_manager, atm_auxvars_manager, atm_trcvars_manager)
Driver.
module INITIAL
subroutine, public mktopo_setup
Setup.
subroutine, public mktopo(output, model_mesh, topography)
Driver.
subroutine, public mktopo_write(model_mesh, topography)
Output topography data.
module Oceanic component
module USER
Definition mod_user.F90:12
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / Common
subroutine, public atm_dyn_dgm_nonhydro3d_common_drhot2entot(entot, ddens, momx, momy, momz, drhot, dens_hyd, pres_hyd, therm_hyd, rtot, cvtot, cptot, lcmesh, elem3d)
subroutine, public atm_dyn_dgm_nonhydro3d_common_calc_rhot_hyd(rhot_hyd, pres_hyd, lcmesh, elem3d)
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.
module FElib / Mesh / Local 3D
module FElib / Mesh / Base 3D
FElib / model framework / variable manager.
Module common / time.
subroutine, public time_manager_advance()
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 a computational mesh (base class)
Derived type to manage coupler component.
Derived type to manage oceanic component.
Derived type to manage a local 3D computational domain.
Derived type representing a field with local mesh (base type)
Derived type to manage a computational mesh (base type for 3D domain)