Skip to content

Commit 3acedd4

Browse files
committed
update pressure calculation
1 parent 6a2d154 commit 3acedd4

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

components/eam/src/dynamics/se/gravity_waves_sources.F90

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,9 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,use_fgf_pgrad_correction,ele
116116
use dyn_comp, only: hvcoord
117117
use spmd_utils, only: iam
118118
use parallel_mod, only: par
119-
use element_ops, only: get_temperature
119+
use element_ops, only: get_temperature, get_hydro_pressure
120120
use dyn_grid, only: fv_nphys
121121
use prim_driver_mod, only: deriv1
122-
use element_ops, only: get_temperature
123122
use gllfvremap_mod, only: gfr_g2f_scalar, gfr_g2f_vector
124123
implicit none
125124
type(hybrid_t), intent(in ) :: hybrid
@@ -134,8 +133,9 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,use_fgf_pgrad_correction,ele
134133
integer :: k,kptr,i,j,ie,component
135134
real(kind=real_kind) :: frontgf_gll(np,np,nlev,nets:nete)
136135
real(kind=real_kind) :: gradth_gll(np,np,2,nlev,nets:nete) ! grad(theta)
137-
real(kind=real_kind) :: p(np,np) ! pressure at mid points
138-
real(kind=real_kind) :: temperature(np,np,nlev) ! Temperature
136+
real(kind=real_kind) :: pmid(np,np,nlev) ! old version of pressure at mid points
137+
real(kind=real_kind) :: pmid_hydro(np,np,nlev) ! hydrostatic pressure at mid points
138+
real(kind=real_kind) :: temperature(np,np,nlev) ! Temperature
139139
real(kind=real_kind) :: C(np,np,2), wf1(nphys*nphys,nlev), wf2(nphys*nphys,nlev)
140140

141141
! variables needed for eta to pressure surface correction
@@ -181,20 +181,19 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,use_fgf_pgrad_correction,ele
181181

182182
if (use_fgf_pgrad_correction) then
183183

184+
! compute pressure at mid points
185+
call get_hydro_pressure(pmid_hydro,elem(ie)%state%dp3d(:,:,:,tl),hvcoord)
186+
184187
call get_temperature(elem(ie),temperature,hvcoord,tl)
185188
do k = 1,nlev
186-
! pressure at mid points
187-
p(:,:) = hvcoord%hyam(k)*hvcoord%ps0 + hvcoord%hybm(k)*elem(ie)%state%ps_v(:,:,tl)
188189
! potential temperature: theta = T (p/p0)^kappa
189-
theta(:,:,k) = temperature(:,:,k)*(psurf_ref / p(:,:))**kappa
190+
theta(:,:,k) = temperature(:,:,k)*(psurf_ref / pmid_hydro(:,:,k))**kappa
190191
end do
191192
call compute_vertical_derivative(tl,ie,elem,theta,dtheta_dp)
192193

193194
do k = 1,nlev
194195
gradth_gll(:,:,:,k,ie) = gradient_sphere(theta(:,:,k),deriv1,elem(ie)%Dinv)
195-
! calculate and apply correction so that gradient is effectively on a pressure surface
196-
p(:,:) = hvcoord%hyam(k)*hvcoord%ps0 + hvcoord%hybm(k)*elem(ie)%state%ps_v(:,:,tl)
197-
gradp_gll(:,:,:) = gradient_sphere(p,deriv1,elem(ie)%Dinv)
196+
gradp_gll(:,:,:) = gradient_sphere(pmid_hydro(:,:,k),deriv1,elem(ie)%Dinv)
198197
do component=1,2
199198
gradth_gll(:,:,component,k,ie) = gradth_gll(:,:,component,k,ie) - dtheta_dp(:,:,k) * gradp_gll(:,:,component)
200199
end do
@@ -212,8 +211,7 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,use_fgf_pgrad_correction,ele
212211
end do
213212

214213
do k = 1,nlev
215-
p(:,:) = hvcoord%hyam(k)*hvcoord%ps0 + hvcoord%hybm(k)*elem(ie)%state%ps_v(:,:,tl)
216-
gradp_gll(:,:,:) = gradient_sphere(p,deriv1,elem(ie)%Dinv)
214+
gradp_gll(:,:,:) = gradient_sphere(pmid_hydro(:,:,k),deriv1,elem(ie)%Dinv)
217215
! Do ugradv on the cartesian components - Dot u with the gradient of each component
218216
do component=1,3
219217
dum_grad(:,:,:) = gradient_sphere(dum_cart(:,:,component,k),deriv1,elem(ie)%Dinv)
@@ -237,11 +235,11 @@ subroutine compute_frontogenesis(frontgf,frontga,tl,use_fgf_pgrad_correction,ele
237235
else ! .not. use_fgf_pgrad_correction
238236

239237
do k = 1,nlev
240-
! pressure at mid points
241-
p(:,:) = hvcoord%hyam(k)*hvcoord%ps0 + hvcoord%hybm(k)*elem(ie)%state%ps_v(:,:,tl)
238+
! pressure at mid points - this pressure preserves the old behavior of E3SMv3 and prior
239+
pmid(:,:,k) = hvcoord%hyam(k)*hvcoord%ps0 + hvcoord%hybm(k)*elem(ie)%state%ps_v(:,:,tl)
242240
! potential temperature: theta = T (p/p0)^kappa
243241
call get_temperature(elem(ie),temperature,hvcoord,tl)
244-
theta(:,:,k) = temperature(:,:,k)*(psurf_ref / p(:,:))**kappa
242+
theta(:,:,k) = temperature(:,:,k)*(psurf_ref / pmid(:,:,k))**kappa
245243
gradth_gll(:,:,:,k,ie) = gradient_sphere(theta(:,:,k),deriv1,elem(ie)%Dinv)
246244
! compute C = (grad(theta) dot grad ) u
247245
C(:,:,:) = ugradv_sphere(gradth_gll(:,:,:,k,ie), elem(ie)%state%v(:,:,:,k,tl),deriv1,elem(ie))

0 commit comments

Comments
 (0)