Skip to content

Commit

Permalink
use conv_water calcs in COSP
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-eaton committed Jul 9, 2024
1 parent 9ca1ea4 commit 4bded6f
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 76 deletions.
77 changes: 77 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,82 @@
===============================================================

Tag name:
Originator(s): eaton
Date:
One-line Summary: Use same cloud water for radiation and COSP.
Github PR URL:

Purpose of changes (include the issue number and title text for each relevant GitHub issue):

Issue #1027 - Radiatively active cloud water missing from COSP.

The all-cloud liquid and ice mixing ratios calculated in the conv_water module are
used by the radiation code. Use these same quantities in the COSP code by
making them accessable via the physics buffer.

resolves #1027

Describe any changes made to build system: none

Describe any changes made to the namelist: none

List any changes to the defaults for the boundary datasets: none

Describe any substantial timing or memory changes: none

Code reviewed by:

List all files eliminated: none

List all files added and what they do: none

List all existing files that have been modified, and describe the changes:

src/control/cam_snapshot_common.F90
. remove pbuf fields DP_CLDLIQ, DP_CLDICE, SH_CLDLIQ1, SH_CLDICE1

src/physics/cam/conv_water.F90
. add GB_TOTCLDLIQMR, GB_TOTCLDICEMR to pbuf
. remove SH_CLDLIQ1, SH_CLDICE1 from pbuf
. conv_water_4rad
- remove dummy args totg_liq and totg_ice and replace assignment to those
args by assignment to the pbuf variables GB_TOTCLDLIQMR and
GB_TOTCLDICEMR

src/physics/cam/cloud_diagnostics.F90
. access the pbuf fields GB_TOTCLDLIQMR and GB_TOTCLDICEMR which are set by
the calls to conv_water_4rad

src/physics/cam/cospsimulator_intr.F90
. replace access of pbuf fields DP_CLDLIQ, DP_CLDICE, SH_CLDLIQ1, and
SH_CLDICE1, by GB_TOTCLDLIQMR and GB_TOTCLDICEMR
. assign the total cloud mixing ratios to the arguments for the large scale
values, and set the convective cloud inputs to zero.

src/physics/cam/zm_conv_intr.F90
. remove pbuf fields DP_CLDLIQ and DP_CLDICE which were set to 0. and being
used as if they had real data by COSP.

If there were any failures reported from running test_driver.sh on any test
platform, and checkin with these failures has been OK'd by the gatekeeper,
then copy the lines from the td.*.status files for the failed tests to the
appropriate machine below. All failed tests must be justified.

derecho/intel/aux_cam:

izumi/nag/aux_cam:

izumi/gnu/aux_cam:

CAM tag used for the baseline comparison tests if different than previous
tag:

Summarize any changes to answers: BFB. Only COSP diagnostic fields have
differences.

===============================================================
===============================================================

Tag name: cam6_4_006
Originator(s): pel, eaton
Date: 3 July 2024
Expand Down
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 @@ -100,6 +102,10 @@ subroutine cloud_diagnostics_init()
!-----------------------------------------------------------------------

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 @@ -245,6 +251,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 @@ -297,6 +306,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 @@ -362,10 +374,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 @@ -410,7 +421,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
Loading

0 comments on commit 4bded6f

Please sign in to comment.