Skip to content

Commit

Permalink
Merge pull request #270 from GEOS-ESM/feature/mmanyin/cape_from_moist
Browse files Browse the repository at this point in the history
Slightly improve lightning flash rates
  • Loading branch information
mmanyin authored Dec 20, 2023
2 parents a754644 + b22f25c commit f56ecb7
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 31 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Connectivity from GMI to ACHEM (4 fields)
- Connectivity from GMI to ACHEM (4 fields), requires GMI v1.2.0 or later to run
- Slight improvement for lightning flash rate calculation (LOPEZ and MOIST schemes). See the option UsePreconCape in ChemEnv.rc . This involves new imports from MOIST: CAPE, BYNCY and INHB. **NOTE** THIS REQUIRES GEOSgcm_GridComp develop branch (as of 12/12/23).

### Removed

Expand Down
8 changes: 5 additions & 3 deletions ChemEnv.rc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ MOIST_flashFactor_resvec_REPLAY: 2.0 2.0 2.0 1.84 1.84
FIT_flashFactor_resvec_REPLAY: 1.0 1.0 1.0 1.0 1.0 1.0

# originally called 'alpha'
LOPEZ_flashFactor_resvec_CTM: 37.5 37.5 37.5 37.5 37.5 37.5
LOPEZ_flashFactor_resvec_FREE: 37.5 37.5 37.5 37.5 37.5 37.5
LOPEZ_flashFactor_resvec_REPLAY: 37.5 37.5 37.5 37.5 37.5 37.5
LOPEZ_flashFactor_resvec_CTM: 37.5 37.5 37.5 37.5 165300 37.5
LOPEZ_flashFactor_resvec_FREE: 37.5 37.5 37.5 37.5 165300 37.5
LOPEZ_flashFactor_resvec_REPLAY: 37.5 37.5 37.5 37.5 165300 37.5

# originally called 'otdLisScale'
# NOTE: testing (Nov2020) indicated c-90 value of 9.48e-3 might be better
Expand All @@ -34,3 +34,5 @@ HEMCO_flashFactor_resvec_REPLAY: 0.6 0.355 0.1 2.095e-2 7.024e-
lightNOampFactor: 1.07
numberNOperFlash: 1.50e+26
minDeepCloudTop: 7.0

usePreconCape: TRUE
41 changes: 39 additions & 2 deletions GEOS_ChemEnvGridComp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module GEOS_ChemEnvGridCompMod
real :: FIT_flashFactor
real :: HEMCO_flashFactor
real :: LOPEZ_flashFactor
logical :: usePreconCape ! use CAPE, INHB and BYNCY from MOIST

! May change during the course of the run:
integer :: year_for_ratio = 0
Expand Down Expand Up @@ -369,6 +370,30 @@ subroutine SetServices ( GC, RC )
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)

call MAPL_AddImportSpec(GC, &
SHORT_NAME ='BYNCY', &
LONG_NAME ='buoyancy_of surface_parcel', &
UNITS ='m s-2', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzVert, &
VLOCATION = MAPL_VLocationCenter, __RC__)

call MAPL_AddImportSpec(GC, &
SHORT_NAME ='CAPE', &
LONG_NAME ='cape_for_surface_parcel', &
UNITS ='J kg-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)

call MAPL_AddImportSpec(GC, &
SHORT_NAME ='INHB', &
LONG_NAME ='inhibition_for_surface_parcel', &
UNITS ='J kg-1', &
RESTART = MAPL_RestartSkip, &
DIMS = MAPL_DimsHorzOnly, &
VLOCATION = MAPL_VLocationNone, __RC__)


! !EXPORT STATE:

Expand Down Expand Up @@ -734,13 +759,16 @@ subroutine Initialize_ ( GC, impChem, expChem, clock, RC )
numberNOperFlash, &
MOIST_flashFactor, FIT_flashFactor, &
HEMCO_flashFactor, LOPEZ_flashFactor, &
usePreconCape, &
__RC__ )

IF(MAPL_AM_I_ROOT()) THEN
if ( flash_source_enum == FLASH_SOURCE_MOIST ) PRINT*,'MOIST_flashFactor is ',MOIST_flashFactor
if ( flash_source_enum == FLASH_SOURCE_FIT ) PRINT*, ' FIT_flashFactor is ', FIT_flashFactor
if ( flash_source_enum == FLASH_SOURCE_FIT ) PRINT*,' FIT_flashFactor is ', FIT_flashFactor
if ( flash_source_enum == FLASH_SOURCE_HEMCO ) PRINT*,'HEMCO_flashFactor is ',HEMCO_flashFactor
if ( flash_source_enum == FLASH_SOURCE_LOPEZ ) PRINT*,'LOPEZ_flashFactor is ',LOPEZ_flashFactor

PRINT*,'usePreconCape = ', usePreconCape
ENDIF

RETURN_(ESMF_SUCCESS)
Expand Down Expand Up @@ -807,6 +835,10 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
real, pointer, dimension(:,:,:) :: PFI_CN => null()
real, pointer, dimension(:,:,:) :: CNV_QC => null()

real, pointer, dimension(:,:) :: CAPE_PRECON => null()
real, pointer, dimension(:,:) :: INHB_PRECON => null()
real, pointer, dimension(:,:,:) :: BYNCY_PRECON => null()

! Exports
real, pointer, dimension(:,:,:) :: delp => null()
real, pointer, dimension(:,:) :: LFR => null()
Expand Down Expand Up @@ -922,6 +954,10 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
call MAPL_GetPointer ( IMPORT, CNV_QC, 'CNV_QC', __RC__ )
call MAPL_GetPointer ( IMPORT, cellArea, 'AREA', __RC__ )

call MAPL_GetPointer ( IMPORT, CAPE_PRECON, 'CAPE', __RC__ )
call MAPL_GetPointer ( IMPORT, INHB_PRECON, 'INHB', __RC__ )
call MAPL_GetPointer ( IMPORT, BYNCY_PRECON, 'BYNCY', __RC__ )

BYNCY(:,:,:) = real(0)
CAPE(:,:) = real(0)
LFR(:,:) = real(0)
Expand Down Expand Up @@ -949,7 +985,8 @@ subroutine Run1 ( GC, IMPORT, EXPORT, CLOCK, RC )
TS, CNV_MFC, CNV_QC, T, TH, PFI_CN, PLE, Q, ZLE, &
minDeepCloudTop, lightNOampFactor, numberNOperFlash, &
MOIST_flashFactor, FIT_flashFactor, HEMCO_flashFactor, LOPEZ_flashFactor, &
CNV_MFD, CAPE, BYNCY, LFR, LIGHT_NO_PROD, PHIS, &
CNV_MFD, usePreconCape, CAPE_PRECON, INHB_PRECON, BYNCY_PRECON, &
CAPE, BYNCY, LFR, LIGHT_NO_PROD, PHIS, &
__RC__)

! call pmaxmin('LFR', LFR, flashRateMin, flashRateMax, nc, 1, 1.)
Expand Down
107 changes: 82 additions & 25 deletions Shared/Chem_Shared/Lightning_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ subroutine getLightning (GC, ggState, CLOCK, &
PFICU, PLE, Q, ZLE, &
minDeepCloudTop, lightNOampFactor, numberNOperFlash, &
MOIST_flashFactor, FIT_flashFactor, HEMCO_flashFactor, LOPEZ_flashFactor, &
CNV_MFD, CAPE, BYNCY, flashRate, light_NO_prod, PHIS, &
CNV_MFD, usePreconCape, CAPE_PRECON, INHB_PRECON, BYNCY_PRECON, &
CAPE, BYNCY, flashRate, light_NO_prod, PHIS, &
RC)

type(ESMF_GridComp), intent(inout) :: GC ! Gridded component
Expand Down Expand Up @@ -187,6 +188,15 @@ subroutine getLightning (GC, ggState, CLOCK, &
real, intent(in) :: numberNOperFlash ! NO molecules generated by each flash
real, dimension(:,:,:), intent(in) :: CNV_MFD ! detraining_mass_flux (kg m-2 s-1) [top-down]

logical, intent(in) :: usePreconCape ! Whether to use CAPE, INHB and BYNCY from MOIST
! (only affects LOPEZ and MOIST)
! LOPEZ only uses CAPE, and should benefit from PRECON
! MOIST prefers CAPE computed using the old MERRA2 approach
! which needs BYNCY, so may benefit from PRECON
real, dimension(:,:), intent(in) :: CAPE_PRECON
real, dimension(:,:), intent(in) :: INHB_PRECON
real, dimension(:,:,:), intent(in) :: BYNCY_PRECON

real, dimension(:,:), intent(out) :: CAPE ! can remove these eventually
real, dimension(:,:,:), intent(out) :: BYNCY ! can remove these eventually [top-down]
real, dimension(:,:), intent(out) :: flashRate ! (flashes/km2/s)
Expand Down Expand Up @@ -233,7 +243,7 @@ subroutine getLightning (GC, ggState, CLOCK, &

logical, save :: first = .TRUE.
integer :: IM, JM, LM, K0, KM, nc
integer :: i, j, l, ls
integer :: i, j, L, ls
integer :: modelLevel ! only used for FIT
real(REAL64) :: ptop, pint

Expand Down Expand Up @@ -346,7 +356,14 @@ subroutine getLightning (GC, ggState, CLOCK, &

! callLopezCalcuations() put above end subroutine getLightning

call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB)
! MEM- Recommend PRECON, but leaving the other option available
if (usePreconCape) then
CAPE = CAPE_PRECON
INHB = INHB_PRECON
BYNCY = BYNCY_PRECON
else
call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB)
end if

ALLOCATE( flashRateLopez(IM, JM), STAT=STATUS); VERIFY_(STATUS)
flashRateLopez = real(0)
Expand Down Expand Up @@ -375,7 +392,13 @@ subroutine getLightning (GC, ggState, CLOCK, &
else if (flash_source_enum == FLASH_SOURCE_HEMCO) then

! The HEMCO flash routine may use BYNCY in the future
! call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB)
! if (usePreconCape) then
! CAPE = CAPE_PRECON
! INHB = INHB_PRECON
! BYNCY = BYNCY_PRECON
! else
! call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB)
! end if


call HEMCO_FlashRate (cellArea, LWI, LONSLOCAL, LATSLOCAL, T, PLE, &
Expand All @@ -396,8 +419,35 @@ subroutine getLightning (GC, ggState, CLOCK, &

DM(:,:,1:LM) = ( PLE(:,:,K0+1:KM)-PLE(:,:,K0:KM-1) ) * (1./MAPL_GRAV) ! DELP / g

call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB, &
DM=DM, CAPE_MERRA2=CAPE_MERRA2)
! (Don't use CAPE_PRECON since the units are different from CAPE_MERRA2)
! The MOIST approach wants CAPE computed in the old MERRA2 way
! which uses BYNCY, so usePreconCape really means usePreconBuoyancy in this case
! Probably best to use PRECON
if (usePreconCape) then

CAPE = CAPE_PRECON
INHB = INHB_PRECON
BYNCY = BYNCY_PRECON

CAPE_MERRA2(:,:) = 0.

do L=1,LM-1
where(BYNCY(:,:,L)>0.)
CAPE_MERRA2 = CAPE_MERRA2 + BYNCY(:,:,L)*DM(:,:,L)
end where
end do

where(CAPE_MERRA2 <= 0.0)
CAPE_MERRA2=MAPL_UNDEF
end where

else
call BUOYANCY (T, Q, QSS, DQS, DZ, ZLO, BYNCY, CAPE, INHB, &
DM=DM, CAPE_MERRA2=CAPE_MERRA2)
end if




! Determine the pressure at convective cloud top

Expand Down Expand Up @@ -592,12 +642,13 @@ end subroutine read_flash_source
!EOP
!-----------------------------------------------------------------------

subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, &
SimType, &
ratioGlobalFile, minDeepCloudTop, &
lightNOampFactor, numberNOperFlash, &
MOIST_flashFactor, FIT_flashFactor, &
subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, &
SimType, &
ratioGlobalFile, minDeepCloudTop, &
lightNOampFactor, numberNOperFlash, &
MOIST_flashFactor, FIT_flashFactor, &
HEMCO_flashFactor, LOPEZ_flashFactor, &
usePreconCape, &
RC )

! IN:
Expand All @@ -615,6 +666,7 @@ subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, &
real, intent(out) :: FIT_flashFactor
real, intent(out) :: HEMCO_flashFactor
real, intent(out) :: LOPEZ_flashFactor
logical, intent(out) :: usePreconCape
integer, optional, intent(out) :: RC

! Local vars:
Expand Down Expand Up @@ -699,6 +751,10 @@ subroutine read_lightning_config ( im, jm, rcfilen, flash_source_enum, &
Label = "numberNOperFlash:", &
Default = 1.50E+26, __RC__ )

call ESMF_ConfigGetAttribute(esmfConfig, usePreconCape, &
Label = "usePreconCape:", &
Default = .TRUE., __RC__ )

call ESMF_ConfigDestroy(esmfConfig, __RC__)

end subroutine read_lightning_config
Expand Down Expand Up @@ -1517,20 +1573,21 @@ subroutine LOPEZ_FlashRate(IM, JM, LM, FRLAND, ZKBCON, CAPE, &
real, dimension(1:lm) :: q_graup,q_snow,rho


!!! DEBUGGING
! print*, ""
! print*, "Hello from LOPEZ_FlashRate"
! print*, ""

print*, ""
print*, "Hello from LOPEZ_FlashRate"
print*, ""

print*, "im, jm, lm: ", im, jm, lm
print*, "FRLAND: ", minval(FRLAND), maxval(FRLAND)
print*, "CAPE: ", minval(CAPE), maxval(CAPE)
print*, "ZLE: ", minval(ZLE), maxval(ZLE)
print*, "PFI_CN_GF ", minval(PFI_CN_GF), maxval(PFI_CN_GF)
print*, "TE: ", minval(TE), maxval(TE)
print*, "PLO: ", minval(PLO), maxval(PLO)
print*, "CNV_QC: ", minval(CNV_QC), maxval(CNV_QC)
print*, "zkbcon: ", minval(zkbcon), maxval(zkbcon)
! print*, "im, jm, lm: ", im, jm, lm
! print*, "FRLAND: ", minval(FRLAND), maxval(FRLAND)
! print*, "CAPE: ", minval(CAPE), maxval(CAPE)
! print*, "ZLE: ", minval(ZLE), maxval(ZLE)
! print*, "PFI_CN_GF ", minval(PFI_CN_GF), maxval(PFI_CN_GF)
! print*, "TE: ", minval(TE), maxval(TE)
! print*, "PLO: ", minval(PLO), maxval(PLO)
! print*, "CNV_QC: ", minval(CNV_QC), maxval(CNV_QC)
! print*, "zkbcon: ", minval(zkbcon), maxval(zkbcon)
!!!

DO j = 1, jm
DO i = 1, im
Expand Down Expand Up @@ -1574,7 +1631,7 @@ subroutine LOPEZ_FlashRate(IM, JM, LM, FRLAND, ZKBCON, CAPE, &
endif
if ( te(i,j,k) < t_final ) exit
enddo
print*,'K final, initial: ', k_final, k_initial
! print*,'K final, initial: ', k_final, k_initial

Q_R = 0.0
do k = k_final, k_initial
Expand Down

0 comments on commit f56ecb7

Please sign in to comment.