FE-Project
Loading...
Searching...
No Matches
mod_atmos_mesh_gm.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module Atmosphere / Mesh
3!!
4!! @par Description
5!! Module for mesh with atmospheric global 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
28 use scale_sparsemat, only: sparsemat
30
33
34 use mod_atmos_mesh, only: &
36
37 !-----------------------------------------------------------------------------
38 implicit none
39 private
40 !-----------------------------------------------------------------------------
41 !
42 !++ Public type & procedures
43 !
44
45 !> Derived type to manage a computational mesh of global atmospheric model
46 !!
47 type, extends(atmosmesh), public :: atmosmeshgm
48 type(meshcubedspheredom3d) :: mesh !< Object for 3D cubed-sphere mesh
50 contains
51 procedure :: init => atmosmeshgm_init
52 procedure :: final => atmosmeshgm_final
53 procedure :: create_communicator => atmosmeshgm_create_communicator
54 procedure :: setup_restartfile1 => atmosmeshgm_setup_restartfile1
55 procedure :: setup_restartfile2 => atmosmeshgm_setup_restartfile2
56 procedure :: calc_uvmet => atmosmeshgm_calc_uvmet
57 procedure :: setup_vcoordinate => atmosmeshgm_setup_vcoordinate
58 end type atmosmeshgm
59
60 !-----------------------------------------------------------------------------
61 !
62 !++ Public parameters & variables
63 !
64
65 !-----------------------------------------------------------------------------
66 !
67 !++ Private procedures
68 !
69 !-------------------
70
71 !-----------------------------------------------------------------------------
72 !
73 !++ Private parameters & variables
74 !
75
76contains
77
78 !> Initialize an object to manage computational mesh
79 !!
80!OCL SERIAL
81 subroutine atmosmeshgm_init( this )
82 use scale_const, only: &
83 rplanet => const_radius
84 use scale_mesh_base2d, only: &
85 mftype2d_xy => meshbase2d_dimtypeid_xy
86 use scale_meshutil_vcoord, only: &
88
89 implicit none
90 class(atmosmeshgm), target, intent(inout) :: this
91
92 real(RP) :: dom_zmin = 0.0_rp !< Minimum vertical coordinate value of the computational domain
93 real(RP) :: dom_zmax = 10.0e3_rp !< Maximum vertical coordinate value of the computational domain
94 logical :: isPeriodicZ = .false. !< Flag whether a periodic boundary condition is applied in the vertical direction
95
96 integer, parameter :: FZ_nmax = 1000
97 real(RP) :: FZ(FZ_nmax) !< Values of the vertically computational coordinate at the element boundaries
98
99 !* Global
100 logical :: SHALLOW_ATM_APPROX_FLAG = .true. !< Flag whether the shallow atmosphere approximation is applied
101 integer :: NeGX = 2 !< Number of finite element in the y-coordinate direction in each panel of the cubed-sphere mesh
102 integer :: NeGY = 2 !< Number of finite element in the y-coordinate direction in each panel of the cubed-sphere mesh
103 integer :: NeZ = 2 !< Number of finite element in the vertical direction in each MPI process
104 integer :: NLocalMeshPerPrc = 6 !< Number of local mesh per MPI process
105 integer :: Nprc = 1 !< Total number of MPI process
106 integer :: PolyOrder_h = 2 !< Polynomial order for the horizontal direction
107 integer :: PolyOrder_v = 2 !< Polynomial order for the z-direction
108 logical :: LumpedMassMatFlag = .false. !< Flag whether a mass lumping is applied
109
110 character(len=H_LONG) :: TOPO_IN_BASENAME = '' !< Basename of the input file
111 character(len=H_MID) :: TOPO_IN_VARNAME = 'topo' !< Variable name of topography in the input file
112 character(len=H_MID) :: VERTICAL_COORD_NAME = "TERRAIN_FOLLOWING" !< Type of the vertical coordinate
113
114 logical :: COMM_USE_MPI_PC = .false. !< Flag whether persistent communication is used in MPI
115 logical :: COMM_USE_MPI_PC_FUJITSU_EXT
116
117 character(len=H_SHORT) :: Element_operation_type = 'General' !< General or TensorProd3D
118 character(len=H_SHORT) :: SpMV_storage_format = 'ELL' !< CSR or ELL
119
120 namelist / param_atmos_mesh / &
121 shallow_atm_approx_flag, &
122 dom_zmin, dom_zmax, &
123 fz, isperiodicz, &
124 negx, negy, nez, nlocalmeshperprc, nprc, &
125 polyorder_h, polyorder_v, lumpedmassmatflag, &
126 element_operation_type, &
127 spmv_storage_format, &
128 vertical_coord_name, &
129 topo_in_basename, topo_in_varname, &
130 comm_use_mpi_pc, &
131 comm_use_mpi_pc_fujitsu_ext
132
133 integer :: k
134 logical :: is_spec_FZ
135
136 integer :: ierr
137 !-------------------------------------------
138
139 log_newline
140 log_info("ATMOS_MESH_setup",*) 'Setup'
141
142 fz(:) = -1.0_rp
143#ifdef __FUJITSU
144 comm_use_mpi_pc_fujitsu_ext = .true.
145#else
146 comm_use_mpi_pc_fujitsu_ext = .false.
147#endif
148
149 rewind(io_fid_conf)
150 read(io_fid_conf,nml=param_atmos_mesh,iostat=ierr)
151 if( ierr < 0 ) then !--- missing
152 log_info("ATMOS_MESH_setup",*) 'Not found namelist. Default used.'
153 elseif( ierr > 0 ) then !--- fatal error
154 log_error("ATMOS_MESH_setup",*) 'Not appropriate names in namelist PARAM_ATM_MESH. Check!'
155 call prc_abort
156 endif
157 log_nml(param_atmos_mesh)
158
159 !----
160
161 !- Setup the element
162
163 call this%element%Init( polyorder_h, polyorder_v, lumpedmassmatflag )
164 call this%element_v1D%Init( polyorder_v, lumpedmassmatflag )
165
166 !- Setup the mesh
167
168 is_spec_fz = .true.
169 do k=1, nez+1
170 if (fz(k) < 0.0_rp) then
171 is_spec_fz = .false.
172 end if
173 end do
174 if (is_spec_fz) then
175 call this%mesh%Init( &
176 negx, negy, nez, rplanet, dom_zmin, dom_zmax, &
177 this%element, nlocalmeshperprc, nproc=nprc, &
178 fz=fz(1:nez+1), shallow_approx=shallow_atm_approx_flag )
179 else
180 call this%mesh%Init( &
181 negx, negy, nez, rplanet, dom_zmin, dom_zmax, &
182 this%element, nlocalmeshperprc, nproc=nprc, &
183 shallow_approx=shallow_atm_approx_flag )
184 end if
185
186 call this%mesh%Generate()
187
188 !-
189
190 call this%AtmosMesh_Init( this%mesh )
191 call this%PrepairElementOperation( element_operation_type, spmv_storage_format )
192
193 !- Set topography & vertical coordinate
194
195 call this%Read_topography_file( topo_in_basename, topo_in_varname, this%mesh%mesh2D, dom_zmin )
196
197 this%vcoord_type_id = meshutil_get_vcoord_typeid( vertical_coord_name )
198 call this%Setup_vcoordinate()
199
200 !-
201 this%comm_use_mpi_pc = comm_use_mpi_pc
202 this%comm_use_mpi_pc_fujitsu_ext = comm_use_mpi_pc_fujitsu_ext
203
204 return
205 end subroutine atmosmeshgm_init
206
207 !> Finalize an object to manage computational mesh
208 !!
209!OCL SERIAL
210 subroutine atmosmeshgm_final(this)
211 implicit none
212
213 class(atmosmeshgm), intent(inout) :: this
214 integer :: commid
215 !-------------------------------------------
216
217 do commid=1, this%communicator_num
218 call this%comm_list(commid)%Final()
219 end do
220
221 call this%mesh%Final()
222 call this%AtmosMesh_Final()
223
224 return
225 end subroutine atmosmeshgm_final
226
227 !> Create a communicator for data communication on global computational domain
228 !!
229!OCL SERIAL
230 subroutine atmosmeshgm_create_communicator( this, sfield_num, hvfield_num, htensorfield_num, &
231 var_manager, field_list, commid, &
232 field_list_is, field_list_ie )
233 implicit none
234 class(atmosmeshgm), target, intent(inout) :: this
235 integer, intent(in) :: sfield_num !< Number of scalar fields
236 integer, intent(in) :: hvfield_num !< Number of horizontal vector fields
237 integer, intent(in) :: htensorfield_num !< Number of horizontal tensor fields
238 class(modelvarmanager), intent(inout) :: var_manager !< Object to manage variables
239 class(meshfield3d), intent(in) :: field_list(:) !< Array of 3D fields
240 integer, intent(out) :: commid !< Communicator ID
241 integer, intent(in), optional :: field_list_is !< Starting index of the field list for communication (optional)
242 integer, intent(in), optional :: field_list_ie !< Ending index of the field list for communication (optional)
243 !-----------------------------------------------------
244
245 commid = this%Get_communicatorID( atm_mesh_max_commnuicator_num )
246 call this%comm_list(commid)%Init( sfield_num, hvfield_num, htensorfield_num, this%mesh )
247 if ( this%comm_use_mpi_pc ) then
248 call this%comm_list(commid)%Prepare_PC( this%comm_use_mpi_pc_fujitsu_ext )
249 end if
250 call var_manager%MeshFieldComm_Prepare( this%comm_list(commid), field_list, field_list_is, field_list_ie )
251
252 return
253 end subroutine atmosmeshgm_create_communicator
254
255!OCL SERIAL
256 subroutine atmosmeshgm_setup_restartfile1( this, restart_file, var_num )
257 implicit none
258 class(atmosmeshgm), target, intent(inout) :: this
259 class(file_restart_meshfield_component), intent(inout) :: restart_file
260 integer, intent(in) :: var_num
261 !------------------------------------------------
262
263 call restart_file%Init('ATMOS', var_num, meshcubedsphere3d=this%mesh )
264 return
265 end subroutine atmosmeshgm_setup_restartfile1
266
267!OCL SERIAL
268 subroutine atmosmeshgm_setup_restartfile2( this, restart_file, &
269 in_basename, in_postfix_timelabel, &
270 out_basename, out_postfix_timelabel, &
271 out_dtype, out_title, var_num, dim_name_postfix )
272 implicit none
273 class(atmosmeshgm), target, intent(inout) :: this
274 class(file_restart_meshfield_component), intent(inout) :: restart_file
275 character(*), intent(in) :: in_basename
276 logical, intent(in) :: in_postfix_timelabel
277 character(*), intent(in) :: out_basename
278 logical, intent(in) :: out_postfix_timelabel
279 character(*), intent(in) :: out_title
280 character(*), intent(in) :: out_dtype
281 integer, intent(in) :: var_num
282 character(len=*), intent(in) :: dim_name_postfix
283 !-----------------------------------------------------------
284
285 call restart_file%Init('ATMOS', in_basename, in_postfix_timelabel, &
286 out_basename, out_postfix_timelabel, out_dtype, out_title, &
287 var_num, dim_name_postfix, &
288 meshcubedsphere3d=this%mesh )
289
290 end subroutine atmosmeshgm_setup_restartfile2
291
292!> Calculate horizontal vector components in longitude-latitude coordinates
293!OCL SERIAL
294 subroutine atmosmeshgm_calc_uvmet( this, U, V, &
295 Umet, Vmet )
296
297 use scale_cubedsphere_coord_cnv, only: &
299 implicit none
300 class(atmosmeshgm), target, intent(in) :: this
301 type(meshfield3d), intent(in) :: U
302 type(meshfield3d), intent(in) :: V
303 type(meshfield3d), intent(inout) :: Umet
304 type(meshfield3d), intent(inout) :: Vmet
305
306 integer :: n
307 integer :: ke, ke2D
308 type(localmesh3d), pointer :: lcmesh
309 class(elementbase3d), pointer :: elem
310 !------------------------------------------
311
312 do n=1, this%mesh%LOCAL_MESH_NUM
313 lcmesh => this%mesh%lcmesh_list(n)
314 elem => lcmesh%refElem3D
316 lcmesh%panelID, lcmesh%pos_en(:,:,1), lcmesh%pos_en(:,:,2), & ! (in)
317 lcmesh%gam, elem%Np * lcmesh%Ne, & ! (in)
318 u%local(n)%val(:,lcmesh%NeS:lcmesh%NeE), & ! (in)
319 v%local(n)%val(:,lcmesh%NeS:lcmesh%NeE), & ! (in)
320 umet%local(n)%val(:,lcmesh%NeS:lcmesh%NeE), & ! (out)
321 vmet%local(n)%val(:,lcmesh%NeS:lcmesh%NeE) ) ! (out)
322 end do
323
324 return
325 end subroutine atmosmeshgm_calc_uvmet
326
327!> Setup the vertical coordinate
328!OCL SERIAL
329 subroutine atmosmeshgm_setup_vcoordinate( this )
331 implicit none
332 class(atmosmeshgm), TARGET, INTENT(INOUT) :: this
333
334 type(meshfieldcommcubedspheredom3d) :: comm3D
335 type(meshfieldcommcubedspheredom2d) :: comm2D
336 !-------------------------------------------------
337
338 call comm2d%Init( 1, 0, 0, this%mesh%mesh2D )
339 call comm3d%Init( 2, 1, 0, this%mesh )
340
341 call this%topography%SetVCoordinate( this%ptr_mesh, &
342 this%vcoord_type_id, this%mesh%zmax_gl, comm3d, comm2d )
343
344 call comm2d%Final()
345 call comm3d%Final()
346
347 return
348 end SUBROUTINE atmosmeshgm_setup_vcoordinate
349
350end module mod_atmos_mesh_gm
module Atmosphere / Mesh
subroutine atmosmeshgm_init(this)
Initialize an object to manage computational mesh.
module Atmosphere / Mesh
integer, parameter, public atm_mesh_max_commnuicator_num
Module common / Coordinate conversion with cubed-sphere projection.
subroutine, public cubedspherecoordcnv_cs2lonlatvec(panelid, alpha, beta, gam, np, vecalpha, vecbeta, veclon, veclat, lat, gpu_async_id)
Convert the components of a vector in local coordinates with an equiangular gnomonic cubed-sphere pro...
module FElib / Element / Base
module FElib / Element / hexahedron
module FElib / Mesh / Local 3D
module FElib / Mesh / Base 2D
integer, public meshbase2d_dimtypeid_xy
module FElib / Mesh / Base 3D
module FElib / Mesh / Cubed-sphere 3D domain
module FElib / Data / base
module FElib / Data / Communication in 2D cubed-sphere domain
module FElib / Data / Communication in 3D cubed-sphere domain
module FElib / Mesh / utility for general vertical coordinate
integer function, public meshutil_get_vcoord_typeid(vcoord_type)
Get a type ID of vertical coordinate.
FElib / model framework / mesh manager.
FElib / model framework / variable manager.
Module common / sparsemat.
Derived type to manage a computational mesh (base class)
Derived type to manage a computational mesh of global atmospheric model.
Derived type representing a 3D reference element.
Derived type representing a hexahedral element.
Derived type to manage restart file with each component.
Derived type to manage a local 3D computational domain.
Derived type to manage a computational mesh (base type for 3D domain)
Derived type to manage a cubed-sphere 3D computational domain.
Derived type representing a field with 3D mesh.
Base derived type to manage data communication with 2D cubed-sphere domain.
Base derived type to manage data communication with 3D cubed-sphere domain.
Derived type to manage a sparse matrix.