Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix virtual potential temperature in the total energy calculation #326

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion model/fv_dynamics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ subroutine fv_dynamics(npx, npy, npz, nq_tot, ng, bdt, consv_te, fill,
!---------------------
if ( (consv_te > 0. .or. idiag%id_te>0) .and. (.not.do_adiabatic_init) ) then
call compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, npz, &
u, v, w, delz, pt, delp, q, dp1, pe, peln, phis, &
u, v, w, delz, pt, delp, q, dp1, q_con, pe, peln, phis, &
gridstruct%rsin2, gridstruct%cosa_s, &
zvir, cp_air, rdgas, hlv, te_2d, ua, va, teq, &
flagstruct%moist_phys, nwat, sphum, liq_wat, rainwat, &
Expand Down
10 changes: 7 additions & 3 deletions model/fv_mapz.F90
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ end subroutine Lagrangian_to_Eulerian


subroutine compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, km, &
u, v, w, delz, pt, delp, q, qc, pe, peln, hs, &
u, v, w, delz, pt, delp, q, qc, q_con, pe, peln, hs, &
rsin2_l, cosa_s_l, &
r_vir, cp, rg, hlv, te_2d, ua, va, teq, &
moist_phys, nwat, sphum, liq_wat, rainwat, ice_wat, snowwat, graupel, hydrostatic, id_te)
Expand All @@ -913,7 +913,7 @@ subroutine compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, km, &
real, intent(inout), dimension(isd:ied,jsd:jed,km):: ua, va
real, intent(in), dimension(isd:ied,jsd:jed,km):: pt, delp
real, intent(in), dimension(isd:ied,jsd:jed,km,*):: q
real, intent(in), dimension(isd:ied,jsd:jed,km):: qc
real, intent(in), dimension(isd:ied,jsd:jed,km):: qc, q_con
real, intent(inout):: u(isd:ied, jsd:jed+1,km)
real, intent(inout):: v(isd:ied+1,jsd:jed, km)
real, intent(in):: w(isd:,jsd:,1:) ! vertical velocity (m/s)
Expand All @@ -939,7 +939,7 @@ subroutine compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, km, &
!----------------------
! call cubed_to_latlon(u, v, ua, va, dx, dy, rdxa, rdya, km, flagstruct%c2l_ord)

!$OMP parallel do default(none) shared(is,ie,js,je,isd,ied,jsd,jed,km,hydrostatic,hs,pt,qc,rg,peln,te_2d, &
!$OMP parallel do default(none) shared(is,ie,js,je,isd,ied,jsd,jed,km,hydrostatic,hs,pt,qc,q_con,rg,peln,te_2d, &
!$OMP pe,delp,cp,rsin2_l,u,v,cosa_s_l,delz,moist_phys,w, &
!$OMP q,nwat,liq_wat,rainwat,ice_wat,snowwat,graupel,sphum) &
!$OMP private(phiz, tv, cvm, qd)
Expand All @@ -952,7 +952,11 @@ subroutine compute_total_energy(is, ie, js, je, isd, ied, jsd, jed, km, &
enddo
do k=km,1,-1
do i=is,ie
#ifdef USE_COND
tv(i,k) = pt(i,j,k)*(1.+qc(i,j,k))*(1-q_con(i,j,k))
#else
tv(i,k) = pt(i,j,k)*(1.+qc(i,j,k))
#endif
phiz(i,k) = phiz(i,k+1) + rg*tv(i,k)*(peln(i,k+1,j)-peln(i,k,j))
enddo
enddo
Expand Down