Skip to content

Commit

Permalink
Merge pull request NCAR#60 from SamuelTrahanNOAA/bugfix/haiqin-wetdep
Browse files Browse the repository at this point in the history
Only use wetdpc_shal and wetdpc_deep if they're allocated.
  • Loading branch information
DomHeinzeller authored Nov 10, 2020
2 parents c17ed37 + 1ea6bac commit f2b0bdd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 12 deletions.
17 changes: 11 additions & 6 deletions physics/samfdeepcnv.f
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
& CNV_DQLDT,CLCN,CNV_FICE,CNV_NDROP,CNV_NICE,mp_phys,mp_phys_mg,&
& clam,c0s,c1,betal,betas,evfact,evfactl,pgcon,asolfac, &
& do_ca, ca_closure, ca_entr, ca_trigger, nthresh, ca_deep, &
& rainevap,wetdpc_deep, &
& rainevap,wetdpc_deep,cplchm, &
& errmsg,errflg)
!
use machine , only : kind_phys
Expand Down Expand Up @@ -236,7 +236,8 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
& ctr(im,km,ntr), ctro(im,km,ntr)
! for aerosol transport
real(kind=kind_phys) qaero(im,km,ntc)
real(kind=kind_phys) wetdpc_deep(im,ntc)
real(kind=kind_phys), intent(inout), optional :: wetdpc_deep(:,:)
logical, intent(in) :: cplchm
! for updraft velocity calculation
real(kind=kind_phys) wu2(im,km), buo(im,km), drag(im,km)
real(kind=kind_phys) wc(im), scaldfunc(im), sigmagfm(im)
Expand Down Expand Up @@ -341,7 +342,9 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
vshear(i) = 0.
rainevap(i) = 0.
gdx(i) = sqrt(garea(i))
wetdpc_deep(i,:) = 0.
if(cplchm) then
wetdpc_deep(i,:) = 0.
endif
enddo
!
if (hwrf_samfdeep) then
Expand Down Expand Up @@ -2872,9 +2875,11 @@ subroutine samfdeepcnv_run (im,km,itc,ntc,cliq,cp,cvap, &
!if (k <= kmax(i)) qtr(i,k,kk) = qaero(i,k,n)
if (k <= kmax(i)) then !lzhang
!convert wetdeposition into ug/m2/s !lzhang
wetdpc_deep(i,n) = wetdpc_deep(i,n)
& + ((qtr(i,k,kk)-qaero(i,k,n))*delp(i,k)/(grav*delt))
qtr(i,k,kk) = qaero(i,k,n)
if(cplchm) then
wetdpc_deep(i,n) = wetdpc_deep(i,n)
& + ((qtr(i,k,kk)-qaero(i,k,n))*delp(i,k)/(grav*delt))
endif
qtr(i,k,kk) = qaero(i,k,n)
endif
endif
enddo
Expand Down
8 changes: 8 additions & 0 deletions physics/samfdeepcnv.meta
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,14 @@
kind = kind_phys
intent = out
optional = F
[cplchm]
standard_name = flag_for_chemistry_coupling
long_name = flag controlling cplchm collection (default off)
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
Expand Down
17 changes: 11 additions & 6 deletions physics/samfshalcnv.f
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
& t0c,delt,ntk,ntr,delp, &
& prslp,psp,phil,qtr,q1,t1,u1,v1,fscav, &
& rn,kbot,ktop,kcnv,islimsk,garea, &
& dot,ncloud,hpbl,ud_mf,dt_mf,cnvw,cnvc,wetdpc_shal, &
& dot,ncloud,hpbl,ud_mf,dt_mf,cnvw,cnvc,wetdpc_shal,cplchm, &
& clam,c0s,c1,pgcon,asolfac,hwrf_samfshal,errmsg,errflg)
!
use machine , only : kind_phys
Expand Down Expand Up @@ -180,7 +180,8 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
& ctr(im,km,ntr), ctro(im,km,ntr)
! for aerosol transport
real(kind=kind_phys) qaero(im,km,ntc)
real(kind=kind_phys) wetdpc_shal(im,ntc)
real(kind=kind_phys), intent(inout), optional :: wetdpc_shal(:,:)
logical, intent(in) :: cplchm
! for updraft velocity calculation
real(kind=kind_phys) wu2(im,km), buo(im,km), drag(im,km)
real(kind=kind_phys) wc(im), scaldfunc(im), sigmagfm(im)
Expand Down Expand Up @@ -286,7 +287,9 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
cina(i) = 0.
vshear(i) = 0.
gdx(i) = sqrt(garea(i))
wetdpc_shal(i,:)=0.
if(cplchm) then
wetdpc_shal(i,:)=0.
endif
enddo
endif
!!
Expand Down Expand Up @@ -1849,9 +1852,11 @@ subroutine samfshalcnv_run(im,km,itc,ntc,cliq,cp,cvap, &
!if (k <= kmax(i)) qtr(i,k,kk) = qaero(i,k,n)
if (k <= kmax(i)) then !lzhang
!convert wetdeposition into ug/m2/s !lzhang
wetdpc_shal(i,n)=wetdpc_shal(i,n)
& + ((qtr(i,k,kk)-qaero(i,k,n))*delp(i,k)/(grav*delt))
qtr(i,k,kk) = qaero(i,k,n)
if(cplchm) then
wetdpc_shal(i,n)=wetdpc_shal(i,n)
& +((qtr(i,k,kk)-qaero(i,k,n))*delp(i,k)/(grav*delt))
endif
qtr(i,k,kk) = qaero(i,k,n)
endif
endif
enddo
Expand Down
8 changes: 8 additions & 0 deletions physics/samfshalcnv.meta
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@
kind = kind_phys
intent = out
optional = F
[cplchm]
standard_name = flag_for_chemistry_coupling
long_name = flag controlling cplchm collection (default off)
units = flag
dimensions = ()
type = logical
intent = in
optional = F
[errmsg]
standard_name = ccpp_error_message
long_name = error message for error handling in CCPP
Expand Down

0 comments on commit f2b0bdd

Please sign in to comment.