Skip to content

cam6_4_032: Use same cloud water for radiation and COSP. #1084

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

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 9 additions & 13 deletions src/control/cam_snapshot_common.F90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module cam_snapshot_common


! This is the number of pbuf fields in the CAM code that are declared with the fieldname as opposed to being data driven.
integer, parameter :: npbuf_all = 327
integer, parameter :: npbuf_all = 323

type snapshot_type
character(len=40) :: ddt_string
Expand Down Expand Up @@ -1335,8 +1335,6 @@ subroutine fill_pbuf_info(pbuf_info, pbuf, const_cname)
'DLFZM ','kg/kg/s ',&
'DNIFZM ','1/kg/s ',&
'DNLFZM ','1/kg/s ',&
'DP_CLDICE ','unset ',&
'DP_CLDLIQ ','unset ',&
'DP_FLXPRC ','unset ',&
'DP_FLXSNW ','unset ',&
'DP_FRAC ','unset ',&
Expand Down Expand Up @@ -1427,11 +1425,11 @@ subroutine fill_pbuf_info(pbuf_info, pbuf, const_cname)
'QCWAT ','unset ',&
'QFLX ','kg/m2/s ',&
'QFLX_RES ','unset ',&
'QINI ','unset ' /), (/2,100/))
'QINI ','unset ',&
'qir_det ','kg/kg ',&
'QIST ','unset '/), (/2,100/))

pbuf_all(1:2,201:300) = reshape ( (/ &
'qir_det ','kg/kg ',&
'QIST ','unset ',&
'qlr_det ','kg/kg ',&
'QLST ','unset ',&
'QME ','unset ',&
Expand Down Expand Up @@ -1470,9 +1468,7 @@ subroutine fill_pbuf_info(pbuf_info, pbuf, const_cname)
'SD ','unset ',&
'SGH30 ','unset ',&
'SGH ','unset ',&
'SH_CLDICE1 ','unset ',&
'SH_CLDICE ','unset ',&
'SH_CLDLIQ1 ','unset ',&
'SH_CLDLIQ ','unset ',&
'SH_E_ED_RATIO ','unset ',&
'SHFLX ','W/m2 ',&
Expand Down Expand Up @@ -1529,13 +1525,13 @@ subroutine fill_pbuf_info(pbuf_info, pbuf, const_cname)
'UP2_nadv ','unset ',&
'UPWP ','m^2/s^2 ',&
'UZM ','M/S ',&
'VI ','m/s ' /), (/2,100/))

pbuf_all(1:2,301:npbuf_all) = reshape ( (/ &
'VI ','m/s ',&
'VM ','m/s ',&
'VOLC_MMR ','unset ',&
'VOLC_RAD_GEOM ','unset ',&
'VP2_nadv ','unset ',&
'VP2_nadv ','unset '/), (/2,100/))

pbuf_all(1:2,301:npbuf_all) = reshape ( (/ &
'VPWP ','m^2/s^2 ',&
'went ','m/s ',&
'WETDENS_AP ','unset ',&
Expand All @@ -1558,7 +1554,7 @@ subroutine fill_pbuf_info(pbuf_info, pbuf, const_cname)
'ZM_MAXG ','unset ',&
'ZM_MD ','unset ',&
'ZM_MU ','unset ',&
'ZTODT ','unset ' /), (/2,27/))
'ZTODT ','unset '/), (/2,23/))

! Fields which are added with pbuf_add_field calls, but are data driven. These are not
! included in the above list. This means that these fields will not have proper units
Expand Down
23 changes: 18 additions & 5 deletions src/physics/cam/cloud_diagnostics.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ module cloud_diagnostics
integer :: cldtau_idx = -1
integer :: nmxrgn_idx = -1
integer :: pmxrgn_idx = -1
integer :: gb_totcldliqmr_idx = -1
integer :: gb_totcldicemr_idx = -1

! Index fields for precipitation efficiency.
integer :: acpr_idx, acgcme_idx, acnum_idx
Expand Down Expand Up @@ -103,6 +105,10 @@ subroutine cloud_diagnostics_init(pbuf2d)
!-----------------------------------------------------------------------

cld_idx = pbuf_get_index('CLD')
! grid box total cloud liquid water mixing ratio (kg/kg)
gb_totcldliqmr_idx = pbuf_get_index('GB_TOTCLDLIQMR')
! grid box total cloud ice water mixing ratio (kg/kg)
gb_totcldicemr_idx = pbuf_get_index('GB_TOTCLDICEMR')

call phys_getopts(use_spcam_out=use_spcam)

Expand Down Expand Up @@ -254,6 +260,9 @@ subroutine cloud_diagnostics_calc(state, pbuf)
integer, pointer :: nmxrgn(:) ! Number of maximally overlapped regions
real(r8), pointer :: pmxrgn(:,:) ! Maximum values of pressure for each

real(r8), pointer :: totg_ice(:,:) ! grid box total cloud ice mixing ratio
real(r8), pointer :: totg_liq(:,:) ! grid box total cloud liquid mixing ratio

integer :: itim_old

real(r8) :: cwp (pcols,pver) ! in-cloud cloud (total) water path
Expand Down Expand Up @@ -306,6 +315,9 @@ subroutine cloud_diagnostics_calc(state, pbuf)
itim_old = pbuf_old_tim_idx()
call pbuf_get_field(pbuf, cld_idx, cld, start=(/1,1,itim_old/), kount=(/pcols,pver,1/) )

call pbuf_get_field(pbuf, gb_totcldicemr_idx, totg_ice)
call pbuf_get_field(pbuf, gb_totcldliqmr_idx, totg_liq)

if(two_mom_clouds)then

call pbuf_get_field(pbuf, iclwp_idx, iclwp )
Expand Down Expand Up @@ -371,10 +383,9 @@ subroutine cloud_diagnostics_calc(state, pbuf)
! iclwp and iciwp to pass to the radiation. !
! ----------------------------------------------------------- !
if( conv_water_in_rad /= 0 ) then
allcld_ice(:ncol,:) = 0._r8 ! Grid-avg all cloud liquid
allcld_liq(:ncol,:) = 0._r8 ! Grid-avg all cloud ice

call conv_water_4rad(state, pbuf, allcld_liq, allcld_ice)
call conv_water_4rad(state, pbuf)
allcld_ice(:ncol,:) = totg_ice(:ncol,:) ! Grid-avg all cloud liquid
allcld_liq(:ncol,:) = totg_liq(:ncol,:) ! Grid-avg all cloud ice
else
allcld_liq(:ncol,top_lev:pver) = state%q(:ncol,top_lev:pver,ixcldliq) ! Grid-ave all cloud liquid
allcld_ice(:ncol,top_lev:pver) = state%q(:ncol,top_lev:pver,ixcldice) ! " ice
Expand Down Expand Up @@ -419,7 +430,9 @@ subroutine cloud_diagnostics_calc(state, pbuf)
elseif(one_mom_clouds) then

if (conv_water_in_rad /= 0) then
call conv_water_4rad(state, pbuf, allcld_liq, allcld_ice)
call conv_water_4rad(state, pbuf)
allcld_ice(:ncol,:) = totg_ice(:ncol,:) ! Grid-avg all cloud liquid
allcld_liq(:ncol,:) = totg_liq(:ncol,:) ! Grid-avg all cloud ice
else
allcld_liq = state%q(:,:,ixcldliq)
allcld_ice = state%q(:,:,ixcldice)
Expand Down
35 changes: 15 additions & 20 deletions src/physics/cam/conv_water.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module conv_water
! --------------------------------------------------------------------- !
! Purpose: !
! Computes grid-box average liquid (and ice) from stratus and cumulus !
! Just for the purposes of radiation. !
! These values used by both the radiation and the COSP diagnostics. !
! !
! Method: !
! Extract information about deep+shallow liquid and cloud fraction from !
Expand Down Expand Up @@ -38,9 +38,10 @@ module conv_water
! pbuf indices

integer :: icwmrsh_idx, icwmrdp_idx, fice_idx, sh_frac_idx, dp_frac_idx, &
ast_idx, sh_cldliq1_idx, sh_cldice1_idx, rei_idx
ast_idx, rei_idx

integer :: ixcldice, ixcldliq
integer :: gb_totcldliqmr_idx, gb_totcldicemr_idx

! Namelist
integer, parameter :: unset_int = huge(1)
Expand Down Expand Up @@ -113,11 +114,10 @@ subroutine conv_water_register

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

! these calls were already done in convect_shallow...so here I add the same fields to the physics buffer with a "1" at the end
! shallow gbm cloud liquid water (kg/kg)
call pbuf_add_field('SH_CLDLIQ1','physpkg',dtype_r8,(/pcols,pver/),sh_cldliq1_idx)
! shallow gbm cloud ice water (kg/kg)
call pbuf_add_field('SH_CLDICE1','physpkg',dtype_r8,(/pcols,pver/),sh_cldice1_idx)
! grid box total cloud liquid water mixing ratio (kg/kg)
call pbuf_add_field('GB_TOTCLDLIQMR', 'physpkg', dtype_r8, (/pcols,pver/), gb_totcldliqmr_idx)
! grid box total cloud ice water mixing ratio (kg/kg)
call pbuf_add_field('GB_TOTCLDICEMR', 'physpkg', dtype_r8, (/pcols,pver/), gb_totcldicemr_idx)

end subroutine conv_water_register

Expand Down Expand Up @@ -168,7 +168,7 @@ subroutine conv_water_init()

end subroutine conv_water_init

subroutine conv_water_4rad(state, pbuf, totg_liq, totg_ice)
subroutine conv_water_4rad(state, pbuf)

! --------------------------------------------------------------------- !
! Purpose: !
Expand Down Expand Up @@ -202,9 +202,6 @@ subroutine conv_water_4rad(state, pbuf, totg_liq, totg_ice)
type(physics_state), target, intent(in) :: state ! state variables
type(physics_buffer_desc), pointer :: pbuf(:)

real(r8), intent(out):: totg_ice(pcols,pver) ! Total GBA in-cloud ice
real(r8), intent(out):: totg_liq(pcols,pver) ! Total GBA in-cloud liquid

! --------------- !
! Local Workspace !
! --------------- !
Expand All @@ -222,8 +219,9 @@ subroutine conv_water_4rad(state, pbuf, totg_liq, totg_ice)
real(r8), pointer, dimension(:,:) :: dp_icwmr ! Deep conv. cloud water
real(r8), pointer, dimension(:,:) :: sh_icwmr ! Shallow conv. cloud water
real(r8), pointer, dimension(:,:) :: fice ! Ice partitioning ratio
real(r8), pointer, dimension(:,:) :: sh_cldliq ! shallow convection gbx liq cld mixing ratio for COSP
real(r8), pointer, dimension(:,:) :: sh_cldice ! shallow convection gbx ice cld mixing ratio for COSP

real(r8), pointer, dimension(:,:) :: totg_ice ! Grid box total cloud ice mixing ratio
real(r8), pointer, dimension(:,:) :: totg_liq ! Grid box total cloud liquid mixing ratio

real(r8) :: conv_ice(pcols,pver) ! Convective contributions to IC cloud ice
real(r8) :: conv_liq(pcols,pver) ! Convective contributions to IC cloud liquid
Expand Down Expand Up @@ -282,6 +280,10 @@ subroutine conv_water_4rad(state, pbuf, totg_liq, totg_ice)
itim_old = pbuf_old_tim_idx()
call pbuf_get_field(pbuf, ast_idx, ast, start=(/1,1,itim_old/), kount=(/pcols,pver,1/) )

! Fields computed below and stored in pbuf.
call pbuf_get_field(pbuf, gb_totcldicemr_idx, totg_ice)
call pbuf_get_field(pbuf, gb_totcldliqmr_idx, totg_liq)

! --------------------------------------------------------------- !
! Loop through grid-boxes and determine: !
! 1. Effective mean in-cloud convective ice/liquid (deep+shallow) !
Expand Down Expand Up @@ -407,13 +409,6 @@ subroutine conv_water_4rad(state, pbuf, totg_liq, totg_ice)
end do
end do

!add pbuff calls for COSP
call pbuf_get_field(pbuf, sh_cldliq1_idx, sh_cldliq )
call pbuf_get_field(pbuf, sh_cldice1_idx, sh_cldice )

sh_cldliq(:ncol,:pver)=sh_icwmr(:ncol,:pver)*(1-fice(:ncol,:pver))*sh_frac(:ncol,:pver)
sh_cldice(:ncol,:pver)=sh_icwmr(:ncol,:pver)*fice(:ncol,:pver)*sh_frac(:ncol,:pver)

! Output convective IC WMRs

call outfld( 'ICLMRCU ', conv_liq , pcols, lchnk )
Expand Down
43 changes: 19 additions & 24 deletions src/physics/cam/cospsimulator_intr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,9 @@ module cospsimulator_intr
! chunk (allocatable->1:pcols,begchunk:endchunk)
! pbuf indices
integer :: cld_idx, concld_idx, lsreffrain_idx, lsreffsnow_idx, cvreffliq_idx
integer :: cvreffice_idx, dpcldliq_idx, dpcldice_idx
integer :: shcldliq1_idx, shcldice1_idx, dpflxprc_idx
integer :: cvreffice_idx
integer :: gb_totcldliqmr_idx, gb_totcldicemr_idx
integer :: dpflxprc_idx
integer :: dpflxsnw_idx, shflxprc_idx, shflxsnw_idx, lsflxprc_idx, lsflxsnw_idx
integer :: rei_idx, rel_idx

Expand Down Expand Up @@ -870,10 +871,8 @@ subroutine cospsimulator_intr_init()
lsreffsnow_idx = pbuf_get_index('LS_REFFSNOW')
cvreffliq_idx = pbuf_get_index('CV_REFFLIQ')
cvreffice_idx = pbuf_get_index('CV_REFFICE')
dpcldliq_idx = pbuf_get_index('DP_CLDLIQ')
dpcldice_idx = pbuf_get_index('DP_CLDICE')
shcldliq1_idx = pbuf_get_index('SH_CLDLIQ1')
shcldice1_idx = pbuf_get_index('SH_CLDICE1')
gb_totcldliqmr_idx = pbuf_get_index('GB_TOTCLDLIQMR') ! grid box total cloud liquid water mr (kg/kg)
gb_totcldicemr_idx = pbuf_get_index('GB_TOTCLDICEMR') ! grid box total cloud ice water mr (kg/kg)
dpflxprc_idx = pbuf_get_index('DP_FLXPRC')
dpflxsnw_idx = pbuf_get_index('DP_FLXSNW')
shflxprc_idx = pbuf_get_index('SH_FLXPRC', errcode=ierr)
Expand Down Expand Up @@ -1205,11 +1204,9 @@ subroutine cospsimulator_intr_run(state, pbuf, cam_in, emis, coszrs, &
real(r8), pointer, dimension(:,:) :: ls_flxprc ! stratiform interface gbm flux_cloud_rain+snow (kg m^-2 s^-1)
real(r8), pointer, dimension(:,:) :: ls_flxsnw ! stratiform interface gbm flux_cloud_snow (kg m^-2 s^-1)

!! cloud mixing ratio pointers (note: large-scale in state)
real(r8), pointer, dimension(:,:) :: sh_cldliq ! shallow gbm cloud liquid water (kg/kg)
real(r8), pointer, dimension(:,:) :: sh_cldice ! shallow gbm cloud ice water (kg/kg)
real(r8), pointer, dimension(:,:) :: dp_cldliq ! deep gbm cloud liquid water (kg/kg)
real(r8), pointer, dimension(:,:) :: dp_cldice ! deep gmb cloud ice water (kg/kg)
!! grid box total cloud mixing ratio (large-scale + convective)
real(r8), pointer, dimension(:,:) :: totg_liq ! gbm total cloud liquid water (kg/kg)
real(r8), pointer, dimension(:,:) :: totg_ice ! gbm total cloud ice water (kg/kg)

! Output CAM variables
! Multiple "mdims" are collapsed because CAM history buffers only support one mdim.
Expand Down Expand Up @@ -1508,11 +1505,9 @@ subroutine cospsimulator_intr_run(state, pbuf, cam_in, emis, coszrs, &
call pbuf_get_field(pbuf, cvreffliq_idx, cv_reffliq )
call pbuf_get_field(pbuf, cvreffice_idx, cv_reffice )

!! convective cloud mixing ratios
call pbuf_get_field(pbuf, dpcldliq_idx, dp_cldliq )
call pbuf_get_field(pbuf, dpcldice_idx, dp_cldice )
call pbuf_get_field(pbuf, shcldliq1_idx, sh_cldliq )
call pbuf_get_field(pbuf, shcldice1_idx, sh_cldice )
!! grid box total cloud mixing ratios
call pbuf_get_field(pbuf, gb_totcldliqmr_idx, totg_liq)
call pbuf_get_field(pbuf, gb_totcldicemr_idx, totg_ice)

!! precipitation fluxes
call pbuf_get_field(pbuf, dpflxprc_idx, dp_flxprc )
Expand Down Expand Up @@ -1616,9 +1611,12 @@ subroutine cospsimulator_intr_run(state, pbuf, cam_in, emis, coszrs, &

grpl_ls_interp = 0._r8

!! CAM5 cloud mixing ratio calculations
!! Note: Although CAM5 has non-zero convective cloud mixing ratios that affect the model state,
!! Convective cloud water is NOT part of radiation calculations.
! subroutine subsample_and_optics provides separate arguments to pass
! the large scale and convective cloud condensate. Below the grid box
! total cloud water mixing ratios are passed in the arrays for the
! large scale contributions and the arrays for the convective
! contributions are set to zero. This is consistent with the treatment
! of cloud water by the radiation code.
mr_ccliq = 0._r8
mr_ccice = 0._r8
mr_lsliq = 0._r8
Expand All @@ -1627,11 +1625,8 @@ subroutine cospsimulator_intr_run(state, pbuf, cam_in, emis, coszrs, &
kk = ktop + k -1
do i = 1, ncol
if (cld(i,k) > 0._r8) then
!! note: convective mixing ratio is the sum of shallow and deep convective clouds in CAM5
mr_ccliq(i,k) = sh_cldliq(i,kk) + dp_cldliq(i,kk)
mr_ccice(i,k) = sh_cldice(i,kk) + dp_cldice(i,kk)
mr_lsliq(i,k) = state%q(i,kk,ixcldliq) ! state only includes stratiform (kg/kg)
mr_lsice(i,k) = state%q(i,kk,ixcldice) ! state only includes stratiform (kg/kg)
mr_lsliq(i,k) = totg_liq(i,kk)
mr_lsice(i,k) = totg_ice(i,kk)
end if
end do
end do
Expand Down
14 changes: 0 additions & 14 deletions src/physics/cam/zm_conv_intr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ module zm_conv_intr
zm_ideep_idx, &
dp_flxprc_idx, &
dp_flxsnw_idx, &
dp_cldliq_idx, &
ixorg, &
dp_cldice_idx, &
dlfzm_idx, & ! detrained convective cloud water mixing ratio.
difzm_idx, & ! detrained convective cloud ice mixing ratio.
dnlfzm_idx, & ! detrained convective cloud water num concen.
Expand Down Expand Up @@ -135,12 +133,6 @@ subroutine zm_conv_register
! Flux of snow from deep convection (kg/m2/s)
call pbuf_add_field('DP_FLXSNW','global',dtype_r8,(/pcols,pverp/),dp_flxsnw_idx)

! deep gbm cloud liquid water (kg/kg)
call pbuf_add_field('DP_CLDLIQ','global',dtype_r8,(/pcols,pver/), dp_cldliq_idx)

! deep gbm cloud liquid water (kg/kg)
call pbuf_add_field('DP_CLDICE','global',dtype_r8,(/pcols,pver/), dp_cldice_idx)

call pbuf_add_field('ICWMRDP', 'physpkg',dtype_r8,(/pcols,pver/),icwmrdp_idx)
call pbuf_add_field('RPRDDP', 'physpkg',dtype_r8,(/pcols,pver/),rprddp_idx)
call pbuf_add_field('NEVAPR_DPCU','physpkg',dtype_r8,(/pcols,pver/),nevapr_dpcu_idx)
Expand Down Expand Up @@ -459,8 +451,6 @@ subroutine zm_conv_tend(pblh ,mcon ,cme , &
real(r8), pointer, dimension(:,:) :: evapcdp ! Evaporation of deep convective precipitation
real(r8), pointer, dimension(:,:) :: flxprec ! Convective-scale flux of precip at interfaces (kg/m2/s)
real(r8), pointer, dimension(:,:) :: flxsnow ! Convective-scale flux of snow at interfaces (kg/m2/s)
real(r8), pointer, dimension(:,:) :: dp_cldliq
real(r8), pointer, dimension(:,:) :: dp_cldice
real(r8), pointer :: dlf(:,:) ! detrained convective cloud water mixing ratio.
real(r8), pointer :: dif(:,:) ! detrained convective cloud ice mixing ratio.
real(r8), pointer :: dnlf(:,:) ! detrained convective cloud water num concen.
Expand Down Expand Up @@ -709,10 +699,6 @@ subroutine zm_conv_tend(pblh ,mcon ,cme , &

call pbuf_get_field(pbuf, dp_flxprc_idx, flxprec )
call pbuf_get_field(pbuf, dp_flxsnw_idx, flxsnow )
call pbuf_get_field(pbuf, dp_cldliq_idx, dp_cldliq )
call pbuf_get_field(pbuf, dp_cldice_idx, dp_cldice )
dp_cldliq(:ncol,:) = 0._r8
dp_cldice(:ncol,:) = 0._r8
!REMOVECAM - no longer need these when CAM is retired and pcols no longer exists
flxprec(:,:) = 0._r8
flxsnow(:,:) = 0._r8
Expand Down
Loading