8 use fckit_configuration_module,
only: fckit_configuration
9 use fckit_mpi_module,
only: fckit_mpi_comm, fckit_mpi_sum
10 use fckit_log_module,
only: fckit_log
14 use kinds,
only: kind_real
15 use oops_variables_mod,
only: oops_variables
18 use dcmip_initial_conditions_test_1_2_3,
only : test1_advection_deformation, &
19 test1_advection_hadley, test3_gravity_wave
20 use dcmip_initial_conditions_test_4,
only : test4_baroclinic_wave
28 use mpas_derived_types
29 use mpas_field_routines
30 use mpas_kind_types,
only: strkind
31 use mpas_pool_routines
32 use mpas_dmpar,
only: mpas_dmpar_exch_halo_field
71 character(len=StrKIND) :: kind_op
74 type (mpas_pool_type),
pointer :: state, diag, mesh
75 type (field2dreal),
pointer :: fld2d_pb, fld2d_u, fld2d_u_inc, fld2d_urm, fld2d_urz
76 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_qv, ptrr2_sh
77 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_p, ptrr2_rho, ptrr2_t, ptrr2_th, ptrr2_pp
78 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_ps
83 if (self%geom%nCells==increment%geom%nCells .and. self%geom%nVertLevels==increment%geom%nVertLevels)
then
86 call da_operator(trim(kind_op), self%subFields, increment%subFields, fld_select = increment%fldnames_ci)
94 ngrid = self%geom%nCellsSolve
99 increment%has(
'spechum') .and. .not.increment%has(
'qv'))
then
100 call self%get(
'qv', ptrr2_qv)
101 call self%get(
'spechum', ptrr2_sh)
102 call q_to_w( ptrr2_sh(:,1:ngrid), ptrr2_qv(:,1:ngrid) )
112 call self%get(
'qv', ptrr2_qv)
113 call self%get(
'pressure', ptrr2_p)
114 call self%get(
'rho', ptrr2_rho)
115 call self%get(
'surface_pressure', ptrr1_ps)
116 call self%get(
'temperature', ptrr2_t)
117 call self%get(
'theta', ptrr2_th)
120 ptrr2_t(:,1:ngrid), ptrr2_qv(:,1:ngrid), ptrr1_ps(1:ngrid), &
121 ptrr2_p(:,1:ngrid), ptrr2_rho(:,1:ngrid), ptrr2_th(:,1:ngrid) )
125 if ( self%has(
'pressure_p') .and. self%has(
'pressure') .and. &
126 .not.increment%has(
'pressure_p') )
then
127 call self%get(
'pressure', ptrr2_p)
128 call self%get(
'pressure_p', ptrr2_pp)
129 call mpas_pool_get_field(self%geom%domain%blocklist%allFields,
'pressure_base', fld2d_pb)
130 ptrr2_pp(:,1:ngrid) = ptrr2_p(:,1:ngrid) - fld2d_pb%array(:,1:ngrid)
135 if ( self%has(
'u') .and. &
137 .not.increment%has(
'u') )
then
138 call mpas_pool_get_field(self%subFields,
'u', fld2d_u)
139 call mpas_pool_get_field(increment%subFields,
'uReconstructMeridional', fld2d_urm)
140 call mpas_pool_get_field(increment%subFields,
'uReconstructZonal', fld2d_urz)
142 call mpas_duplicate_field(fld2d_u, fld2d_u_inc)
144 call mpas_dmpar_exch_halo_field(fld2d_urz)
145 call mpas_dmpar_exch_halo_field(fld2d_urm)
146 call uv_cell_to_edges(self%geom%domain, fld2d_urz, fld2d_urm, fld2d_u_inc, &
147 self%geom%lonCell, self%geom%latCell, self%geom%nCells, &
148 self%geom%edgeNormalVectors, self%geom%nEdgesOnCell, self%geom%edgesOnCell, &
149 self%geom%nVertLevels)
150 ngrid = self%geom%nEdgesSolve
151 fld2d_u%array(:,1:ngrid) = fld2d_u%array(:,1:ngrid) + fld2d_u_inc%array(:,1:ngrid)
154 call mpas_deallocate_field( fld2d_u_inc )
157 call abor1_ftn(
"mpas_state:add_incr: dimension mismatch")
197 type(
mpas_geom),
target,
intent(in) :: geom
198 type(fckit_configuration),
intent(in) :: f_conf
199 type(datetime),
intent(inout) :: vdate
201 character(len=:),
allocatable :: str
202 character(len=30) :: ic
203 character(len=20) :: sdate
204 character(len=1024) :: buf
207 real(kind=kind_real) :: rlat, rlon, z
208 real(kind=kind_real) :: pk,pe1,pe2,ps
209 real(kind=kind_real) :: u0,v0,w0,t0,phis0,ps0,rho0,hum0,q1,q2,q3,q4
211 real(kind=kind_real) :: dtdummy = 900.0
212 logical,
allocatable :: grids_on_this_pe(:)
213 integer :: p_split = 1
214 real (kind=kind_real),
dimension(:,:),
pointer :: &
215 u_ptr, v_ptr, temperature_ptr, p_ptr, &
216 qv_ptr, qc_ptr, qr_ptr, qi_ptr, qs_ptr, &
218 real(kind=kind_real),
dimension(:),
pointer :: ps_ptr
219 integer,
pointer :: index_qv, index_qc, index_qr, index_qi, index_qs
220 type (field3dreal),
pointer :: field3d
221 type (mpas_pool_type),
pointer :: pool_a, pool_b, state
222 real(kind=kind_real) :: zhalf
227 If (f_conf%has(
"analytic_init"))
Then
228 call f_conf%get_or_die(
"analytic_init",str)
234 call fckit_log%info (
"mpas_state:analytic_init: "//ic)
238 call f_conf%get_or_die(
"date",str)
240 call fckit_log%info (
"validity date is: "//sdate)
242 call datetime_set(sdate, vdate)
250 call mpas_pool_get_subpool(geom % domain % blocklist % structs, &
253 pool_a => geom % domain % blocklist % allFields
256 call mpas_pool_get_array(pool_a,
"pressure", p_ptr)
257 call mpas_pool_get_array(pool_a,
"uReconstructZonal", u_ptr)
258 call mpas_pool_get_array(pool_a,
"uReconstructMeridional", v_ptr)
259 call mpas_pool_get_array(pool_a,
"temperature", temperature_ptr)
260 call mpas_pool_get_array(pool_a,
"surface_pressure", ps_ptr)
264 call mpas_pool_get_field(pool_a,
"scalars", field3d)
265 call mpas_pool_get_dimension(state,
"index_qv", index_qv)
266 if ( index_qv .gt. 0 ) &
267 qv_ptr => field3d % array(index_qv,:,:)
269 call mpas_pool_get_dimension(state,
"index_qc", index_qc)
270 if ( index_qc .gt. 0 ) &
271 qc_ptr => field3d % array(index_qc,:,:)
273 call mpas_pool_get_dimension(state,
"index_qr", index_qr)
274 if ( index_qr .gt. 0 ) &
275 qr_ptr => field3d % array(index_qr,:,:)
277 call mpas_pool_get_dimension(state,
"index_qi", index_qi)
278 if ( index_qi .gt. 0 ) &
279 qi_ptr => field3d % array(index_qi,:,:)
281 call mpas_pool_get_dimension(state,
"index_qs", index_qs)
282 if ( index_qs .gt. 0 ) &
283 qs_ptr => field3d % array(index_qs,:,:)
286 int_option:
Select Case (ic)
326 Case (
"dcmip-test-1-1")
327 do ii = 1, geom%nCellsSolve
328 rlat = geom%latCell(ii)
329 rlon = geom%lonCell(ii)
332 do jlev = 1, geom%nVertLevels
335 Call test1_advection_deformation(rlon,rlat,pk,zhalf,1,u0,v0,w0,t0,&
336 phis0,ps0,rho0,hum0,q1,q2,q3,q4)
342 if (index_qv.gt.0) qv_ptr(jlev,ii) = hum0
343 if (index_qc.gt.0) qc_ptr(jlev,ii) = q1
344 if (index_qi.gt.0) qi_ptr(jlev,ii) = q2
345 if (index_qr.gt.0) qr_ptr(jlev,ii) = q3
346 if (index_qs.gt.0) qs_ptr(jlev,ii) = q4
348 temperature_ptr(jlev,ii) = t0
353 Case (
"dcmip-test-1-2")
355 do ii = 1, geom%nCellsSolve
356 rlat = geom%latCell(ii)
357 rlon = geom%lonCell(ii)
360 do jlev = 1, geom%nVertLevels
363 Call test1_advection_hadley(rlon,rlat,pk,zhalf,1,u0,v0,w0,&
364 t0,phis0,ps0,rho0,hum0,q1)
370 if (index_qv.gt.0) qv_ptr(jlev,ii) = hum0
371 if (index_qc.gt.0) qc_ptr(jlev,ii) = q1
373 if (index_qi.gt.0) qi_ptr(jlev,ii) = 0._kind_real
374 if (index_qr.gt.0) qr_ptr(jlev,ii) = 0._kind_real
375 if (index_qs.gt.0) qs_ptr(jlev,ii) = 0._kind_real
377 temperature_ptr(jlev,ii) = t0
382 Case (
"dcmip-test-3-1")
384 do ii = 1, geom%nCellsSolve
385 rlat = geom%latCell(ii)
386 rlon = geom%lonCell(ii)
389 do jlev = 1, geom%nVertLevels
392 Call test3_gravity_wave(rlon,rlat,pk,zhalf,1,u0,v0,w0,&
393 t0,phis0,ps0,rho0,hum0)
400 if (index_qv.gt.0) qv_ptr(jlev,ii) = hum0
401 if (index_qc.gt.0) qc_ptr(jlev,ii) = 0._kind_real
402 if (index_qi.gt.0) qi_ptr(jlev,ii) = 0._kind_real
403 if (index_qr.gt.0) qr_ptr(jlev,ii) = 0._kind_real
404 if (index_qs.gt.0) qs_ptr(jlev,ii) = 0._kind_real
406 temperature_ptr(jlev,ii) = t0
411 Case (
"dcmip-test-4-0")
413 do ii = 1, geom%nCellsSolve
414 rlat = geom%latCell(ii)
415 rlon = geom%lonCell(ii)
418 do jlev = 1, geom%nVertLevels
421 Call test4_baroclinic_wave(0,
mpas_jedi_one_kr,rlon,rlat,pk,zhalf,1,u0,v0,w0,&
422 t0,phis0,ps0,rho0,hum0,q1,q2)
431 if (index_qv.gt.0) qv_ptr(jlev,ii) = hum0
432 if (index_qc.gt.0) qc_ptr(jlev,ii) = 0._kind_real
433 if (index_qi.gt.0) qi_ptr(jlev,ii) = 0._kind_real
434 if (index_qr.gt.0) qr_ptr(jlev,ii) = 0._kind_real
435 if (index_qs.gt.0) qs_ptr(jlev,ii) = 0._kind_real
437 temperature_ptr(jlev,ii) = t0
446 End Select int_option
450 call fckit_log%debug (
'==> end mpas_state:analytic_init')
461 type(fckit_configuration),
intent(in) :: f_conf
462 real (kind=kind_real),
dimension(:,:),
pointer :: r2d_ptr_a, r2d_ptr_b
463 real (kind=kind_real),
dimension(:),
pointer :: r1d_ptr_a, r1d_ptr_b
465 type (mpas_pool_type),
pointer :: pool_a, state
466 type (field3dreal),
pointer :: field3d
467 integer,
pointer :: index_qv
471 call mpas_pool_get_subpool(self % geom % domain % blocklist % structs, &
473 pool_a => self % geom % domain % blocklist % allFields
477 call mpas_pool_get_array(pool_a,
"uReconstructZonal", r2d_ptr_a)
478 do jlev = 1,self % geom % nVertLevels
479 do ii = 1, self % geom % nCellsSolve
480 r2d_ptr_a(jlev,ii) = cos(0.25*self % geom % lonEdge(ii)) + cos(0.25*self % geom % latEdge(ii))
485 call mpas_pool_get_array(pool_a,
"uReconstructMeridional", r2d_ptr_a)
486 do jlev = 1,self % geom % nVertLevels
487 do ii = 1, self % geom % nCellsSolve
493 call mpas_pool_get_array(pool_a,
"temperature", r2d_ptr_a)
494 do jlev = 1,self % geom % nVertLevels
495 do ii = 1, self % geom % nCellsSolve
496 r2d_ptr_a(jlev,ii) = cos(0.25*self % geom % lonCell(ii)) + cos(0.25*self % geom % latCell(ii))
501 call mpas_pool_get_array(pool_a,
"pressure", r2d_ptr_a)
502 do jlev = 1,self % geom % nVertLevels
503 do ii = 1, self % geom % nCellsSolve
504 r2d_ptr_a(jlev,ii) = real(jlev,kind_real)
509 call mpas_pool_get_array(pool_a,
"surface_pressure", r1d_ptr_a)
510 do ii = 1, self % geom % nCellsSolve
515 call mpas_pool_get_field(pool_a,
'scalars', field3d)
516 call mpas_pool_get_dimension(state,
'index_qv', index_qv)
517 if ( index_qv .gt. 0 )
then
518 r2d_ptr_a => field3d % array(index_qv,:,:)
519 do jlev = 1,self % geom % nVertLevels
520 do ii = 1, self % geom % nCellsSolve
elemental subroutine, public q_to_w(specific_humidity, mixing_ratio)
subroutine, public hydrostatic_balance(ncells, nlevels, zw, t, qv, ps, p, rho, theta)
subroutine, public da_posdef(pool_a, fld_select)
Performs A = max(0.,A) for pool A.
subroutine, public da_operator(kind_op, pool_a, pool_b, pool_c, fld_select)
Performs A = A 'kind_op' B for pools A and B.
subroutine, public da_copy_all2sub_fields(domain, pool_a)
Performs a copy of allfield to a sub pool A.
subroutine, public uv_cell_to_edges(domain, u_field, v_field, du, lonCell, latCell, nCells, edgeNormalVectors, nEdgesOnCell, edgesOnCell, nVertLevels)
real(kind=kind_real), parameter mpas_jedi_half_kr
real(kind=kind_real), parameter mpas_jedi_zero_kr
real(kind=kind_real), parameter mpas_jedi_one_kr
character(len=maxvarlen), dimension(2), parameter, public cellcenteredwindfields
character(len=maxvarlen), dimension(4), parameter, public modelthermofields
character(len=maxvarlen), dimension(6), public mpas_hydrometeor_fields
character(len=maxvarlen), dimension(2), parameter, public moisturefields
character(len=maxvarlen), dimension(2), parameter, public analysisthermofields
subroutine, public invent_state(self, f_conf)
subroutine, public add_incr(self, increment)
add increment to state
subroutine, public analytic_ic(self, geom, f_conf, vdate)
Analytic Initialization for the MPAS Model.
Fortran derived type to hold MPAS field.
Fortran derived type to hold geometry definition.