FE-Project
Loading...
Searching...
No Matches
mod_atmos_mesh_rm.F90
Go to the documentation of this file.
1!-------------------------------------------------------------------------------
2!> module Atmosphere / Mesh
3!!
4!! @par Description
5!! Module for mesh with atmospheric regional 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 regional atmospheric model
46 !!
47 type, extends(atmosmesh), public :: atmosmeshrm
48 type(meshcubedom3d) :: mesh !< Object to manage a cubic computational mesh
49 type(meshfieldcommcubedom3d) :: comm_list(atm_mesh_max_commnuicator_num) !< Object to manage data communication on a cubic computational mesh
50 contains
51 procedure :: init => atmosmeshrm_init
52 procedure :: final => atmosmeshrm_final
53 procedure :: create_communicator => atmosmeshrm_create_communicator
54 procedure :: setup_restartfile1 => atmosmeshrm_setup_restartfile1
55 procedure :: setup_restartfile2 => atmosmeshrm_setup_restartfile2
56 procedure :: calc_uvmet => atmosmeshrm_calc_uvmet
57 procedure :: setup_vcoordinate => atmosmeshrm_setup_vcoordinate
58 end type atmosmeshrm
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 !- AtmosMesh RM -----------------------------------------
79
80 !> Initialize an object to manage computational mesh
81 !!
82 subroutine atmosmeshrm_init( this )
84 use scale_mesh_base2d, only: &
85 mftype2d_xy => meshbase2d_dimtypeid_xy
86 use scale_meshutil_vcoord, only: &
88
89 implicit none
90 class(atmosmeshrm), target, intent(inout) :: this
91
92 real(RP) :: dom_xmin = 0.0_rp !< Minimum x-coordinate value of the computational domain
93 real(RP) :: dom_xmax = 100.0e3_rp !< Maximum x-coordinate value of the computational domain
94 real(RP) :: dom_ymin = 0.0_rp !< Minimum y-coordinate value of the computational domain
95 real(RP) :: dom_ymax = 100.0e3_rp !< Maximum y-coordinate value of the computational domain
96 real(RP) :: dom_zmin = 0.0_rp !< Minimum vertical coordinate value of the computational domain
97 real(RP) :: dom_zmax = 10.0e3_rp !< Maximum vertical coordinate value of the computational domain
98 logical :: isPeriodicX = .true. !< Flag whether a periodic boundary condition is applied in the x-direction
99 logical :: isPeriodicY = .true. !< Flag whether a periodic boundary condition is applied in the y-direction
100 logical :: isPeriodicZ = .false. !< Flag whether a periodic boundary condition is applied in the vertical direction
101
102 integer :: NeX = 2 !< Number of finite element in the x-direction in each MPI process
103 integer :: NeY = 2 !< Number of finite element in the y-direction in each MPI process
104 integer :: NeZ = 2 !< Number of finite element in the vertical direction in each MPI process
105 integer :: NprcX = 1 !< Number of MPI process in the x-direction
106 integer :: NprcY = 1 !< Number of MPI process in the y-direction
107 integer :: PolyOrder_h = 2 !< Polynomial order for the horizontal direction
108 integer :: PolyOrder_v = 2 !< Polynomial order for the z-direction
109 logical :: LumpedMassMatFlag = .false. !< Flag whether a mass lumping is applied
110
111 character(len=H_LONG) :: TOPO_IN_BASENAME = '' !< Basename of the input file
112 character(len=H_MID) :: TOPO_IN_VARNAME = 'topo' !< Variable name of topography in the input file
113 character(len=H_MID) :: VERTICAL_COORD_NAME = "TERRAIN_FOLLOWING" !< Type of the vertical coordinate
114
115 logical :: COMM_USE_MPI_PC = .false. !< Flag whether persistent communication is used in MPI
116 logical :: COMM_USE_MPI_PC_FUJITSU_EXT
117
118 character(len=H_SHORT) :: Element_operation_type = 'General' !< General or TensorProd3D
119 character(len=H_SHORT) :: SpMV_storage_format = 'ELL' !< Storage format of sparse matrix (CSR or ELL)
120
121 integer, parameter :: ATMOS_MESH_NLocalMeshPerPrc = 1
122
123 integer, parameter :: FZ_nmax = 1000
124 real(RP) :: FZ(FZ_nmax) !< Values of the vertically computational coordinate at the element boundaries
125
126 namelist / param_atmos_mesh / &
127 dom_xmin, dom_xmax, &
128 dom_ymin, dom_ymax, &
129 dom_zmin, dom_zmax, &
130 fz, &
131 isperiodicx, isperiodicy, isperiodicz, &
132 nex, ney, nez, &
133 polyorder_h, polyorder_v, lumpedmassmatflag, &
134 element_operation_type, &
135 spmv_storage_format, &
136 nprcx, nprcy, &
137 topo_in_basename, topo_in_varname, &
138 vertical_coord_name, &
139 comm_use_mpi_pc, &
140 comm_use_mpi_pc_fujitsu_ext
141
142 integer :: k
143 logical :: is_spec_FZ
144
145 integer :: ierr
146
147 type(file_base_meshfield) :: file_topo
148 !-------------------------------------------
149
150 log_newline
151 log_info("ATMOS_MESH_setup",*) 'Setup'
152
153 fz(:) = -1.0_rp
154#ifdef __FUJITSU
155 comm_use_mpi_pc_fujitsu_ext = .true.
156#else
157 comm_use_mpi_pc_fujitsu_ext = .false.
158#endif
159
160 rewind(io_fid_conf)
161 read(io_fid_conf,nml=param_atmos_mesh,iostat=ierr)
162 if( ierr < 0 ) then !--- missing
163 log_info("ATMOS_MESH_setup",*) 'Not found namelist. Default used.'
164 elseif( ierr > 0 ) then !--- fatal error
165 log_error("ATMOS_MESH_setup",*) 'Not appropriate names in namelist PARAM_ATM_MESH. Check!'
166 call prc_abort
167 endif
168 log_nml(param_atmos_mesh)
169
170 !----
171
172 ! Setup the element
173
174 call this%element%Init( polyorder_h, polyorder_v, lumpedmassmatflag )
175 call this%element_v1D%Init( polyorder_v, lumpedmassmatflag )
176
177 ! Setup the mesh
178
179 is_spec_fz = .true.
180 do k=1, nez+1
181 if (fz(k) < 0.0_rp) then
182 is_spec_fz = .false.
183 end if
184 end do
185 if (is_spec_fz) then
186 call this%mesh%Init( &
187 nprcx*nex, nprcy*ney, nez, &
188 dom_xmin, dom_xmax,dom_ymin, dom_ymax, dom_zmin, dom_zmax, &
189 isperiodicx, isperiodicy, isperiodicz, &
190 this%element, atmos_mesh_nlocalmeshperprc, nprcx, nprcy, &
191 fz=fz(1:nez+1) )
192 else
193 call this%mesh%Init( &
194 nprcx*nex, nprcy*ney, nez, &
195 dom_xmin, dom_xmax,dom_ymin, dom_ymax, dom_zmin, dom_zmax, &
196 isperiodicx, isperiodicy, isperiodicz, &
197 this%element, atmos_mesh_nlocalmeshperprc, nprcx, nprcy )
198 end if
199
200 call this%mesh%Generate()
201
202 !-
203 call this%AtmosMesh_Init( this%mesh )
204 call this%PrepairElementOperation( element_operation_type, spmv_storage_format )
205
206 !- Set topography & vertical coordinate
207
208 if ( topo_in_basename /= '' ) then
209 log_info("ATMOS_MESH_setup",*) 'Read topography data'
210
211 call file_topo%Init(1, mesh2d=this%mesh%mesh2D )
212 call file_topo%Open( topo_in_basename, myrank=prc_myrank )
213 call file_topo%Read_Var( mftype2d_xy, topo_in_varname, this%topography%topo )
214 call file_topo%Close()
215 call file_topo%Final()
216 end if
217
218 this%vcoord_type_id = meshutil_get_vcoord_typeid( vertical_coord_name )
219 call this%Setup_vcoordinate()
220
221 !-
222 this%comm_use_mpi_pc = comm_use_mpi_pc
223 this%comm_use_mpi_pc_fujitsu_ext = comm_use_mpi_pc_fujitsu_ext
224
225 return
226 end subroutine atmosmeshrm_init
227
228 !> Finalize an object to manage computational mesh
229 !!
230 subroutine atmosmeshrm_final(this)
231 implicit none
232
233 class(atmosmeshrm), intent(inout) :: this
234 integer :: commid
235 !-------------------------------------------
236
237 do commid=1, this%communicator_num
238 call this%comm_list(commid)%Final()
239 end do
240
241 call this%mesh%Final()
242 call this%AtmosMesh_Final()
243
244 return
245 end subroutine atmosmeshrm_final
246
247 !> Create a communicator for data communication on regional computational domain
248 !!
249 subroutine atmosmeshrm_create_communicator( this, sfield_num, hvfield_num, htensorfield_num, &
250 var_manager, field_list, commid )
251 implicit none
252 class(atmosmeshrm), target, intent(inout) :: this
253 integer, intent(in) :: sfield_num !< Number of scalar fields
254 integer, intent(in) :: hvfield_num !< Number of horizontal vector fields
255 integer, intent(in) :: htensorfield_num !< Number of horizontal tensor fields
256 class(modelvarmanager), intent(inout) :: var_manager !< Object to manage variables
257 class(meshfield3d), intent(in) :: field_list(:) !< Array of 3D fields
258 integer, intent(out) :: commid !< Communicator ID
259 !-----------------------------------------------------
260
261 commid = this%Get_communicatorID( atm_mesh_max_commnuicator_num )
262 call this%comm_list(commid)%Init( sfield_num, hvfield_num, htensorfield_num, this%mesh )
263 if ( this%comm_use_mpi_pc ) then
264 call this%comm_list(commid)%Prepare_PC( this%comm_use_mpi_pc_fujitsu_ext )
265 end if
266 call var_manager%MeshFieldComm_Prepare( this%comm_list(commid), field_list )
267
268 return
269 end subroutine atmosmeshrm_create_communicator
270
271 subroutine atmosmeshrm_setup_restartfile1( this, restart_file, var_num )
272 implicit none
273 class(atmosmeshrm), target, intent(inout) :: this
274 class(file_restart_meshfield_component), intent(inout) :: restart_file
275 integer, intent(in) :: var_num
276 !------------------------------------------------
277
278 call restart_file%Init('ATMOS', var_num, mesh3d=this%mesh )
279 return
280 end subroutine atmosmeshrm_setup_restartfile1
281
282 subroutine atmosmeshrm_setup_restartfile2( this, restart_file, &
283 in_basename, in_postfix_timelabel, &
284 out_basename, out_postfix_timelabel, &
285 out_dtype, out_title, var_num )
286 implicit none
287 class(atmosmeshrm), target, intent(inout) :: this
288 class(file_restart_meshfield_component), intent(inout) :: restart_file
289 character(*), intent(in) :: in_basename
290 logical, intent(in) :: in_postfix_timelabel
291 character(*), intent(in) :: out_basename
292 logical, intent(in) :: out_postfix_timelabel
293 character(*), intent(in) :: out_title
294 character(*), intent(in) :: out_dtype
295 integer, intent(in) :: var_num
296 !-----------------------------------------------------------
297
298 call restart_file%Init('ATMOS', in_basename, in_postfix_timelabel, &
299 out_basename, out_postfix_timelabel, out_dtype, out_title, var_num, &
300 mesh3d=this%mesh )
301
302 return
303 end subroutine atmosmeshrm_setup_restartfile2
304
305 subroutine atmosmeshrm_calc_uvmet( this, U, V, &
306 Umet, Vmet )
307 implicit none
308 class(atmosmeshrm), target, intent(in) :: this
309 type(meshfield3d), intent(in) :: U
310 type(meshfield3d), intent(in) :: V
311 type(meshfield3d), intent(inout) :: Umet
312 type(meshfield3d), intent(inout) :: Vmet
313
314 integer :: n
315 integer :: ke
316 type(localmesh3d), pointer :: lcmesh
317 !------------------------------------------
318
319 do n=1, this%mesh%LOCAL_MESH_NUM
320 lcmesh => this%mesh%lcmesh_list(n)
321 !$omp parallel do
322 do ke=lcmesh%NeS, lcmesh%NeE
323 umet%local(n)%val(:,ke) = u%local(n)%val(:,ke)
324 vmet%local(n)%val(:,ke) = v%local(n)%val(:,ke)
325 end do
326 end do
327
328 return
329 end subroutine atmosmeshrm_calc_uvmet
330
331!> Setup the vertical coordinate
332 subroutine atmosmeshrm_setup_vcoordinate( this )
334 implicit none
335 class(atmosmeshrm), TARGET, INTENT(INOUT) :: this
336
337 type(meshfieldcommcubedom3d) :: comm3D
338 type(meshfieldcommrectdom2d) :: comm2D
339 !-------------------------------------------------
340
341 call comm2d%Init( 1, 0, 0, this%mesh%mesh2D )
342 call comm3d%Init( 2, 1, 0, this%mesh )
343
344 call this%topography%SetVCoordinate( this%ptr_mesh, &
345 this%vcoord_type_id, this%mesh%zmax_gl, comm3d, comm2d )
346
347 call comm2d%Final()
348 call comm3d%Final()
349
350 return
351 end SUBROUTINE atmosmeshrm_setup_vcoordinate
352
353end module mod_atmos_mesh_rm
module Atmosphere / Mesh
subroutine atmosmeshrm_init(this)
Initialize an object to manage computational mesh.
module Atmosphere / Mesh
integer, parameter, public atm_mesh_max_commnuicator_num
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 / Cubic 3D domain
module FElib / Data / base
module FElib / Data / Communication 3D cubic domain
module FElib / Data / Communication 2D rectangle domain
module FElib / Mesh / utility for general vertical coordinate
integer function, public meshutil_get_vcoord_typeid(vcoord_type)
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 regional atmospheric model.
Derived type representing a 3D reference element.
Derived type representing a hexahedral element.
Derived type to manage a local 3D computational domain.
Derived type representing a field with 3D mesh.
Base derived type to manage data communication with 3D cubic domain.
Base derived type to manage data communication with 2D rectangle domain.
Derived type to manage a sparse matrix.