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 Lightning Potential Index calculation failure #1836

Merged
merged 1 commit into from
Mar 30, 2023
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 Registry/Registry.EM_COMMON
Original file line number Diff line number Diff line change
Expand Up @@ -3310,7 +3310,7 @@ package ltng_none lightning_option==0 - -
package ltng_crm_PR92w lightning_option==1 - state:ic_flashcount,ic_flashrate,cg_flashcount,cg_flashrate
package ltng_crm_PR92z lightning_option==2 - state:ic_flashcount,ic_flashrate,cg_flashcount,cg_flashrate
package ltng_cpm_PR92z lightning_option==11 - state:ic_flashcount,ic_flashrate,cg_flashcount,cg_flashrate
package ltng_lpi lightning_option==3 - state:lpi
package ltng_lpi lightning_option==3 - state:lpi,ic_flashcount,ic_flashrate,cg_flashcount,cg_flashrate
# only need to specify these once; not for every io_form* variable
package io_intio io_form_restart==1 - -
package io_netcdf io_form_restart==2 - -
Expand Down
26 changes: 14 additions & 12 deletions phys/module_lightning_driver.F
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,21 @@ SUBROUTINE lightning_driver ( &
)

! LPI lightning options
#if (EM_CORE==1)
CASE( ltng_lpi )
CALL wrf_debug ( 100, ' lightning_driver: calling Light Potential Index' )
IF(F_QG) THEN
CALL calclpi(W=w, &
Z=z, &
PI_PHY=pi_phy, RHO_PHY=rho, &
TH_PHY=TH_PHY,P_PHY=p_phy, &
Z=z, &
PI_PHY=pi_phy, RHO_PHY=rho, &
TH_PHY=TH_PHY,P_PHY=p_phy, &
DZ8w=dz8w, &
QV=moist(ims,kms,jms,P_QV), & !Qv=qv_curr, &
QC=moist(ims,kms,jms,P_QC), & !Qc=qc_curr, &
QR=moist(ims,kms,jms,P_QR), & !QR=qr_curr, &
QI=moist(ims,kms,jms,P_QI), & !QI=qi_curr, &
QS=moist(ims,kms,jms,P_QS), & !qs_curr, &
QG=moist(ims,kms,jms,P_QG), & !qg_curr, &
QH=moist(ims,kms,jms,P_QH), & !qh_curr, &
QV=moist(ims,kms,jms,P_QV), & !Qv=qv_curr
QC=moist(ims,kms,jms,P_QC), & !Qc=qc_curr
QR=moist(ims,kms,jms,P_QR), & !QR=qr_curr
QI=moist(ims,kms,jms,P_QI), & !QI=qi_curr
QS=moist(ims,kms,jms,P_QS), & !qs_curr
QG=moist(ims,kms,jms,P_QG), & !qg_curr
! QH=moist(ims,kms,jms,P_QH), & !qh_curr
lpi=lpi &
,IDS=ids,IDE=ide, JDS=jds,JDE=jde, KDS=kds,KDE=kde &
,IMS=ims,IME=ime, JMS=jms,JME=jme, KMS=kms,KME=kme &
Expand All @@ -437,7 +436,7 @@ SUBROUTINE lightning_driver ( &
WRITE(wrf_err_message, * ) ' lightning_driver: LPI option needs Microphysics Option with Graupel '
CALL wrf_error_fatal ( wrf_err_message )
ENDIF
#endif

! CASE ( another_cpm_option)

! Invalid lightning options
Expand All @@ -447,6 +446,8 @@ SUBROUTINE lightning_driver ( &

END SELECT flashrate_select

IF (lightning_option.eq.3) GOTO 100

!-----------------------------------------------------------------

CALL wrf_debug ( 100, ' lightning_driver: partitioning IC:CG')
Expand Down Expand Up @@ -584,6 +585,7 @@ SUBROUTINE lightning_driver ( &
ic_flashcount(its:ite,jts:jte) = ic_flashcount(its:ite,jts:jte) + ic_flashrate(its:ite,jts:jte) * lightning_dt
cg_flashcount(its:ite,jts:jte) = cg_flashcount(its:ite,jts:jte) + cg_flashrate(its:ite,jts:jte) * lightning_dt

100 CONTINUE
do
if( REAL(ltngacttime,8) <= nextTime ) then
ltngacttime = ltngacttime + lightning_dt
Expand Down
24 changes: 14 additions & 10 deletions phys/module_ltng_lpi.F
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ MODULE module_ltng_lpi
! However, we don't check for collapsing cell (so as not to require use of halo).
! This means that lpi is also calculated in cells that are no longer (on average) growing
! For a "complete" lightning forecast scheme, please see:
!http:https://journals.ametsoc.org/doi/abs/10.1175/WAF-D-11-00144.1
!https:https://doi.org/10.1175/WAF-D-11-00144.1
!(Predicting Cloud-to-Ground and Intracloud Lightning in Weather Forecast Models)

CONTAINS
!===================================================================
!
SUBROUTINE calclpi(qv,qc, qr, qi, qs, qg, qh &
,w,z,dz8w,pi_phy,th_phy,p_phy,rho_phy &
,lpi&
SUBROUTINE calclpi(qv,qc, qr, qi, qs, qg &
,w,z,dz8w,pi_phy,th_phy,p_phy,rho_phy &
,lpi &
,ids,ide, jds,jde, kds,kde &
,ims,ime, jms,jme, kms,kme &
,its,ite, jts,jte, kts,kte &
Expand All @@ -35,7 +35,7 @@ SUBROUTINE calclpi(qv,qc, qr, qi, qs, qg, qh &
qi, &
qr, &
qs, &
qg,qh
qg

REAL, DIMENSION( ims:ime, kms:kme, jms:jme ), &
INTENT(IN ) :: w, z
Expand Down Expand Up @@ -85,7 +85,7 @@ SUBROUTINE calclpi(qv,qc, qr, qi, qs, qg, qh &
qc1d(k)=qc(i,k,j)
ql1d(k)=qc(i,k,j)+qr(i,k,j)
qi1d(k)=qi(i,k,j)
qti1d(k)=qi(i,k,j)+qs(i,k,j)+qg(i,k,j)+qh(i,k,j)
qti1d(k)=qi(i,k,j)+qs(i,k,j)+qg(i,k,j)
qs1d(k)=qs(i,k,j)
! qg1d(k)=qg(i,k,j)+qh(i,k,j)
! Hail doesn't usually charge
Expand All @@ -103,6 +103,7 @@ SUBROUTINE calclpi(qv,qc, qr, qi, qs, qg, qh &
END DO
return
end subroutine calclpi

subroutine &
& calc_lpi(ql3d,qi3d,qs3d,qg3d,w3d,t3d,height,lpi,t_base,t_top,nk,nke)
implicit none
Expand All @@ -125,6 +126,9 @@ end subroutine calclpi
real num_s,den_s
real num_i,den_i
real q_isg
real small_num

small_num=1.e-10
icnt=0
do k=1,nke
top=height(k)
Expand All @@ -138,26 +142,27 @@ end subroutine calclpi
ave_z=0
del_z_tot=0
lpi=0

do k=1,nke-1
if (t3d(k).le.t_base.and.t3d(k).gt.t_top)then ! set temp range

den_i = qi3d(k)+qg3d(k)
den_s = qs3d(k)+qg3d(k)
if (qs3d(k).eq.0.or.qg3d(k).eq.0.)then !checks for zeroes
if (qs3d(k).le.small_num.or.qg3d(k).le.small_num)then !checks for zeroes
den_s=10000.
num_s = 0.
else
num_s = sqrt(qs3d(k)*qg3d(k))
end if
if (qi3d(k).eq.0.or.qg3d(k).eq.0.)then ! checks for zeroes
if (qi3d(k).le.small_num.or.qg3d(k).le.small_num)then ! checks for zeroes
den_i=10000.
num_i = 0.
else
num_i = sqrt(qi3d(k)*qg3d(k))
end if
q_isg = qg3d(k)*(num_i/den_i+num_s/den_s) ! ice "fract"-content

if (ql3d(k).eq.0.or.q_isg.eq.0)then
if (ql3d(k).le.small_num.or.q_isg.eq.0)then
num=0
den=10000.
else
Expand All @@ -173,7 +178,6 @@ end subroutine calclpi
!
if (del_z_tot.eq.0)del_z_tot=100000
lpi=ave_z/del_z_tot

!
return
end subroutine calc_lpi
Expand Down