8 use fckit_configuration_module,
only: fckit_configuration
9 use fckit_log_module,
only : fckit_log
14 use oops_variables_mod,
only: oops_variables
22 use mpas_derived_types
23 use mpas_field_routines
24 use mpas_pool_routines
34 type (mpas_pool_type),
pointer :: trajectories => null()
50 subroutine create(self, geom, bg, fg, f_conf, vars)
57 type(fckit_configuration),
intent(in) :: f_conf
58 type(oops_variables),
intent(in) :: vars
60 type (field2DReal),
pointer :: fld2d_t, fld2d_p, fld2d_qs
64 if ( vars % has (
'relhum') )
then
68 call mpas_pool_create_pool(self % trajectories)
70 if ( .not. fg % has (
'temperature') .or. .not. fg % has (
'pressure') ) &
71 call abor1_ftn(
"LinVarChaC2A::LinVarChaC2A, mpasjedi_linvarcha_c2a_create: Trajectory failed")
73 call fg%get(
'temperature', fld2d_t)
74 call fg%get(
'pressure' , fld2d_p)
76 call mpas_duplicate_field(fld2d_t, fld2d_qs)
78 call da_tp_to_qs( fld2d_t % array(:,1:ngrid), fld2d_p % array(:,1:ngrid), fld2d_qs% array(:,1:ngrid))
80 call mpas_pool_add_field(self % trajectories,
'spechum_sat', fld2d_qs)
92 if (
associated(self % trajectories))
then
93 call mpas_pool_destroy_pool(self % trajectories)
108 type (mpas_pool_iterator_type) :: poolItr
109 type (field2DReal),
pointer :: fld2d_sf, fld2d_vp, fld2d_uRz, fld2d_uRm, fld2d_traj_qs
110 type (field2DReal),
pointer :: fld2d_v_src, fld2d_sf_v, fld2d_e_src, fld2d_u
112 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_ctl, ptrr1_ana
113 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_ctl, ptrr2_ana
114 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_sh, ptrr2_rh
116 integer :: k, ngrid, nCells, nVertices, nEdges
118 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiply: xana % fldnames(:) =",xana % fldnames(:)
120 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiply: xctl % fldnames(:) =",xctl % fldnames(:)
123 ngrid = geom % nCellsSolve
126 call mpas_pool_begin_iteration(xctl%subFields)
127 do while ( mpas_pool_get_next_member(xctl%subFields, poolitr) )
129 if (poolitr % memberType == mpas_pool_field .and. poolitr % dataType == mpas_pool_real)
then
130 if( xana%has(poolitr % memberName) )
then
131 if (poolitr % nDims == 1)
then
132 call xctl%get(poolitr % memberName, ptrr1_ctl)
133 call xana%get(poolitr % memberName, ptrr1_ana)
134 ptrr1_ana(1:ngrid)=ptrr1_ctl(1:ngrid)
135 else if (poolitr % nDims == 2)
then
136 call xctl%get(poolitr % memberName, ptrr2_ctl)
137 call xana%get(poolitr % memberName, ptrr2_ana)
138 ptrr2_ana(:,1:ngrid)=ptrr2_ctl(:,1:ngrid)
140 write(
message,*)
'--> mpasjedi_linvarcha_c2a::multiply: poolItr % nDims == ',poolitr % nDims,
' not handled'
147 if( xctl%has(
'relhum') .and. xana%has(
'spechum') )
then
148 call xctl%get(
'relhum', ptrr2_rh)
149 call xana%get(
'spechum', ptrr2_sh)
150 call mpas_pool_get_field(self%trajectories,
'spechum_sat', fld2d_traj_qs)
151 call pseudorh_to_spechum( ptrr2_rh(:,1:ngrid), ptrr2_sh(:,1:ngrid), fld2d_traj_qs%array(:,1:ngrid) )
154 if( xctl%has(
'stream_function') .and. xctl%has(
'velocity_potential') .and. &
155 xana%has(
'uReconstructZonal') .and. xana%has(
'uReconstructMeridional') )
then
156 call xctl%get(
'stream_function', fld2d_sf)
157 call xctl%get(
'velocity_potential', fld2d_vp)
158 call xana%get(
'uReconstructZonal', fld2d_urz)
159 call xana%get(
'uReconstructMeridional', fld2d_urm)
161 call mpas_dmpar_exch_halo_field(fld2d_sf)
162 call mpas_dmpar_exch_halo_field(fld2d_vp)
164 ncells = geom % nCells
165 nvertices = geom % nVertices
166 nedges = geom % nEdges
169 call mpas_pool_get_field( geom % domain % blocklist % allFields,
'vorticity', fld2d_v_src)
170 call mpas_duplicate_field(fld2d_v_src, fld2d_sf_v)
171 fld2d_sf_v % fieldName =
'stream_function at vertices'
172 call mpas_pool_get_field( geom % domain % blocklist % allFields,
'u', fld2d_e_src)
173 call mpas_duplicate_field(fld2d_e_src, fld2d_u)
174 fld2d_u % fieldName =
'Horizontal normal velocity at edges'
177 call mpas_dmpar_exch_halo_field(fld2d_sf_v)
179 fld2d_u%array(:,1:nedges) )
180 call mpas_dmpar_exch_halo_field(fld2d_u)
182 fld2d_urz%array(:,1:ncells), fld2d_urm%array(:,1:ncells) )
184 call mpas_deallocate_field(fld2d_sf_v)
185 call mpas_deallocate_field(fld2d_u)
200 type (mpas_pool_iterator_type) :: poolItr
201 type (field2DReal),
pointer :: fld2d_sf, fld2d_vp, fld2d_uRz, fld2d_uRm, fld2d_traj_qs
202 type (field2DReal),
pointer :: fld2d_v_src, fld2d_sf_v, fld2d_e_src, fld2d_u
204 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_ctl, ptrr1_ana
205 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_ctl, ptrr2_ana
206 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_sh, ptrr2_rh
207 integer :: k, ngrid, nCells, nVertices, nEdges
209 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiplyadjoint: xana % fldnames(:) =",xana % fldnames(:)
211 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiplyadjoint: xctl % fldnames(:) =",xctl % fldnames(:)
214 ngrid = geom % nCellsSolve
217 call mpas_pool_begin_iteration(xctl%subFields)
218 do while ( mpas_pool_get_next_member(xctl%subFields, poolitr) )
220 if (poolitr % memberType == mpas_pool_field .and. poolitr % dataType == mpas_pool_real)
then
221 if( xana%has(poolitr % memberName) )
then
222 if (poolitr % nDims == 1)
then
223 call xctl%get(poolitr % memberName, ptrr1_ctl)
224 call xana%get(poolitr % memberName, ptrr1_ana)
225 ptrr1_ctl(1:ngrid)=ptrr1_ctl(1:ngrid)+ptrr1_ana(1:ngrid)
227 else if (poolitr % nDims == 2)
then
228 call xctl%get(poolitr % memberName, ptrr2_ctl)
229 call xana%get(poolitr % memberName, ptrr2_ana)
230 ptrr2_ctl(:,1:ngrid)=ptrr2_ctl(:,1:ngrid)+ptrr2_ana(:,1:ngrid)
233 write(
message,*)
'--> mpasjedi_linvarcha_c2a::multiplyadjoint: poolItr % nDims == ',poolitr % nDims,
' not handled'
240 if( xctl%has(
'relhum') .and. xana%has(
'spechum') )
then
241 call xctl%get(
'relhum', ptrr2_rh)
242 call xana%get(
'spechum', ptrr2_sh)
243 call mpas_pool_get_field(self%trajectories,
'spechum_sat', fld2d_traj_qs)
244 call pseudorh_to_spechumad( ptrr2_rh(:,1:ngrid), ptrr2_sh(:,1:ngrid), fld2d_traj_qs%array(:,1:ngrid) )
247 if( xctl%has(
'stream_function') .and. xctl%has(
'velocity_potential') .and. &
248 xana%has(
'uReconstructZonal') .and. xana%has(
'uReconstructMeridional') )
then
249 call xctl%get(
'stream_function', fld2d_sf)
250 call xctl%get(
'velocity_potential', fld2d_vp)
251 call xana%get(
'uReconstructZonal', fld2d_urz)
252 call xana%get(
'uReconstructMeridional', fld2d_urm)
254 ncells = geom % nCells
255 nvertices = geom % nVertices
256 nedges = geom % nEdges
259 call mpas_pool_get_field( geom % domain % blocklist % allFields,
'vorticity', fld2d_v_src)
260 call mpas_duplicate_field(fld2d_v_src, fld2d_sf_v)
261 fld2d_sf_v % fieldName =
'stream_function at vertices'
262 call mpas_pool_get_field( geom % domain % blocklist % allFields,
'u', fld2d_e_src)
263 call mpas_duplicate_field(fld2d_e_src, fld2d_u)
264 fld2d_u % fieldName =
'Horizontal normal velocity at edges'
267 fld2d_urz%array(:,1:ncells), fld2d_urm%array(:,1:ncells) )
268 call mpas_dmpar_exch_halo_adj_field(fld2d_u)
270 fld2d_u%array(:,1:nedges) )
271 call mpas_dmpar_exch_halo_adj_field(fld2d_sf_v)
274 call mpas_deallocate_field(fld2d_sf_v)
275 call mpas_deallocate_field(fld2d_u)
280 call mpas_dmpar_exch_halo_adj_field(fld2d_sf)
281 call mpas_dmpar_exch_halo_adj_field(fld2d_vp)
296 type (mpas_pool_iterator_type) :: poolItr
297 type (field2DReal),
pointer :: fld2d_traj_qs
298 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_ctl, ptrr1_ana
299 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_ctl, ptrr2_ana
300 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_sh, ptrr2_rh
303 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiplyinverse: xana % fldnames(:) =",xana % fldnames(:)
305 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiplyinverse: xctl % fldnames(:) =",xctl % fldnames(:)
308 ngrid = geom % nCellsSolve
311 call mpas_pool_begin_iteration(xctl%subFields)
312 do while ( mpas_pool_get_next_member(xctl%subFields, poolitr) )
314 if (poolitr % memberType == mpas_pool_field .and. poolitr % dataType == mpas_pool_real)
then
315 if( xana%has(poolitr % memberName) )
then
316 if (poolitr % nDims == 1)
then
317 call xctl%get(poolitr % memberName, ptrr1_ctl)
318 call xana%get(poolitr % memberName, ptrr1_ana)
319 ptrr1_ctl(1:ngrid)=ptrr1_ana(1:ngrid)
320 else if (poolitr % nDims == 2)
then
321 call xctl%get(poolitr % memberName, ptrr2_ctl)
322 call xana%get(poolitr % memberName, ptrr2_ana)
323 ptrr2_ctl(:,1:ngrid)=ptrr2_ana(:,1:ngrid)
325 write(
message,*)
'--> mpasjedi_linvarcha_c2a::multiplyinverse: poolItr % nDims == ',poolitr % nDims,
' not handled'
332 if( xctl%has(
'relhum') .and. xana%has(
'spechum') )
then
333 call xana%get(
'spechum', ptrr2_sh)
334 call xctl%get(
'relhum', ptrr2_rh)
335 call mpas_pool_get_field(self%trajectories,
'spechum_sat', fld2d_traj_qs)
340 if( xctl%has(
'stream_function') .and. xctl%has(
'velocity_potential') .and. &
341 xana%has(
'uReconstructZonal') .and. xana%has(
'uReconstructMeridional') )
then
342 call xana%get(
'uReconstructZonal', ptrr2_ana)
343 call xctl%get(
'stream_function', ptrr2_ctl)
344 ptrr2_ctl(:,1:ngrid)=ptrr2_ana(:,1:ngrid)
346 call xana%get(
'uReconstructMeridional', ptrr2_ana)
347 call xctl%get(
'velocity_potential', ptrr2_ctl)
348 ptrr2_ctl(:,1:ngrid)=ptrr2_ana(:,1:ngrid)
363 type (mpas_pool_iterator_type) :: poolItr
364 type (field2DReal),
pointer :: fld2d_traj_qs
365 real(kind=kind_real),
dimension(:),
pointer :: ptrr1_ctl, ptrr1_ana
366 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_ctl, ptrr2_ana
367 real(kind=kind_real),
dimension(:,:),
pointer :: ptrr2_sh, ptrr2_rh, ptrr2_traj_qs
370 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiplyinverseadjoint: xana % fldnames(:) =",xana % fldnames(:)
372 write(
message,*)
"DEBUG: mpasjedi_linvarcha_c2a_multiplyinverseadjoint: xctl % fldnames(:) =",xctl % fldnames(:)
375 ngrid = geom % nCellsSolve
378 call mpas_pool_begin_iteration(xctl%subFields)
379 do while ( mpas_pool_get_next_member(xctl%subFields, poolitr) )
381 if (poolitr % memberType == mpas_pool_field .and. poolitr % dataType == mpas_pool_real)
then
382 if( xana%has(poolitr % memberName) )
then
383 if (poolitr % nDims == 1)
then
384 call xctl%get(poolitr % memberName, ptrr1_ctl)
385 call xana%get(poolitr % memberName, ptrr1_ana)
386 ptrr1_ana(1:ngrid)=ptrr1_ana(1:ngrid)+ptrr1_ctl(1:ngrid)
388 else if (poolitr % nDims == 2)
then
389 call xctl%get(poolitr % memberName, ptrr2_ctl)
390 call xana%get(poolitr % memberName, ptrr2_ana)
391 ptrr2_ana(:,1:ngrid)=ptrr2_ana(:,1:ngrid)+ptrr2_ctl(:,1:ngrid)
394 write(
message,*)
'--> mpasjedi_linvarcha_c2a::multiplyinverse: poolItr % nDims == ',poolitr % nDims,
' not handled'
401 if( xctl%has(
'relhum') .and. xana%has(
'spechum') )
then
402 call xana%get(
'spechum', ptrr2_sh)
403 call xctl%get(
'relhum', ptrr2_rh)
404 call mpas_pool_get_field(self%trajectories,
'spechum_sat', fld2d_traj_qs)
409 if( xctl%has(
'stream_function') .and. xctl%has(
'velocity_potential') .and. &
410 xana%has(
'uReconstructZonal') .and. xana%has(
'uReconstructMeridional') )
then
411 call xana%get(
'uReconstructZonal', ptrr2_ana)
412 call xctl%get(
'stream_function', ptrr2_ctl)
413 ptrr2_ana(:,1:ngrid)=ptrr2_ana(:,1:ngrid)+ptrr2_ctl(:,1:ngrid)
416 call xana%get(
'uReconstructMeridional', ptrr2_ana)
417 call xctl%get(
'velocity_potential', ptrr2_ctl)
418 ptrr2_ana(:,1:ngrid)=ptrr2_ana(:,1:ngrid)+ptrr2_ctl(:,1:ngrid)
429 uReconstructZonal, uReconstructMeridional, includeHalos)
433 type (mpas_pool_type),
intent(in) :: meshPool
434 real (kind=rkind),
dimension(:,:),
intent(inout) :: u
435 real (kind=rkind),
dimension(:,:),
intent(inout) :: ureconstructx
436 real (kind=rkind),
dimension(:,:),
intent(inout) :: ureconstructy
437 real (kind=rkind),
dimension(:,:),
intent(inout) :: ureconstructz
438 real (kind=rkind),
dimension(:,:),
intent(inout) :: ureconstructzonal
439 real (kind=rkind),
dimension(:,:),
intent(inout) :: ureconstructmeridional
440 logical,
optional,
intent(in) :: includeHalos
443 logical :: includeHalosLocal
444 integer,
pointer :: nCells
445 integer,
dimension(:,:),
pointer :: edgesOnCell
446 integer,
dimension(:),
pointer :: nEdgesOnCell
447 integer :: iCell,iEdge, i
448 real(kind=rkind),
dimension(:),
pointer :: latcell, loncell
450 real (kind=rkind),
dimension(:,:,:),
pointer :: coeffs_reconstruct
452 logical,
pointer :: on_a_sphere
454 real (kind=rkind) :: clat, slat, clon, slon
456 if (
present(includehalos) )
then
457 includehaloslocal = includehalos
459 includehaloslocal = .false.
463 call mpas_pool_get_array(meshpool,
'coeffs_reconstruct', coeffs_reconstruct)
466 call mpas_pool_get_array(meshpool,
'nEdgesOnCell', nedgesoncell)
467 call mpas_pool_get_array(meshpool,
'edgesOnCell', edgesoncell)
469 if ( includehaloslocal )
then
470 call mpas_pool_get_dimension(meshpool,
'nCells', ncells)
472 call mpas_pool_get_dimension(meshpool,
'nCellsSolve', ncells)
475 call mpas_pool_get_array(meshpool,
'latCell', latcell)
476 call mpas_pool_get_array(meshpool,
'lonCell', loncell)
478 call mpas_pool_get_config(meshpool,
'on_a_sphere', on_a_sphere)
484 if (on_a_sphere)
then
486 clat = cos(latcell(icell))
487 slat = sin(latcell(icell))
488 clon = cos(loncell(icell))
489 slon = sin(loncell(icell))
491 ureconstructx(:,icell) = ureconstructx(:,icell) - clon*slat * ureconstructmeridional(:,icell)
492 ureconstructy(:,icell) = ureconstructy(:,icell) - slon*slat * ureconstructmeridional(:,icell)
493 ureconstructz(:,icell) = ureconstructz(:,icell) + clat * ureconstructmeridional(:,icell)
495 ureconstructx(:,icell) = ureconstructx(:,icell) - slon * ureconstructzonal(:,icell)
496 ureconstructy(:,icell) = ureconstructy(:,icell) + clon * ureconstructzonal(:,icell)
500 ureconstructy(:,icell) = ureconstructy(:,icell) + ureconstructmeridional(:,icell)
501 ureconstructx(:,icell) = ureconstructx(:,icell) + ureconstructzonal(:,icell)
509 do i=1,nedgesoncell(icell)
510 iedge = edgesoncell(i,icell)
511 u(:,iedge) = u(:,iedge) + coeffs_reconstruct(1,i,icell) * ureconstructx(:,icell) &
512 + coeffs_reconstruct(2,i,icell) * ureconstructy(:,icell) &
513 + coeffs_reconstruct(3,i,icell) * ureconstructz(:,icell)
522 uReconstructZonal, uReconstructMeridional, includeHalos)
526 type (mpas_pool_type),
intent(in) :: meshPool
527 real (kind=rkind),
dimension(:),
intent(inout) :: u
528 real (kind=rkind),
dimension(:),
intent(inout) :: ureconstructx
529 real (kind=rkind),
dimension(:),
intent(inout) :: ureconstructy
530 real (kind=rkind),
dimension(:),
intent(inout) :: ureconstructz
531 real (kind=rkind),
dimension(:),
intent(inout) :: ureconstructzonal
532 real (kind=rkind),
dimension(:),
intent(inout) :: ureconstructmeridional
533 logical,
optional,
intent(in) :: includeHalos
536 logical :: includeHalosLocal
537 integer,
pointer :: nCells
538 integer,
dimension(:,:),
pointer :: edgesOnCell
539 integer,
dimension(:),
pointer :: nEdgesOnCell
540 integer :: iCell,iEdge, i
541 real(kind=rkind),
dimension(:),
pointer :: latcell, loncell
543 real (kind=rkind),
dimension(:,:,:),
pointer :: coeffs_reconstruct
545 logical,
pointer :: on_a_sphere
547 real (kind=rkind) :: clat, slat, clon, slon
549 if (
present(includehalos) )
then
550 includehaloslocal = includehalos
552 includehaloslocal = .false.
556 call mpas_pool_get_array(meshpool,
'coeffs_reconstruct', coeffs_reconstruct)
559 call mpas_pool_get_array(meshpool,
'nEdgesOnCell', nedgesoncell)
560 call mpas_pool_get_array(meshpool,
'edgesOnCell', edgesoncell)
562 if ( includehaloslocal )
then
563 call mpas_pool_get_dimension(meshpool,
'nCells', ncells)
565 call mpas_pool_get_dimension(meshpool,
'nCellsSolve', ncells)
568 call mpas_pool_get_array(meshpool,
'latCell', latcell)
569 call mpas_pool_get_array(meshpool,
'lonCell', loncell)
571 call mpas_pool_get_config(meshpool,
'on_a_sphere', on_a_sphere)
577 if (on_a_sphere)
then
579 clat = cos(latcell(icell))
580 slat = sin(latcell(icell))
581 clon = cos(loncell(icell))
582 slon = sin(loncell(icell))
584 ureconstructx(icell) = ureconstructx(icell) - clon*slat * ureconstructmeridional(icell)
585 ureconstructy(icell) = ureconstructy(icell) - slon*slat * ureconstructmeridional(icell)
586 ureconstructz(icell) = ureconstructz(icell) + clat * ureconstructmeridional(icell)
588 ureconstructx(icell) = ureconstructx(icell) - slon * ureconstructzonal(icell)
589 ureconstructy(icell) = ureconstructy(icell) + clon * ureconstructzonal(icell)
593 ureconstructy(icell) = ureconstructy(icell) + ureconstructmeridional(icell)
594 ureconstructx(icell) = ureconstructx(icell) + ureconstructzonal(icell)
602 do i=1,nedgesoncell(icell)
603 iedge = edgesoncell(i,icell)
604 u(iedge) = u(iedge) + coeffs_reconstruct(1,i,icell) * ureconstructx(icell) &
605 + coeffs_reconstruct(2,i,icell) * ureconstructy(icell) &
606 + coeffs_reconstruct(3,i,icell) * ureconstructz(icell)
618 type (mpas_geom),
intent(in) :: geom
619 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(in) :: psi, chi
620 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(out) :: u, v
623 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCellsSolve) :: &
624 psi_line_intg_dx, psi_line_intg_dy, chi_line_intg_dx, chi_line_intg_dy
631 do ic = 1, geom%nCellsSolve
632 do j = 1, geom%nEdgesOnCell(ic)
633 ie = geom%edgesOnCell(j,ic)
634 psi_line_intg_dx(:,ic) = psi_line_intg_dx(:,ic) &
635 +
mpas_jedi_half_kr * ( psi(:,geom%cellsOnEdge(1,ie)) + psi(:,geom%cellsOnEdge(2,ie)) ) &
636 * geom%dvEdge(ie) * sin(
mpas_jedi_zero_kr-geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic)
637 psi_line_intg_dy(:,ic) = psi_line_intg_dy(:,ic) &
638 +
mpas_jedi_half_kr * ( psi(:,geom%cellsOnEdge(1,ie)) + psi(:,geom%cellsOnEdge(2,ie)) ) &
639 * geom%dvEdge(ie) * cos(geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic)
640 chi_line_intg_dx(:,ic) = chi_line_intg_dx(:,ic) &
641 +
mpas_jedi_half_kr * ( chi(:,geom%cellsOnEdge(1,ie)) + chi(:,geom%cellsOnEdge(2,ie)) ) &
642 * geom%dvEdge(ie) * sin(
mpas_jedi_zero_kr-geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic)
643 chi_line_intg_dy(:,ic) = chi_line_intg_dy(:,ic) &
644 +
mpas_jedi_half_kr * ( chi(:,geom%cellsOnEdge(1,ie)) + chi(:,geom%cellsOnEdge(2,ie)) ) &
645 * geom%dvEdge(ie) * cos(geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic)
649 do ic=1, geom%nCellsSolve
650 u(:,ic) = ( psi_line_intg_dx(:,ic) - chi_line_intg_dy(:,ic) ) / geom%areaCell(ic)
651 v(:,ic) = ( psi_line_intg_dy(:,ic) + chi_line_intg_dx(:,ic) ) / geom%areaCell(ic)
661 type (mpas_geom),
intent(in) :: geom
662 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(inout) :: psi, chi
663 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(inout) :: u, v
666 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCellsSolve) :: &
667 psi_line_intg_dx, psi_line_intg_dy, chi_line_intg_dx, chi_line_intg_dy
674 do ic=1, geom%nCellsSolve
675 psi_line_intg_dx(:,ic) = psi_line_intg_dx(:,ic) + u(:,ic) / geom%areaCell(ic)
676 chi_line_intg_dy(:,ic) = chi_line_intg_dy(:,ic) - u(:,ic) / geom%areaCell(ic)
677 psi_line_intg_dy(:,ic) = psi_line_intg_dy(:,ic) + v(:,ic) / geom%areaCell(ic)
678 chi_line_intg_dx(:,ic) = chi_line_intg_dx(:,ic) + v(:,ic) / geom%areaCell(ic)
681 do ic = 1, geom%nCellsSolve
682 do j = 1, geom%nEdgesOnCell(ic)
683 ie = geom%edgesOnCell(j,ic)
685 psi(:,geom%cellsOnEdge(1,ie)) = psi(:,geom%cellsOnEdge(1,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
686 * sin(
mpas_jedi_zero_kr-geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * psi_line_intg_dx(:,ic)
687 psi(:,geom%cellsOnEdge(2,ie)) = psi(:,geom%cellsOnEdge(2,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
688 * sin(
mpas_jedi_zero_kr-geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * psi_line_intg_dx(:,ic)
690 psi(:,geom%cellsOnEdge(1,ie)) = psi(:,geom%cellsOnEdge(1,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
691 * cos(geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * psi_line_intg_dy(:,ic)
692 psi(:,geom%cellsOnEdge(2,ie)) = psi(:,geom%cellsOnEdge(2,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
693 * cos(geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * psi_line_intg_dy(:,ic)
695 chi(:,geom%cellsOnEdge(1,ie)) = chi(:,geom%cellsOnEdge(1,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
696 * sin(
mpas_jedi_zero_kr-geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * chi_line_intg_dx(:,ic)
697 chi(:,geom%cellsOnEdge(2,ie)) = chi(:,geom%cellsOnEdge(2,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
698 * sin(
mpas_jedi_zero_kr-geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * chi_line_intg_dx(:,ic)
700 chi(:,geom%cellsOnEdge(1,ie)) = chi(:,geom%cellsOnEdge(1,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
701 * cos(geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * chi_line_intg_dy(:,ic)
702 chi(:,geom%cellsOnEdge(2,ie)) = chi(:,geom%cellsOnEdge(2,ie)) +
mpas_jedi_half_kr * geom%dvEdge(ie)&
703 * cos(geom%angleEdge(ie)) * geom%edgesOnCell_sign(j,ic) * chi_line_intg_dy(:,ic)
715 type (mpas_geom),
intent(in) :: geom
716 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(in) :: psi
717 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nVertices),
intent(inout) :: psi_v
724 do iv = 1, geom%nVerticesSolve
725 do j = 1, geom%vertexDegree
726 ic = geom%cellsOnVertex(j,iv)
727 psi_v(:,iv) = psi_v(:,iv) + geom%kiteAreasOnVertex(j,iv) * psi(:,ic)
729 psi_v(:,iv) = psi_v(:,iv) / geom%areaTriangle(iv)
740 type (mpas_geom),
intent(in) :: geom
741 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nVertices),
intent(in) :: psi_v
742 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(in) :: chi
743 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nEdges),
intent(inout) :: edge_normal_wind
750 do ie = 1, geom%nEdgesSolve
751 edge_normal_wind(:,ie) = edge_normal_wind(:,ie) - &
752 ( chi(:,geom%cellsOnEdge(2,ie)) - chi(:,geom%cellsOnEdge(1,ie)) ) / geom%dcEdge(ie) - &
753 ( psi_v(:,geom%verticesOnEdge(2,ie)) - psi_v(:,geom%verticesOnEdge(1,ie)) ) / geom%dvEdge(ie)
763 use mpas_vector_reconstruction
766 type (mpas_geom),
intent(in) :: geom
767 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nEdges),
intent(in) :: edge_normal_wind
768 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(inout) :: u, v
770 real (kind=kind_real),
dimension(:,:),
allocatable :: &
771 ureconstructx, ureconstructy, ureconstructz
772 type (mpas_pool_type),
pointer :: mesh
774 allocate(ureconstructx(geom%nVertLevels,geom%nCells))
775 allocate(ureconstructy(geom%nVertLevels,geom%nCells))
776 allocate(ureconstructz(geom%nVertLevels,geom%nCells))
779 call mpas_pool_get_subpool( geom % domain % blocklist % structs,
'mesh', mesh)
780 call mpas_reconstruct(mesh, edge_normal_wind, &
787 deallocate(ureconstructx, ureconstructy, ureconstructz)
795 type (mpas_geom),
intent(in) :: geom
796 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(inout) :: psi
797 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nVertices),
intent(inout) :: psi_v
804 do iv = 1, geom%nVerticesSolve
805 psi_v(:,iv) = psi_v(:,iv) / geom%areaTriangle(iv)
806 do j = 1, geom%vertexDegree
807 ic = geom%cellsOnVertex(j,iv)
808 psi(:,ic) = psi(:,ic) + geom%kiteAreasOnVertex(j,iv) * psi_v(:,iv)
818 type (mpas_geom),
intent(in) :: geom
819 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nVertices),
intent(inout) :: psi_v
820 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(inout) :: chi
821 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nEdges),
intent(inout) :: edge_normal_wind
829 do ie = 1, geom%nEdgesSolve
830 chi(:,geom%cellsOnEdge(2,ie)) = chi(:,geom%cellsOnEdge(2,ie)) - edge_normal_wind(:,ie) / geom%dcEdge(ie)
831 chi(:,geom%cellsOnEdge(1,ie)) = chi(:,geom%cellsOnEdge(1,ie)) + edge_normal_wind(:,ie) / geom%dcEdge(ie)
832 psi_v(:,geom%verticesOnEdge(2,ie)) = psi_v(:,geom%verticesOnEdge(2,ie)) - edge_normal_wind(:,ie) / geom%dvEdge(ie)
833 psi_v(:,geom%verticesOnEdge(1,ie)) = psi_v(:,geom%verticesOnEdge(1,ie)) + edge_normal_wind(:,ie) / geom%dvEdge(ie)
841 use mpas_vector_reconstruction
844 type (mpas_geom),
intent(in) :: geom
845 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nEdges),
intent(inout) :: edge_normal_wind
846 real (kind=kind_real),
dimension(geom%nVertLevels,geom%nCells),
intent(inout) :: u, v
848 real (kind=kind_real),
dimension(:,:),
allocatable :: &
849 ureconstructx, ureconstructy, ureconstructz
850 type (mpas_pool_type),
pointer :: mesh
854 allocate(ureconstructx(geom%nVertLevels,geom%nCells))
855 allocate(ureconstructy(geom%nVertLevels,geom%nCells))
856 allocate(ureconstructz(geom%nVertLevels,geom%nCells))
858 call mpas_pool_get_subpool( geom % domain % blocklist % structs,
'mesh', mesh)
866 deallocate(ureconstructx, ureconstructy, ureconstructz)
875 real (kind=kind_real),
intent(in) :: pseudorh
876 real (kind=kind_real),
intent(out) :: spechum
877 real (kind=kind_real),
intent(in) :: saturation_spechum
886 real (kind=kind_real),
intent(inout) :: pseudorh
887 real (kind=kind_real),
intent(inout) :: spechum
888 real (kind=kind_real),
intent(in) :: saturation_spechum
898 real (kind=kind_real),
intent(out) :: pseudorh
899 real (kind=kind_real),
intent(in) :: spechum
900 real (kind=kind_real),
intent(in) :: saturation_spechum
909 real (kind=kind_real),
intent(inout) :: pseudorh
910 real (kind=kind_real),
intent(inout) :: spechum
911 real (kind=kind_real),
intent(in) :: saturation_spechum
929 real (kind=kind_real),
intent(in) :: t, p
930 real (kind=kind_real),
intent(out) :: qs
932 real (kind=kind_real) :: es
933 real (kind=kind_real) :: t_c
real(kind=kind_real), parameter mpas_jedi_half_kr
real(kind=kind_real), parameter rd_over_rv1
real(kind=kind_real), parameter t_kelvin
real(kind=kind_real), parameter es_gamma
real(kind=kind_real), parameter es_alpha
real(kind=kind_real), parameter mpas_jedi_zero_kr
real(kind=kind_real), parameter es_beta
real(kind=kind_real), parameter rd_over_rv
real(kind=kind_real), parameter mpas_jedi_hundred_kr
subroutine mpas_reconstruct_1dad(meshPool, u, uReconstructX, uReconstructY, uReconstructZ, uReconstructZonal, uReconstructMeridional, includeHalos)
character(len=1024) message
elemental subroutine pseudorh_to_spechumad(pseudorh, spechum, saturation_spechum)
subroutine psichi_to_uv_edge_step2ad(geom, psi_v, chi, edge_normal_wind)
subroutine psichi_to_uv_edge_step1(geom, psi, psi_v)
subroutine create(self, geom, bg, fg, f_conf, vars)
subroutine multiply(self, geom, xctl, xana)
subroutine multiplyadjoint(self, geom, xana, xctl)
subroutine psichi_to_uv_edge_step2(geom, psi_v, chi, edge_normal_wind)
subroutine multiplyinverse(self, geom, xana, xctl)
subroutine mpas_reconstruct_2dad(meshPool, u, uReconstructX, uReconstructY, uReconstructZ, uReconstructZonal, uReconstructMeridional, includeHalos)
elemental subroutine pseudorh_to_spechum_inverse(pseudorh, spechum, saturation_spechum)
elemental subroutine da_tp_to_qs(t, p, qs)
subroutine psichi_to_uv_edge_step1ad(geom, psi, psi_v)
subroutine psichi_to_uv_centerad(geom, psi, chi, u, v)
subroutine psichi_to_uv_center(geom, psi, chi, u, v)
subroutine psichi_to_uv_edge_step3ad(geom, edge_normal_wind, u, v)
elemental subroutine pseudorh_to_spechum(pseudorh, spechum, saturation_spechum)
elemental subroutine pseudorh_to_spechum_inversead(pseudorh, spechum, saturation_spechum)
subroutine multiplyinverseadjoint(self, geom, xctl, xana)
subroutine psichi_to_uv_edge_step3(geom, edge_normal_wind, u, v)
Fortran derived type to hold MPAS field.
Fortran derived type to hold geometry definition.
Fortran derived type to hold configuration data for the B mat variable change.