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 )
83 use scale_mesh_base2d, only: &
84 mftype2d_xy => meshbase2d_dimtypeid_xy
85 use scale_meshutil_vcoord, only: &
87
88 implicit none
89 class(atmosmeshrm), target, intent(inout) :: this
90
91 real(RP) :: dom_xmin = 0.0_rp !< Minimum x-coordinate value of the computational domain
92 real(RP) :: dom_xmax = 100.0e3_rp !< Maximum x-coordinate value of the computational domain
93 real(RP) :: dom_ymin = 0.0_rp !< Minimum y-coordinate value of the computational domain
94 real(RP) :: dom_ymax = 100.0e3_rp !< Maximum y-coordinate value of the computational domain
95 real(RP) :: dom_zmin = 0.0_rp !< Minimum vertical coordinate value of the computational domain
96 real(RP) :: dom_zmax = 10.0e3_rp !< Maximum vertical coordinate value of the computational domain
97 logical :: isPeriodicX = .true. !< Flag whether a periodic boundary condition is applied in the x-direction
98 logical :: isPeriodicY = .true. !< Flag whether a periodic boundary condition is applied in the y-direction
99 logical :: isPeriodicZ = .false. !< Flag whether a periodic boundary condition is applied in the vertical direction
100
101 integer :: NeX = 2 !< Number of finite element in the x-direction in each MPI process
102 integer :: NeY = 2 !< Number of finite element in the y-direction in each MPI process
103 integer :: NeZ = 2 !< Number of finite element in the vertical direction in each MPI process
104 integer :: NprcX = 1 !< Number of MPI process in the x-direction
105 integer :: NprcY = 1 !< Number of MPI process in the y-direction
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' !< Storage format of sparse matrix (CSR or ELL)
119
120 integer, parameter :: ATMOS_MESH_NLocalMeshPerPrc = 1
121
122 integer, parameter :: FZ_nmax = 1000
123 real(RP) :: FZ(FZ_nmax) !< Values of the vertically computational coordinate at the element boundaries
124
125 namelist / param_atmos_mesh / &
126 dom_xmin, dom_xmax, &
127 dom_ymin, dom_ymax, &
128 dom_zmin, dom_zmax, &
129 fz, &
130 isperiodicx, isperiodicy, isperiodicz, &
131 nex, ney, nez, &
132 polyorder_h, polyorder_v, lumpedmassmatflag, &
133 element_operation_type, &
134 spmv_storage_format, &
135 nprcx, nprcy, &
136 topo_in_basename, topo_in_varname, &
137 vertical_coord_name, &
138 comm_use_mpi_pc, &
139 comm_use_mpi_pc_fujitsu_ext
140
141 integer :: k
142 logical :: is_spec_FZ
143
144 integer :: ierr
145 !-------------------------------------------
146
147 log_newline
148 log_info("ATMOS_MESH_setup",*) 'Setup'
149
150 fz(:) = -1.0_rp
151#ifdef __FUJITSU
152 comm_use_mpi_pc_fujitsu_ext = .true.
153#else
154 comm_use_mpi_pc_fujitsu_ext = .false.
155#endif
156
157 rewind(io_fid_conf)
158 read(io_fid_conf,nml=param_atmos_mesh,iostat=ierr)
159 if( ierr < 0 ) then !--- missing
160 log_info("ATMOS_MESH_setup",*) 'Not found namelist. Default used.'
161 elseif( ierr > 0 ) then !--- fatal error
162 log_error("ATMOS_MESH_setup",*) 'Not appropriate names in namelist PARAM_ATM_MESH. Check!'
163 call prc_abort
164 endif
165 log_nml(param_atmos_mesh)
166
167 !----
168
169 ! Setup the element
170
171 call this%element%Init( polyorder_h, polyorder_v, lumpedmassmatflag )
172 call this%element_v1D%Init( polyorder_v, lumpedmassmatflag )
173
174 ! Setup the mesh
175
176 is_spec_fz = .true.
177 do k=1, nez+1
178 if (fz(k) < 0.0_rp) then
179 is_spec_fz = .false.
180 end if
181 end do
182 if (is_spec_fz) then
183 call this%mesh%Init( &
184 nprcx*nex, nprcy*ney, nez, &
185 dom_xmin, dom_xmax,dom_ymin, dom_ymax, dom_zmin, dom_zmax, &
186 isperiodicx, isperiodicy, isperiodicz, &
187 this%element, atmos_mesh_nlocalmeshperprc, nprcx, nprcy, &
188 fz=fz(1:nez+1) )
189 else
190 call this%mesh%Init( &
191 nprcx*nex, nprcy*ney, nez, &
192 dom_xmin, dom_xmax,dom_ymin, dom_ymax, dom_zmin, dom_zmax, &
193 isperiodicx, isperiodicy, isperiodicz, &
194 this%element, atmos_mesh_nlocalmeshperprc, nprcx, nprcy )
195 end if
196
197 call this%mesh%Generate()
198
199 !-
200 call this%AtmosMesh_Init( this%mesh )
201 call this%PrepairElementOperation( element_operation_type, spmv_storage_format )
202
203 !- Set topography & vertical coordinate
204
205 call this%Read_topography_file( topo_in_basename, topo_in_varname, this%mesh%mesh2D, dom_zmin )
206
207 this%vcoord_type_id = meshutil_get_vcoord_typeid( vertical_coord_name )
208 call this%Setup_vcoordinate()
209
210 !-
211 this%comm_use_mpi_pc = comm_use_mpi_pc
212 this%comm_use_mpi_pc_fujitsu_ext = comm_use_mpi_pc_fujitsu_ext
213
214 return
215 end subroutine atmosmeshrm_init
216
217 !> Finalize an object to manage computational mesh
218 !!
219 subroutine atmosmeshrm_final(this)
220 implicit none
221
222 class(atmosmeshrm), intent(inout) :: this
223 integer :: commid
224 !-------------------------------------------
225
226 do commid=1, this%communicator_num
227 call this%comm_list(commid)%Final()
228 end do
229
230 call this%mesh%Final()
231 call this%AtmosMesh_Final()
232
233 return
234 end subroutine atmosmeshrm_final
235
236 !> Create a communicator for data communication on regional computational domain
237 !!
238 subroutine atmosmeshrm_create_communicator( this, sfield_num, hvfield_num, htensorfield_num, &
239 var_manager, field_list, commid, &
240 field_list_is, field_list_ie )
241 implicit none
242 class(atmosmeshrm), target, intent(inout) :: this
243 integer, intent(in) :: sfield_num !< Number of scalar fields
244 integer, intent(in) :: hvfield_num !< Number of horizontal vector fields
245 integer, intent(in) :: htensorfield_num !< Number of horizontal tensor fields
246 class(modelvarmanager), intent(inout) :: var_manager !< Object to manage variables
247 class(meshfield3d), intent(in) :: field_list(:) !< Array of 3D fields
248 integer, intent(out) :: commid !< Communicator ID
249 integer, intent(in), optional :: field_list_is !< Starting index of the field list for communication (optional)
250 integer, intent(in), optional :: field_list_ie !< Ending index of the field list for communication (optional)
251 !-----------------------------------------------------
252
253 commid = this%Get_communicatorID( atm_mesh_max_commnuicator_num )
254 call this%comm_list(commid)%Init( sfield_num, hvfield_num, htensorfield_num, this%mesh )
255 if ( this%comm_use_mpi_pc ) then
256 call this%comm_list(commid)%Prepare_PC( this%comm_use_mpi_pc_fujitsu_ext )
257 end if
258 call var_manager%MeshFieldComm_Prepare( this%comm_list(commid), field_list, field_list_is, field_list_ie )
259
260 return
261 end subroutine atmosmeshrm_create_communicator
262
263 subroutine atmosmeshrm_setup_restartfile1( this, restart_file, var_num )
264 implicit none
265 class(atmosmeshrm), target, intent(inout) :: this
266 class(file_restart_meshfield_component), intent(inout) :: restart_file
267 integer, intent(in) :: var_num
268 !------------------------------------------------
269
270 call restart_file%Init('ATMOS', var_num, mesh3d=this%mesh )
271 return
272 end subroutine atmosmeshrm_setup_restartfile1
273
274 subroutine atmosmeshrm_setup_restartfile2( this, restart_file, &
275 in_basename, in_postfix_timelabel, &
276 out_basename, out_postfix_timelabel, &
277 out_dtype, out_title, var_num, dim_name_postfix )
278 implicit none
279 class(atmosmeshrm), target, intent(inout) :: this
280 class(file_restart_meshfield_component), intent(inout) :: restart_file
281 character(*), intent(in) :: in_basename
282 logical, intent(in) :: in_postfix_timelabel
283 character(*), intent(in) :: out_basename
284 logical, intent(in) :: out_postfix_timelabel
285 character(*), intent(in) :: out_title
286 character(*), intent(in) :: out_dtype
287 integer, intent(in) :: var_num
288 character(len=*), intent(in) :: dim_name_postfix
289 !-----------------------------------------------------------
290
291 call restart_file%Init('ATMOS', in_basename, in_postfix_timelabel, &
292 out_basename, out_postfix_timelabel, out_dtype, out_title, &
293 var_num, dim_name_postfix, &
294 mesh3d=this%mesh )
295
296 return
297 end subroutine atmosmeshrm_setup_restartfile2
298
299 subroutine atmosmeshrm_calc_uvmet( this, U, V, &
300 Umet, Vmet )
301 implicit none
302 class(atmosmeshrm), target, intent(in) :: this
303 type(meshfield3d), intent(in) :: U
304 type(meshfield3d), intent(in) :: V
305 type(meshfield3d), intent(inout) :: Umet
306 type(meshfield3d), intent(inout) :: Vmet
307
308 integer :: n
309 integer :: ke
310 type(localmesh3d), pointer :: lcmesh
311 !------------------------------------------
312
313 do n=1, this%mesh%LOCAL_MESH_NUM
314 lcmesh => this%mesh%lcmesh_list(n)
315 !$omp parallel do
316 do ke=lcmesh%NeS, lcmesh%NeE
317 umet%local(n)%val(:,ke) = u%local(n)%val(:,ke)
318 vmet%local(n)%val(:,ke) = v%local(n)%val(:,ke)
319 end do
320 end do
321
322 return
323 end subroutine atmosmeshrm_calc_uvmet
324
325!> Setup the vertical coordinate
326 subroutine atmosmeshrm_setup_vcoordinate( this )
328 implicit none
329 class(atmosmeshrm), TARGET, INTENT(INOUT) :: this
330
331 type(meshfieldcommcubedom3d) :: comm3D
332 type(meshfieldcommrectdom2d) :: comm2D
333 !-------------------------------------------------
334
335 call comm2d%Init( 1, 0, 0, this%mesh%mesh2D )
336 call comm3d%Init( 2, 1, 0, this%mesh )
337
338 call this%topography%SetVCoordinate( this%ptr_mesh, &
339 this%vcoord_type_id, this%mesh%zmax_gl, comm3d, comm2d )
340
341 call comm2d%Final()
342 call comm3d%Final()
343
344 return
345 end SUBROUTINE atmosmeshrm_setup_vcoordinate
346
347end 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)
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 regional 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 cubic 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.