FE-Project
Loading...
Searching...
No Matches
mod_atmos_phy_rd_vars.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module Atmosphere / Physics / Radiation
3!!
4!! @par Description
5!! Container for variables with radiation component in atmospheric model
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_prc
20
22 use scale_mesh_base, only: meshbase
24 use scale_mesh_base3d, only: &
25 meshbase3d, &
26 dimtype_xyz => meshbase3d_dimtypeid_xyz, &
27 dimtype_xy => meshbase3d_dimtypeid_xy
30 use scale_localmeshfield_base, only: &
32 use scale_meshfield_base, only: &
35
38
39 use scale_model_var_manager, only: &
40 modelvarmanager, variableinfo
41 use scale_model_mesh_manager, only: modelmeshbase
42
43 use mod_atmos_mesh, only: atmosmesh
44
45 !-----------------------------------------------------------------------------
46 implicit none
47 private
48
49 !-----------------------------------------------------------------------------
50 !
51 !++ Public type & procedures
52 !
53
54 !> Derived type to manage variables with radiation component in atmospheric model
55 type, public :: atmosphyrdvars
56 type(meshfield3d), allocatable :: tends(:) !< Array of tendency variables
57 type(modelvarmanager) :: tends_manager !< Object to manage tendencies
58
59 type(meshfield2d), allocatable :: auxvars2d(:) !< Array of 2D auxiliary variables
60 type(modelvarmanager) :: auxvars2d_manager !< Object to manage 2D auxiliary variables
61
62 type(meshfield2d), allocatable :: sflx_rad_dn(:) !< Array of downward radiative fluxes at the surface
63
64 integer :: tends_num_tot !< Number of tendency variables with cloud microphysics
65
66 type(file_restart_meshfield_component) restart_file !< Restart file for variables with radiation component
67 contains
68 procedure :: init => atmosphyrdvars_init
69 procedure :: final => atmosphyrdvars_final
70 procedure :: setup => atmosphyrdvars_setup
71 procedure :: history => atmosphyrdvars_history
72 procedure :: read_restart_file => atmosphyrdvars_read_restart_file
73 procedure :: write_restart_file_prep => atmosphyrdvars_write_restart_file_prep
74 procedure :: write_restart_file => atmosphyrdvars_write_restart_file
75 procedure :: write_restart_file_post => atmosphyrdvars_write_restart_file_post
76 end type atmosphyrdvars
77
78 !-----------------------------------------------------------------------------
79 !
80 !++ Public variables
81 !
82 integer, public, parameter :: atmos_phy_rd_rhoh_id = 1 !< ID of diabatic heating rate in RD process
83 integer, public, parameter :: atmos_phy_rd_tends_num1 = 1
84
85 type(variableinfo), public :: atmos_phy_rd_tend_vinfo(atmos_phy_rd_tends_num1)
87 variableinfo( atmos_phy_rd_rhoh_id, 'RD_RHOH', 'diabatic heating rate in RD process', &
88 'J/kg/s', 3, 'XYZ', '' ) /
89
90 !-- 2D Auxiliary variables for radiation
91
92 ! Radiative fluxes at the surface
93 integer, public, parameter :: atmos_phy_rd_aux2d_sflx_lw_up_id = 1 !< ID of upward longwave surface flux
94 integer, public, parameter :: atmos_phy_rd_aux2d_sflx_lw_dn_id = 2 !< ID of downward longwave surface flux
95 integer, public, parameter :: atmos_phy_rd_aux2d_sflx_sw_up_id = 3 !< ID of upward shortwave surface flux
96 integer, public, parameter :: atmos_phy_rd_aux2d_sflx_sw_dn_id = 4 !< ID of downward shortwave surface flux
97 integer, public, parameter :: atmos_phy_rd_restart_var_num = 4 !< Number of restart variables for radiation component
98 ! Radiative fluxes at the top of the model
99 integer, public, parameter :: atmos_phy_rd_aux2d_tomflx_lw_up_id = 5 !< ID of upward longwave flux at the top of the model
100 integer, public, parameter :: atmos_phy_rd_aux2d_tomflx_lw_dn_id = 6 !< ID of downward longwave flux at the top of the model
101 integer, public, parameter :: atmos_phy_rd_aux2d_tomflx_sw_up_id = 7 !< ID of upward shortwave flux at the top of the model
102 integer, public, parameter :: atmos_phy_rd_aux2d_tomflx_sw_dn_id = 8 !< ID of downward shortwave flux at the top of the model
103 !
104 integer, public, parameter :: atmos_phy_rd_aux2d_solins_id = 9 !< ID of solar insolation flux at the top of the model
105 integer, public, parameter :: atmos_phy_rd_aux2d_cossza_id = 10 !< ID of cosine of solar zenith angle
106 integer, public, parameter :: atmos_phy_rd_aux2d_num = 10
107
110 variableinfo( atmos_phy_rd_aux2d_sflx_lw_up_id , 'RD_SFLX_LW_up' , 'upward longwave surface flux' , 'W/m2', 2, 'XY', '' ), &
111 variableinfo( atmos_phy_rd_aux2d_sflx_lw_dn_id , 'RD_SFLX_LW_dn' , 'downward longwave surface flux' , 'W/m2', 2, 'XY', '' ), &
112 variableinfo( atmos_phy_rd_aux2d_sflx_sw_up_id , 'RD_SFLX_SW_up' , 'upward shortwave surface flux' , 'W/m2', 2, 'XY', '' ), &
113 variableinfo( atmos_phy_rd_aux2d_sflx_sw_dn_id , 'RD_SFLX_SW_dn' , 'downward shortwave surface flux' , 'W/m2', 2, 'XY', '' ), &
114 variableinfo( atmos_phy_rd_aux2d_tomflx_lw_up_id, 'RD_TOMFLX_LW_up', 'upward longwave flux at the top of the model' , 'W/m2', 2, 'XY', '' ), &
115 variableinfo( atmos_phy_rd_aux2d_tomflx_lw_dn_id, 'RD_TOMFLX_LW_dn', 'downward longwave flux at the top of the model' , 'W/m2', 2, 'XY', '' ), &
116 variableinfo( atmos_phy_rd_aux2d_tomflx_sw_up_id, 'RD_TOMFLX_SW_up', 'upward shortwave flux at the top of the model' , 'W/m2', 2, 'XY', '' ), &
117 variableinfo( atmos_phy_rd_aux2d_tomflx_sw_dn_id, 'RD_TOMFLX_SW_dn', 'downward shortwave flux at the top of the model', 'W/m2', 2, 'XY', '' ), &
118 variableinfo( atmos_phy_rd_aux2d_solins_id , 'RD_SolINS' , 'solar insolation flux at the top of the model' , 'W/m2', 2, 'XY', '' ), &
119 variableinfo( atmos_phy_rd_aux2d_cossza_id , 'RD_cosSZA' , 'cosine of solar zenith angle' , '1', 2, 'XY', '' ) /
120
121 !-
122 integer, public, parameter :: atmos_phy_rd_sflx_dn_sw_dir = 1 !< ID of downward direct shortwave flux at the surface
123 integer, public, parameter :: atmos_phy_rd_sflx_dn_sw_dif = 2 !< ID of downward diffuse shortwave flux at the surface
124 integer, public, parameter :: atmos_phy_rd_sflx_dn_lw = 3 !< ID of downward longwave flux at the surface
125 integer, public, parameter :: atmos_phy_rd_sflx_dn_num = 3 !< Number of downward radiative fluxes
126 !-----------------------------------------------------------------------------
127 !
128 !++ Private procedures
129 !
130contains
131 !> Setup an object to manage variables with a radiation component
132!OCL SERIAL
133 subroutine atmosphyrdvars_init( this, model_mesh )
134
135 use scale_tracer, only: &
136 tracer_name, tracer_desc, tracer_unit
137 use scale_file_history, only: &
138 file_history_reg
139
140 implicit none
141 class(atmosphyrdvars), target, intent(inout) :: this
142 class(modelmeshbase), target, intent(in) :: model_mesh
143
144 class(atmosmesh), pointer :: atm_mesh
145 class(meshbase2d), pointer :: mesh2d
146 class(meshbase3d), pointer :: mesh3d
147
148 integer :: iv
149 integer :: iq
150 integer :: n
151 logical :: reg_file_hist
152 !----------------------------------------------------
153
154 log_info('AtmosPhyRdVars_Init',*)
155 return
156 end subroutine atmosphyrdvars_init
157
158 !> Setup variables objects with radiation component
159 subroutine atmosphyrdvars_setup( this, model_mesh )
160 use scale_tracer, only: &
161 tracer_name, tracer_desc, tracer_unit
162 use scale_file_history, only: &
163 file_history_reg
164
165 implicit none
166 class(atmosphyrdvars), target, intent(inout) :: this
167 class(modelmeshbase), target, intent(in) :: model_mesh
168
169 class(atmosmesh), pointer :: atm_mesh
170 class(meshbase2d), pointer :: mesh2d
171 class(meshbase3d), pointer :: mesh3d
172
173 integer :: iv
174 integer :: iq
175 integer :: n
176 logical :: reg_file_hist
177 !----------------------------------------------------
178
179 log_info('AtmosPhyRdVars_Init',*)
180
181 this%TENDS_NUM_TOT = atmos_phy_rd_tends_num1
182
183 !- Initialize auxiliary and diagnostic variables
184
185 nullify( atm_mesh )
186 select type(model_mesh)
187 class is (atmosmesh)
188 atm_mesh => model_mesh
189 end select
190 mesh3d => atm_mesh%ptr_mesh
191
192 call mesh3d%GetMesh2D( mesh2d )
193
194 !----
195
196 !-
197 call this%tends_manager%Init()
198 allocate( this%tends(this%TENDS_NUM_TOT) )
199
200 reg_file_hist = .true.
202 call this%tends_manager%Regist( &
203 atmos_phy_rd_tend_vinfo(iv), mesh3d, & ! (in)
204 this%tends(iv), reg_file_hist ) ! (out)
205
206 do n = 1, mesh3d%LOCAL_MESH_NUM
207 this%tends(iv)%local(n)%val(:,:) = 0.0_rp
208 end do
209 end do
210
211 !-
212 call this%auxvars2D_manager%Init()
213 allocate( this%auxvars2D(atmos_phy_rd_aux2d_num) )
214
215 reg_file_hist = .true.
217 call this%auxvars2D_manager%Regist( &
218 atmos_phy_rd_aux2d_vinfo(iv), mesh2d, & ! (in)
219 this%auxvars2D(iv), reg_file_hist ) ! (out)
220
221 do n = 1, mesh2d%LOCAL_MESH_NUM
222 this%auxvars2D(iv)%local(n)%val(:,:) = 0.0_rp
223 end do
224 end do
225
226 !- Setup restart file for variables with radiation component
227 call atm_mesh%Setup_restartfile( this%restart_file, &
229
230 return
231 end subroutine atmosphyrdvars_setup
232
233 !> Finalize an object to manage variables with radiation component
234!OCL SERIAL
235 subroutine atmosphyrdvars_final( this )
236 implicit none
237 class(atmosphyrdvars), intent(inout) :: this
238 !----------------------------------------------------
239
240 log_info('AtmosPhyRdVars_Final',*)
241
242 call this%tends_manager%Final()
243 deallocate( this%tends )
244
245 call this%auxvars2D_manager%Final()
246 deallocate( this%auxvars2D )
247
248 return
249 end subroutine atmosphyrdvars_final
250
251 !> Write history data of variables with radiation component
252!OCL SERIAL
253 subroutine atmosphyrdvars_history( this )
255 implicit none
256 class(atmosphyrdvars), intent(inout) :: this
257
258 integer :: v
259 integer :: hst_id
260 !----------------------------------------------------
261
262 do v = 1, this%TENDS_NUM_TOT
263 hst_id = this%tends(v)%hist_id
264 if ( hst_id > 0 ) call file_history_meshfield_put( hst_id, this%tends(v) )
265 end do
266
267 do v = 1, atmos_phy_rd_aux2d_num
268 hst_id = this%auxvars2D(v)%hist_id
269 if ( hst_id > 0 ) call file_history_meshfield_put( hst_id, this%auxvars2D(v) )
270 end do
271
272 return
273 end subroutine atmosphyrdvars_history
274
275!> Read data with atmospheric variables with radiation component from restart file
276!!
277!OCL SERIAL
278 subroutine atmosphyrdvars_read_restart_file( this )
280 implicit none
281
282 class(atmosphyrdvars), intent(inout), target :: this
283
284 integer :: iv
285 !--------------------------------------------------------------------
286
287 log_newline
288 log_info("AtmosPhyRdVars_Read_restart_file",*) 'Open restart file (ATMOS/Physics radiation) '
289
290 !- Open restart file
291 call this%restart_file%Open()
292
293 !- Read restart file
294
296 call this%restart_file%Read_var( dimtype_xy, this%auxvars2D(iv)%varname, &
297 this%auxvars2D(iv) )
298 end do
299
300 !- Close restart file
301 log_info("AtmosPhyRdVars_Read_restart_file",*) 'Close restart file (ATMOS/Physics radiation) '
302 call this%restart_file%Close()
303 return
304 end subroutine atmosphyrdvars_read_restart_file
305
306!> Write data with atmospheric variables with radiation component to restart file
307!!
308!OCL SERIAL
309 subroutine atmosphyrdvars_write_restart_file_prep( this )
310 implicit none
311 class(atmosphyrdvars), intent(inout) :: this
312
313 integer :: iv, rf_vid
314 !---------------------------------------
315
316 log_newline
317 log_info("AtmosPhyRdVars_Write_restart_file_prep",*) 'Define variables with ATMOS/Physics radiation'
318
319 !- Create restart file
320 call this%restart_file%Create()
321 call prc_mpibarrier()
322
323 !- Define variables
324
326 rf_vid = iv
327 call this%restart_file%Def_var( this%auxvars2D(iv), &
328 atmos_phy_rd_aux2d_vinfo(iv)%DESC, rf_vid, dimtype_xy )
329 end do
330 return
331 end subroutine atmosphyrdvars_write_restart_file_prep
332
333!> Write data with atmospheric variables with radiation component to restart file
334!!
335!OCL SERIAL
336 subroutine atmosphyrdvars_write_restart_file( this )
337 implicit none
338 class(atmosphyrdvars), intent(inout) :: this
339
340 integer :: iv, rf_vid
341 !---------------------------------------
342 !- Write restart file
344 rf_vid = iv
345 call this%restart_file%Write_var(rf_vid, this%auxvars2D(iv) )
346 end do
347 return
348 end subroutine atmosphyrdvars_write_restart_file
349
350 !> Close restart file with atmospheric radiation component
351 !!
352!OCL SERIAL
353 subroutine atmosphyrdvars_write_restart_file_post( this )
354 implicit none
355 class(atmosphyrdvars), intent(inout) :: this
356 !---------------------------------------
357 log_info("AtmosPhyRdVars_Write_restart_file_post",*) 'Close restart file (ATMOS/Physics radiation) '
358
359 call this%restart_file%Close()
360 return
361 end subroutine atmosphyrdvars_write_restart_file_post
362
363end module mod_atmos_phy_rd_vars
module Atmosphere / Mesh
module Atmosphere / Physics / Radiation
integer, parameter, public atmos_phy_rd_aux2d_solins_id
ID of solar insolation flux at the top of the model.
integer, parameter, public atmos_phy_rd_aux2d_tomflx_lw_up_id
ID of upward longwave flux at the top of the model.
integer, parameter, public atmos_phy_rd_aux2d_tomflx_sw_dn_id
ID of downward shortwave flux at the top of the model.
integer, parameter, public atmos_phy_rd_restart_var_num
Number of restart variables for radiation component.
type(variableinfo), dimension(atmos_phy_rd_aux2d_num), public atmos_phy_rd_aux2d_vinfo
integer, parameter, public atmos_phy_rd_aux2d_cossza_id
ID of cosine of solar zenith angle.
integer, parameter, public atmos_phy_rd_sflx_dn_lw
ID of downward longwave flux at the surface.
integer, parameter, public atmos_phy_rd_sflx_dn_num
Number of downward radiative fluxes.
integer, parameter, public atmos_phy_rd_tends_num1
integer, parameter, public atmos_phy_rd_aux2d_tomflx_sw_up_id
ID of upward shortwave flux at the top of the model.
type(variableinfo), dimension(atmos_phy_rd_tends_num1), public atmos_phy_rd_tend_vinfo
integer, parameter, public atmos_phy_rd_aux2d_sflx_sw_dn_id
ID of downward shortwave surface flux.
integer, parameter, public atmos_phy_rd_rhoh_id
ID of diabatic heating rate in RD process.
integer, parameter, public atmos_phy_rd_aux2d_sflx_lw_dn_id
ID of downward longwave surface flux.
integer, parameter, public atmos_phy_rd_aux2d_tomflx_lw_dn_id
ID of downward longwave flux at the top of the model.
integer, parameter, public atmos_phy_rd_aux2d_sflx_sw_up_id
ID of upward shortwave surface flux.
integer, parameter, public atmos_phy_rd_aux2d_sflx_lw_up_id
ID of upward longwave surface flux.
integer, parameter, public atmos_phy_rd_sflx_dn_sw_dir
ID of downward direct shortwave flux at the surface.
integer, parameter, public atmos_phy_rd_sflx_dn_sw_dif
ID of downward diffuse shortwave flux at the surface.
integer, parameter, public atmos_phy_rd_aux2d_num
module FElib / Element / Base
type(file_restart_meshfield), public restart_file
An object to manage main restart file.
module FElib / Mesh / Local 3D
module FElib / Mesh / Local, Base
module FElib / Mesh / Base 2D
module FElib / Mesh / Base 3D
integer, public meshbase3d_dimtypeid_xy
integer, public meshbase3d_dimtypeid_xyz
module FElib / Mesh / Base
module FElib / Data / base
module FElib / Data / Communication base
FElib / model framework / mesh manager.
FElib / model framework / variable manager.
Derived type to manage a computational mesh (base class)
Derived type to manage variables with radiation component in atmospheric model.
Derived type representing a 3D reference element.
Derived type to manage restart file with each component.
Derived type to manage a local 3D computational domain.
Derived type to manage a local computational domain (base type)
Derived type representing a field with local mesh (base type)
Derived type to manage a computational mesh (base type for 2D domain)
Derived type to manage a computational mesh (base type for 3D domain)
Base type to manage a computational mesh.
Derived type representing a field with 2D mesh.
Derived type representing a field with 3D mesh.
Derived type representing a field (base type)
Container to save a pointer of MeshField(1D, 2D, 3D) object.