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

Enforce tracer column mass conservation in TVD schemes #812

Merged
merged 1 commit into from
Jan 5, 2022
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
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