Skip to content

Commit

Permalink
Merge pull request #819 from grantfirl/bugfix/tvd_gjf
Browse files Browse the repository at this point in the history
This PR implements a vertically-integrated formula to compute tracer column mass and ensure mass conservation for all tracers except TKE. The formula properly computes the tracer mass at each layer dm(z) taking into account that the air density rho(z) changes with altitude (z):

    dm(z) = rho(z) q(z) dz

where q(z) is the tracer mixing ratio.

This PR will change the baseline for all regression tests using Scale-Aware Mass-Flux (SAMF) shallow or deep convective schemes, as well as the Scale-aware TKE-based Moist Eddy-Diffusivity Mass-Flux (SATMEDMF) PBL scheme.

Resolves issue #811
  • Loading branch information
SamuelTrahanNOAA authored Jan 5, 2022
2 parents 1f907e4 + 4a37860 commit a5dcdce
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 28 deletions.
28 changes: 20 additions & 8 deletions physics/samfdeepcnv.f
Original file line number Diff line number Diff line change
Expand Up @@ -2975,11 +2975,12 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
tsump(i) = 0.
rtnp(i) = 1.
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if(cnvflg(i) .and. k <= ktcon(i)) then
if(q1(i,k) < 0.) tsumn(i) = tsumn(i) + q1(i,k)
if(q1(i,k) > 0.) tsump(i) = tsump(i) + q1(i,k)
tem = q1(i,k) * delp(i,k) / grav
if(q1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
if(q1(i,k) > 0.) tsump(i) = tsump(i) + tem
endif
enddo
enddo
Expand All @@ -2994,7 +2995,7 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
endif
endif
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if(cnvflg(i) .and. k <= ktcon(i)) then
if(rtnp(i) < 0.) then
Expand All @@ -3011,6 +3012,7 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
enddo
!
if (.not.hwrf_samfdeep) then
indx = ntk - 2
do n = 1, ntr
!
do k = 1, km
Expand All @@ -3033,11 +3035,21 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
tsump(i) = 0.
rtnp(i) = 1.
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if(cnvflg(i) .and. k <= ktcon(i)) then
if(ctr(i,k,n) < 0.) tsumn(i) = tsumn(i) + ctr(i,k,n)
if(ctr(i,k,n) > 0.) tsump(i) = tsump(i) + ctr(i,k,n)
if(n == indx) then
if(k > 1) then
dz = zi(i,k) - zi(i,k-1)
else
dz = zi(i,k)
endif
tem = ctr(i,k,n) * dz
else
tem = ctr(i,k,n) * delp(i,k) / grav
endif
if(ctr(i,k,n) < 0.) tsumn(i) = tsumn(i) + tem
if(ctr(i,k,n) > 0.) tsump(i) = tsump(i) + tem
endif
enddo
enddo
Expand All @@ -3052,7 +3064,7 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
endif
endif
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if(cnvflg(i) .and. k <= ktcon(i)) then
if(rtnp(i) < 0.) then
Expand Down
28 changes: 20 additions & 8 deletions physics/samfshalcnv.f
Original file line number Diff line number Diff line change
Expand Up @@ -1922,12 +1922,13 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
tsump(i) = 0.
rtnp(i) = 1.
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if (cnvflg(i)) then
if(k > kb(i) .and. k <= ktcon(i)) then
if(q1(i,k) < 0.) tsumn(i) = tsumn(i) + q1(i,k)
if(q1(i,k) > 0.) tsump(i) = tsump(i) + q1(i,k)
tem = q1(i,k) * delp(i,k) / grav
if(q1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
if(q1(i,k) > 0.) tsump(i) = tsump(i) + tem
endif
endif
enddo
Expand All @@ -1943,7 +1944,7 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
endif
endif
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if (cnvflg(i)) then
if(k > kb(i) .and. k <= ktcon(i)) then
Expand All @@ -1963,6 +1964,7 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
!
if (.not.hwrf_samfshal) then
!
indx = ntk - 2
do n = 1, ntr
!
do k = 1, km
Expand All @@ -1985,12 +1987,22 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
tsump(i) = 0.
rtnp(i) = 1.
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if (cnvflg(i)) then
if(k > kb(i) .and. k <= ktcon(i)) then
if(ctr(i,k,n) < 0.) tsumn(i) = tsumn(i) + ctr(i,k,n)
if(ctr(i,k,n) > 0.) tsump(i) = tsump(i) + ctr(i,k,n)
if(n == indx) then
if(k > 1) then
dz = zi(i,k) - zi(i,k-1)
else
dz = zi(i,k)
endif
tem = ctr(i,k,n) * dz
else
tem = ctr(i,k,n) * delp(i,k) / grav
endif
if(ctr(i,k,n) < 0.) tsumn(i) = tsumn(i) + tem
if(ctr(i,k,n) > 0.) tsump(i) = tsump(i) + tem
endif
endif
enddo
Expand All @@ -2006,7 +2018,7 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
endif
endif
enddo
do k = 1,km
do k = 1,km1
do i = 1,im
if (cnvflg(i)) then
if(k > kb(i) .and. k <= ktcon(i)) then
Expand Down
32 changes: 20 additions & 12 deletions physics/satmedmfvdifq.F
Original file line number Diff line number Diff line change
Expand Up @@ -1515,8 +1515,10 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw,ntiw,ntke, &
endif
if((pcnvflg(i) .or. scuflg(i)) .and.
& (k >= kbx .and. k <= kmx)) then
if(f1(i,k) < 0.) tsumn(i) = tsumn(i) + f1(i,k)
if(f1(i,k) > 0.) tsump(i) = tsump(i) + f1(i,k)
dz = zi(i,k+1) - zi(i,k)
tem = f1(i,k) * dz
if(f1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
if(f1(i,k) > 0.) tsump(i) = tsump(i) + tem
endif
enddo
enddo
Expand Down Expand Up @@ -1569,8 +1571,10 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw,ntiw,ntke, &
enddo
do k = 1,km
do i = 1,im
if(f1(i,k) < 0.) tsumn(i) = tsumn(i) + f1(i,k)
if(f1(i,k) > 0.) tsump(i) = tsump(i) + f1(i,k)
dz = zi(i,k+1) - zi(i,k)
tem = f1(i,k) * dz
if(f1(i,k) < 0.) tsumn(i) = tsumn(i) + tem
if(f1(i,k) > 0.) tsump(i) = tsump(i) + tem
enddo
enddo
do i = 1,im
Expand Down Expand Up @@ -1760,8 +1764,9 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw,ntiw,ntke, &
endif
if((pcnvflg(i) .or. scuflg(i)) .and.
& (k >= kbx .and. k <= kmx)) then
if(f2(i,k) < 0.) tsumn(i) = tsumn(i) + f2(i,k)
if(f2(i,k) > 0.) tsump(i) = tsump(i) + f2(i,k)
tem = f2(i,k) * del(i,k) / grav
if(f2(i,k) < 0.) tsumn(i) = tsumn(i) + tem
if(f2(i,k) > 0.) tsump(i) = tsump(i) + tem
endif
enddo
enddo
Expand Down Expand Up @@ -1815,8 +1820,9 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw,ntiw,ntke, &
enddo
do k = 1,km
do i = 1,im
if(f2(i,k) < 0.) tsumn(i) = tsumn(i) + f2(i,k)
if(f2(i,k) > 0.) tsump(i) = tsump(i) + f2(i,k)
tem = f2(i,k) * del(i,k) / grav
if(f2(i,k) < 0.) tsumn(i) = tsumn(i) + tem
if(f2(i,k) > 0.) tsump(i) = tsump(i) + tem
enddo
enddo
do i = 1,im
Expand Down Expand Up @@ -1943,8 +1949,9 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw,ntiw,ntke, &
endif
if((pcnvflg(i) .or. scuflg(i)) .and.
& (k >= kbx .and. k <= kmx)) then
if(f2(i,k+is) < 0.) tsumn(i) = tsumn(i) + f2(i,k+is)
if(f2(i,k+is) > 0.) tsump(i) = tsump(i) + f2(i,k+is)
tem = f2(i,k+is) * del(i,k) / grav
if(f2(i,k+is) < 0.) tsumn(i) = tsumn(i) + tem
if(f2(i,k+is) > 0.) tsump(i) = tsump(i) + tem
endif
enddo
enddo
Expand Down Expand Up @@ -1998,8 +2005,9 @@ subroutine satmedmfvdifq_run(im,km,ntrac,ntcw,ntrw,ntiw,ntke, &
enddo
do k = 1,km
do i = 1,im
if(f2(i,k+is) < 0.) tsumn(i) = tsumn(i) + f2(i,k+is)
if(f2(i,k+is) > 0.) tsump(i) = tsump(i) + f2(i,k+is)
tem = f2(i,k+is) * del(i,k) / grav
if(f2(i,k+is) < 0.) tsumn(i) = tsumn(i) + tem
if(f2(i,k+is) > 0.) tsump(i) = tsump(i) + tem
enddo
enddo
do i = 1,im
Expand Down

0 comments on commit a5dcdce

Please sign in to comment.