FE-Project
Loading...
Searching...
No Matches
mod_atmos_component.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module Atmosphere component
3!!
4!! @par Description
5!! Atmosphere component module
6!!
7!! @author Yuta Kawai, Team SCALE
8!!
9!<
10!-------------------------------------------------------------------------------
11#include "scaleFElib.h"
13 !-----------------------------------------------------------------------------
14 !
15 !++ used modules
16 !
17 use scale_precision
18 use scale_io
19 use scale_prof
20 use scale_prc
21
22 use scale_mesh_base, only: meshbase
27 use scale_localmeshfield_base, only: &
31
32 use mod_atmos_mesh, only: atmosmesh
35
36 use mod_atmos_vars, only: atmosvars
37
38 use mod_atmos_dyn, only: atmosdyn
42
43 !-----------------------------------------------------------------------------
44 implicit none
45 private
46 !-----------------------------------------------------------------------------
47 !
48 !++ Public type & procedure
49 !
50
51 !> Derived type to manage atmospheric component
52 type, extends(modelcomponent), public :: atmoscomponent
53 type(atmosvars) :: vars !< Object to mange variables with atmospheric component
54
55 character(len=H_SHORT) :: mesh_type !< Type name of mesh atmospheric component
56 class(atmosmesh), pointer :: mesh !< Pointer of mesh atmospheric component
57 type(atmosmeshrm) :: mesh_rm !< Object to manage mesh for the case of regional mode
58 type(atmosmeshgm) :: mesh_gm !< Object to manage mesh for the case of global mode
59
60 type(atmosdyn) :: dyn_proc !< Object to manage dynamical process
61 type(atmosphysfc) :: phy_sfc_proc !< Object to manage surface process
62 type(atmosphytb ) :: phy_tb_proc !< Object to manage sub-grid scale turbulence process
63 type(atmosphymp ) :: phy_mp_proc !< Object to manage cloud microphysics process
64
65 contains
66 procedure, public :: setup => atmos_setup
67 procedure, public :: setup_vars => atmos_setup_vars
68 procedure, public :: calc_tendency => atmos_calc_tendency
69 procedure, public :: update => atmos_update
70 procedure, public :: set_surface => atmos_set_surface
71 procedure, public :: finalize => atmos_finalize
72 end type atmoscomponent
73
74 !-----------------------------------------------------------------------------
75 !
76 !++ Public parameters & variables
77 !
78 !-----------------------------------------------------------------------------
79 !
80 !++ Private procedure
81 !
82 !-----------------------------------------------------------------------------
83 !
84 !++ Private parameters & variables
85 !
86 !-----------------------------------------------------------------------------
87contains
88
89!> Setup an object to mange atmospheric component
90!OCL SERIAL
91 subroutine atmos_setup( this )
92 use scale_const, only: &
93 undef8 => const_undef8
94
95 use scale_atmos_hydrometeor, only: &
96 atmos_hydrometeor_dry, &
97 atmos_hydrometeor_regist
98 use scale_atmos_thermodyn, only: &
99 atmos_thermodyn_setup
100 use scale_atmos_saturation, only: &
101 atmos_saturation_setup
102
105 use scale_time_manager, only: &
107
108 implicit none
109
110 class(atmoscomponent), intent(inout), target :: this
111
112 logical :: ACTIVATE_FLAG = .true. !< Flag whether atmospheric component is activated
113
114 real(DP) :: TIME_DT = undef8 !< Timestep value of atmospheric component
115 character(len=H_SHORT) :: TIME_DT_UNIT = 'SEC' !< Timestep unit of atmospheric component
116 real(DP) :: TIME_DT_RESTART = undef8 !< Timestep value when outputting restart file for atmospheric component
117 character(len=H_SHORT) :: TIME_DT_RESTART_UNIT = 'SEC' !< Timestep unit when outputting restart file for atmospheric component
118
119 logical :: ATMOS_DYN_DO = .true. !< Flag whether dynamics process is considered
120 logical :: ATMOS_PHY_SF_DO = .false. !< Flag whether surface process is considered
121 logical :: ATMOS_PHY_TB_DO = .false. !< Flag whether SGS turbulent process is considered
122 logical :: ATMOS_PHY_MP_DO = .false. !< Flag whether cloud microphysics process is considered
123 character(len=H_SHORT) :: ATMOS_MESH_TYPE = 'REGIONAL' !< Name of mesh type for atmospheric component ('REGIONAL' or 'GLOBAL')
124
125 logical :: ATMOS_USE_QV = .false. !< Flag whether QV is used although cloud microphysics is not considered
126
127
128 namelist / param_atmos / &
129 activate_flag, &
130 time_dt, &
131 time_dt_unit, &
132 time_dt_restart, &
133 time_dt_restart_unit, &
134 atmos_mesh_type, &
135 atmos_dyn_do, &
136 atmos_phy_sf_do, &
137 atmos_phy_tb_do, &
138 atmos_phy_mp_do, &
139 atmos_use_qv
140
141 integer :: ierr
142 !--------------------------------------------------
143 call prof_rapstart( 'ATM_setup', 1)
144 log_info('AtmosComponent_setup',*) 'Atmosphere model components '
145
146 !--- read namelist
147 rewind(io_fid_conf)
148 read(io_fid_conf,nml=param_atmos,iostat=ierr)
149 if( ierr < 0 ) then !--- missing
150 log_info("ATMOS_setup",*) 'Not found namelist. Default used.'
151 elseif( ierr > 0 ) then !--- fatal error
152 log_error("ATM_setup",*) 'Not appropriate names in namelist PARAM_ATMOS. Check!'
153 call prc_abort
154 endif
155 log_nml(param_atmos)
156
157 !************************************************
158 call this%ModelComponent_Init('ATMOS', activate_flag )
159 if ( .not. activate_flag ) return
160
161 !- Setup time manager
162
163 call this%time_manager%Init( this%GetComponentName(), &
164 time_dt, time_dt_unit, &
165 time_dt_restart, time_dt_restart_unit )
166
167 call time_manager_regist_component( this%time_manager )
168
169 !- Setup mesh & file I/O for atmospheric component
170
171 this%mesh_type = atmos_mesh_type
172 select case( this%mesh_type )
173 case('REGIONAL')
174 call this%mesh_rm%Init()
175 call file_history_meshfield_setup( mesh3d_=this%mesh_rm%mesh )
176 this%mesh => this%mesh_rm
177 case('GLOBAL')
178 call this%mesh_gm%Init()
179 call file_history_meshfield_setup( meshcubedsphere3d_=this%mesh_gm%mesh )
180 this%mesh => this%mesh_gm
181 case default
182 log_error("ATM_setup",*) 'Unsupported type of mesh is specified. Check!', this%mesh_type
183 call prc_abort
184 end select
185
186 !- setup common tools for atmospheric model
187
188 call atmos_thermodyn_setup
189 call atmos_saturation_setup
190
191 !- Setup each processes in atmospheric model ------------------------------------
192
193 !- Setup the module for atmosphere / physics / surface
194 call this%phy_sfc_proc%ModelComponentProc_Init( 'AtmosPhysSfc', atmos_phy_sf_do )
195 call this%phy_sfc_proc%setup( this%mesh, this%time_manager )
196
197 !- Setup the module for atmosphere / physics / cloud microphysics
198 call this%phy_mp_proc%ModelComponentProc_Init( 'AtmosPhysMp', atmos_phy_mp_do )
199 call this%phy_mp_proc%setup( this%mesh, this%time_manager )
200
201 !-- Regist qv if needed
202 if ( atmos_hydrometeor_dry .and. atmos_use_qv ) then
203 log_info("ATMOS_setup",*) "Regist QV"
204 call atmos_hydrometeor_regist( 0, 0, & ! (in)
205 (/'QV'/), & ! (in)
206 (/'Ratio of Water Vapor mass to total mass (Specific humidity)'/), & ! (in)
207 (/'kg/kg'/), & ! (in)
208 this%phy_mp_proc%vars%QS ) ! (out)
209
210 this%phy_mp_proc%vars%QA = 1
211 this%phy_mp_proc%vars%QE = this%phy_mp_proc%vars%QS
212 end if
213
214 !- Setup the module for atmosphere / dynamics
215 call this%dyn_proc%ModelComponentProc_Init( 'AtmosDyn', atmos_dyn_do )
216 call this%dyn_proc%setup( this%mesh, this%time_manager )
217
218 !- Setup the module for atmosphere / physics / turbulence
219 call this%phy_tb_proc%ModelComponentProc_Init( 'AtmosPhysTb', atmos_phy_tb_do )
220 call this%phy_tb_proc%setup( this%mesh, this%time_manager )
221 call this%phy_tb_proc%SetDynBC( this%dyn_proc%dyncore_driver%boundary_cond )
222
223 log_newline
224 log_info('AtmosComponent_setup',*) 'Finish setup of each atmospheric components.'
225
226 call prof_rapend( 'ATM_setup', 1)
227
228 return
229 end subroutine atmos_setup
230
231!> Setup variables with the atmospheric component
232!OCL SERIAL
233 subroutine atmos_setup_vars( this )
234 implicit none
235
236 class(atmoscomponent), intent(inout) :: this
237 !----------------------------------------------------------
238
239 call prof_rapstart( 'ATM_setup_vars', 1)
240
241 call this%vars%Init( this%mesh )
242 call this%vars%Regist_physvar_manager( &
243 this%phy_mp_proc%vars%auxvars2D_manager )
244
245 call prof_rapend( 'ATM_setup_vars', 1)
246
247 return
248 end subroutine atmos_setup_vars
249
250!> Calculate tendencies with the atmospheric component
251!OCL SERIAL
252 subroutine atmos_calc_tendency( this, force )
253 use scale_tracer, only: qa
255 phytend_num1 => phytend_num, &
256 dens_tp => phytend_dens_id, &
257 momx_tp => phytend_momx_id, &
258 momy_tp => phytend_momy_id, &
259 momz_tp => phytend_momz_id, &
260 rhot_tp => phytend_rhot_id, &
261 rhoh_p => phytend_rhoh_id
262 use mod_atmos_vars, only: &
264
265 implicit none
266 class(atmoscomponent), intent(inout) :: this
267 logical, intent(in) :: force
268
269
270 class(meshbase), pointer :: mesh
271 class(localmesh3d), pointer :: lcmesh
272 type(localmeshfieldbaselist) :: tp_list(PHYTEND_NUM1)
273 type(localmeshfieldbaselist) :: tp_qtrc(QA)
274
275 integer :: tm_process_id
276 logical :: is_update
277 integer :: n
278 integer :: v
279 integer :: iq
280 integer :: ke
281 !------------------------------------------------------------------
282
283 call prof_rapstart( 'ATM_tendency', 1)
284 !LOG_INFO('AtmosComponent_calc_tendency',*)
285
286 call this%mesh%GetModelMesh( mesh )
287
288 !########## Get Surface Boundary from coupler ##########
289
290
291 !########## calculate tendency ##########
292
293 !* Exchange halo data ( for physics )
294 call prof_rapstart( 'ATM_exchange_prgv', 2)
295 call this%vars%PROGVARS_manager%MeshFieldComm_Exchange()
296 if ( qa > 0 ) call this%vars%QTRCVARS_manager%MeshFieldComm_Exchange()
297 call prof_rapend( 'ATM_exchange_prgv', 2)
298
299 ! reset tendencies of physics
300
301 do n=1, mesh%LOCAL_MESH_NUM
302 call atmosvars_getlocalmeshphytends( n, mesh, this%vars%PHYTENDS_manager , & ! (in)
303 tp_list(dens_tp)%ptr, tp_list(momx_tp)%ptr, tp_list(momy_tp)%ptr, & ! (out)
304 tp_list(momz_tp)%ptr, tp_list(rhot_tp)%ptr, tp_list(rhoh_p )%ptr, tp_qtrc, & ! (out)
305 lcmesh ) ! (out)
306
307 !$omp parallel private(v,iq,ke)
308 !$omp do collapse(2)
309 do v=1, phytend_num1
310 do ke=lcmesh%NeS, lcmesh%NeE
311 tp_list(v)%ptr%val(:,ke) = 0.0_rp
312 end do
313 end do
314 !$omp do collapse(2)
315 do iq=1, qa
316 do ke=lcmesh%NeS, lcmesh%NeE
317 tp_qtrc(iq)%ptr%val(:,ke) = 0.0_rp
318 end do
319 end do
320 !$omp end do
321 !$omp end parallel
322 end do
323
324 ! Cloud Microphysics
325
326 if ( this%phy_mp_proc%IsActivated() ) then
327 call prof_rapstart('ATM_Microphysics', 1)
328 tm_process_id = this%phy_mp_proc%tm_process_id
329 is_update = this%time_manager%Do_process(tm_process_id) .or. force
330 call this%phy_mp_proc%calc_tendency( &
331 this%mesh, this%vars%PROGVARS_manager, this%vars%QTRCVARS_manager, &
332 this%vars%AUXVARS_manager, this%vars%PHYTENDS_manager, is_update )
333 call prof_rapend('ATM_Microphysics', 1)
334 end if
335
336 ! Radiation
337
338
339 ! Turbulence
340
341 if ( this%phy_tb_proc%IsActivated() ) then
342 call prof_rapstart('ATM_Turbulence', 1)
343 tm_process_id = this%phy_tb_proc%tm_process_id
344 is_update = this%time_manager%Do_process(tm_process_id) .or. force
345 call this%phy_tb_proc%calc_tendency( &
346 this%mesh, this%vars%PROGVARS_manager, this%vars%QTRCVARS_manager, &
347 this%vars%AUXVARS_manager, this%vars%PHYTENDS_manager, is_update )
348 call prof_rapend('ATM_Turbulence', 1)
349 end if
350
351 ! Cumulus
352
353
354! if ( .not. CPL_sw ) then
355
356 ! Surface flux
357
358 if ( this%phy_sfc_proc%IsActivated() ) then
359 call prof_rapstart('ATM_SurfaceFlux', 1)
360 tm_process_id = this%phy_sfc_proc%tm_process_id
361 is_update = this%time_manager%Do_process(tm_process_id) .or. force
362 call this%phy_sfc_proc%calc_tendency( &
363 this%mesh, this%vars%PROGVARS_manager, this%vars%QTRCVARS_manager, &
364 this%vars%AUXVARS_manager, this%vars%PHYTENDS_manager, is_update )
365 call prof_rapend('ATM_SurfaceFlux', 1)
366 end if
367
368 ! Planetary Boundary layer
369
370! end if
371
372 call prof_rapend( 'ATM_tendency', 1)
373 return
374 end subroutine atmos_calc_tendency
375
376!> Update variables with the atmospheric component
377!OCL SERIAL
378 subroutine atmos_update( this )
379 implicit none
380 class(atmoscomponent), intent(inout) :: this
381
382 integer :: tm_process_id
383 logical :: is_update
384 integer :: inner_itr
385 !--------------------------------------------------
386 call prof_rapstart( 'ATM_update', 1)
387
388 !########## Dynamics ##########
389
390 if ( this%dyn_proc%IsActivated() ) then
391 call prof_rapstart('ATM_Dynamics', 1)
392 tm_process_id = this%dyn_proc%tm_process_id
393 is_update = this%time_manager%Do_process( tm_process_id )
394
395 log_progress(*) 'atmosphere / dynamics'
396 do inner_itr=1, this%time_manager%Get_process_inner_itr_num( tm_process_id )
397 call this%dyn_proc%update( &
398 this%mesh, this%vars%PROGVARS_manager, this%vars%QTRCVARS_manager, &
399 this%vars%AUXVARS_manager, this%vars%PHYTENDS_manager, is_update )
400 end do
401 call prof_rapend('ATM_Dynamics', 1)
402 end if
403
404 !########## Calculate diagnostic variables ##########
405
406 call this%vars%Calc_diagnostics()
407 call this%vars%AUXVARS_manager%MeshFieldComm_Exchange()
408
409 !########## Adjustment ##########
410 ! Microphysics
411 ! Aerosol
412 ! Lightning
413
414 !########## Reference State ###########
415
416 !#### Check values #################################
417 call this%vars%Check()
418
419 call prof_rapend('ATM_update', 1)
420 return
421 end subroutine atmos_update
422
423!OCL SERIAL
424 subroutine atmos_set_surface( this )
425 use mod_atmos_vars, only: &
427 use mod_atmos_phy_mp_vars, only: &
429 implicit none
430 class(atmoscomponent), intent(inout) :: this
431
432 class(meshbase), pointer :: mesh
433 class(meshbase2d), pointer :: mesh2D
434 class(localmesh2d), pointer :: lcmesh
435 integer :: n
436 integer :: ke
437
438 class(localmeshfieldbase), pointer :: PREC, PREC_ENGI
439 class(localmeshfieldbase), pointer :: SFLX_rain_MP, SFLX_snow_MP, SFLX_ENGI_MP
440
441 !--------------------------------------------------
442
443 call prof_rapstart( 'ATM_sfc_exch', 1)
444
445 call this%mesh%GetModelMesh( mesh )
446 select type(mesh)
447 class is (meshbase3d)
448 call mesh%GetMesh2D( mesh2d )
449 end select
450
451 !- sum of rainfall from mp and cp
452
453 do n=1, mesh2d%LOCAL_MESH_NUM
455 mesh2d, this%vars%AUXVARS2D_manager, & ! (in)
456 prec, prec_engi, lcmesh ) ! (out)
457
458 !$omp parallel do private(ke)
459 do ke=lcmesh%NeS, lcmesh%NeE
460 prec %val(:,ke) = 0.0_rp
461 prec_engi%val(:,ke) = 0.0_rp
462 end do
463
464 if ( this%phy_mp_proc%IsActivated() ) then
466 mesh2d, this%phy_mp_proc%vars%auxvars2D_manager, & ! (in)
467 sflx_rain_mp, sflx_snow_mp, sflx_engi_mp ) ! (out)
468
469 !$omp parallel do private(ke)
470 do ke=lcmesh%NeS, lcmesh%NeE
471 prec %val(:,ke) = prec %val(:,ke) + sflx_rain_mp%val(:,ke) + sflx_snow_mp%val(:,ke)
472 prec_engi%val(:,ke) = prec_engi%val(:,ke) + sflx_engi_mp%val(:,ke)
473 end do
474 end if
475 end do
476
477 call prof_rapend( 'ATM_sfc_exch', 1)
478
479 return
480 end subroutine atmos_set_surface
481
482!> Finalize an object to manage the atmospheric component
483!OCL SERIAL
484 subroutine atmos_finalize( this )
485 implicit none
486 class(atmoscomponent), intent(inout) :: this
487 !--------------------------------------------------
488
489 log_info('AtmosComponent_finalize',*)
490
491 if ( .not. this%IsActivated() ) return
492
493 call this%dyn_proc%finalize()
494 call this%phy_sfc_proc%finalize()
495 call this%phy_tb_proc%finalize()
496 call this%phy_mp_proc%finalize()
497
498 call this%vars%Final()
499
500 select case( this%mesh_type )
501 case('REGIONAL')
502 call this%mesh_rm%Final()
503 case('GLOBAL')
504 call this%mesh_gm%Final()
505 end select
506 this%mesh => null()
507
508 call this%time_manager%Final()
509
510 return
511 end subroutine atmos_finalize
512
513end module mod_atmos_component
module Atmosphere component
subroutine atmos_setup(this)
Setup an object to mange atmospheric component.
module Atmosphere / Dynamics
module Atmosphere / Mesh
module Atmosphere / Mesh
module Atmosphere / Mesh
module Atmosphere / Physics / Cloud Microphysics
subroutine, public atmosphympvars_getlocalmeshfields_sfcflx(domid, mesh, sfcflx_list, sflx_rain, sflx_snow, sflx_engi)
module Atmosphere / Physics / cloud microphysics
module Atmosphere / Physics / surface process
module Atmosphere / Physics / sub-grid scale turbulence process
module Atmosphere / Physics / Variables
subroutine, public atmosvars_getlocalmeshsfcvar(domid, mesh, auxvars2d_list, prec, prec_engi, lcmesh2d)
subroutine, public atmosvars_getlocalmeshphytends(domid, mesh, phytends_list, dens_tp, momx_tp, momy_tp, momz_tp, rhot_tp, rhoh_p, rhoq_tp, lcmesh3d)
module FElib / Fluid dyn solver / Atmosphere / Nonhydrostatic model / Common
subroutine, public file_history_meshfield_setup(mesh1d_, mesh2d_, mesh3d_, meshcubedsphere2d_, meshcubedsphere3d_)
module FElib / Mesh / Local 2D
module FElib / Mesh / Local 3D
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
module FElib / Mesh / Base
FElib / model framework / model component.
FElib / model framework / mesh manager.
Module common / time.
subroutine, public time_manager_regist_component(tmanager_comp)
Derived type to manage atmospheric component.
Derived type to manage a component of atmospheric dynamics.
Derived type to manage a computational mesh (base class)
Derived type to manage a computational mesh of global atmospheric model.
Derived type to manage a computational mesh of regional atmospheric model.
Derived type to manage a component of cloud microphysics.
Derived type to manage a component of surface process.
Derived type to manage a component of sub-grid scale turbulent process.
Derived type to manage variables with atmospheric component.
Derived type to manage a local 3D computational domain.
Derived type representing a field with local mesh (base type)