Skip to content

Commit

Permalink
fixed bug in vertintrp call; fixed LBA (moved it over a land point)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrher committed Sep 21, 2023
1 parent 83f17fe commit 064f488
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 83 deletions.
24 changes: 12 additions & 12 deletions cime_config/testdefs/testmods_dirs/cam/outfrq9s_clubbmf/user_nl_cam
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ deep_scheme='off'

clubb_mf_nup = 25

!clubb_mf_Lopt = 6
!clubb_mf_up_ndt = 1
!clubb_mf_a0 = 2.0D0
!clubb_mf_b0 = 0.5D0
!clubb_mf_max_L0 = 1000.0D0
!clubb_mf_alphturb = 3.0D0
!do_clubb_mf_rhtke = .true.
clubb_mf_Lopt = 6
clubb_mf_up_ndt = 1
clubb_mf_a0 = 2.0D0
clubb_mf_b0 = 0.5D0
clubb_mf_max_L0 = 1000.0D0
clubb_mf_alphturb = 3.0D0
do_clubb_mf_rhtke = .true.

!clubb_mf_fdd = 0.5
!do_clubb_mf_coldpool = .true.
!clubb_mf_cp_ndt = 1
!clubb_mf_ddalph = 500.
!clubb_mf_ddbeta = 1.0
clubb_mf_fdd = 0.5
do_clubb_mf_coldpool = .true.
clubb_mf_cp_ndt = 1
clubb_mf_ddalph = 500.
clubb_mf_ddbeta = 1.0
3 changes: 2 additions & 1 deletion cime_config/usermods_dirs/scam_LBA/shell_commands
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# setup SCAM lon and lat for this iop
# this should correspond to the forcing IOP coordinates
./xmlchange PTS_LON=0.0
#./xmlchange PTS_LON=0.0
./xmlchange PTS_LON=295.
./xmlchange PTS_LAT=0.0

# Specify the starting/ending time for the IOP
Expand Down
3 changes: 2 additions & 1 deletion cime_config/usermods_dirs/scam_LBA/user_nl_cam
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
iopfile='/glade/u/home/storer/scam_iop_nc/iop_LBA_precip_halfhour.nc'

!ncdata='$DIN_LOC_ROOT/CESM2.F2000climo.IOP_SITES_L128.cam.i.0003-06-01-00000.nc'
ncdata='/glade/work/aherring/grids/vertical-res/CESM2.F2000climo.IOP_SITES_L128.cam.i.0003-06-01-00000.nc'
!ncdata='/glade/work/aherring/grids/vertical-res/CESM2.F2000climo.IOP_SITES_L128.cam.i.0003-06-01-00000.nc'
ncdata="$DIN_LOC_ROOT/atm/cam/scam/iop/CESM2.F2000climo.IOP_SITES.cam.i.0003-06-01-00000.nc"

nhtfrq = 1
mfilt = 720
Expand Down
95 changes: 26 additions & 69 deletions src/physics/cam/clubb_intr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ subroutine clubb_register_cam( )
call pbuf_add_field('pdf_zm_var_w_2', 'global', dtype_r8, (/pcols,pverp,dyn_time_lvls/), pdf_zm_varnce_w_2_idx)
call pbuf_add_field('pdf_zm_mixt_frac', 'global', dtype_r8, (/pcols,pverp,dyn_time_lvls/), pdf_zm_mixt_frac_idx)

! these extrra coord vars don't seem to work for interpolate_output=.true.
call add_hist_coord('ncyc', cld_macmic_num_steps, 'macro/micro cycle index')
call add_hist_coord('nens', clubb_mf_nup, 'clubb+mf ensemble size')

Expand Down Expand Up @@ -2115,7 +2116,6 @@ subroutine clubb_ini_cam(pbuf2d)
call add_default( 'edmf_vflx' , 1, ' ')
call add_default( 'edmf_qtflx' , 1, ' ')

!+++ARH - not bfb (initialized them to zero -- fixed?)
call add_default( 'edmf_thlforcup', 1, ' ')
call add_default( 'edmf_qtforcup' , 1, ' ')
call add_default( 'edmf_thlforcdn', 1, ' ')
Expand Down Expand Up @@ -2918,11 +2918,8 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
mf_thlflx_output, mf_qtflx_output, mf_uflx_output, mf_vflx_output, &
mf_thvflx_output, &
mf_rcm_output, mf_precc_output
!+++ARH
! MF Plume
! NOTE: Arrays of size PCOLS (all possible columns) can be used to access State, PBuf and History Subroutines
!real(r8), dimension(pcols,pverp) :: mf_dry_a, mf_moist_a, &
real(r8), dimension(state%ncol,pverp) :: mf_dry_a, mf_moist_a, &
! MF work arrays (of size NCOL)
real(r8), dimension(state%ncol,pverp):: mf_dry_a, mf_moist_a, &
mf_dry_w, mf_moist_w, &
mf_dry_qt, mf_moist_qt, &
mf_dry_thl, mf_moist_thl, &
Expand All @@ -2943,9 +2940,8 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
mf_sqtdn, mf_sthldn, &
mf_sqt, mf_sthl, &
mf_precc
!+++ARH
!real(r8), dimension(pcols,pverp) :: mf_thlflxup, mf_qtflxup, mf_uflxup, mf_vflxup, &
real(r8), dimension(state%ncol,pverp) :: mf_thlflxup, mf_qtflxup, mf_uflxup, mf_vflxup, &

real(r8), dimension(state%ncol,pverp) :: mf_thlflxup, mf_qtflxup, mf_uflxup, mf_vflxup, &
mf_thlflxdn, mf_qtflxdn, mf_uflxdn, mf_vflxdn, &
mf_thlflx, mf_qtflx, mf_uflx, mf_vflx, &
mf_thvflx, &
Expand All @@ -2959,67 +2955,44 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
mf_qc_zt, mf_cloudfrac_zt, &
mf_rcm, mf_rcm_nadv, &
mf_ent_nadv
!+++ARH
! MF plume level
!real(r8), dimension(pcols,pverp,clubb_mf_nup) :: mf_upa, mf_dna, &

real(r8), dimension(state%ncol,pverp,clubb_mf_nup) :: mf_upa, mf_dna, &
mf_upw, mf_dnw, &
mf_upmf, &
mf_upqt, mf_dnqt, &
mf_upthl, mf_dnthl, &
mf_upthv, mf_dnthv, &
mf_upth, mf_dnth, &
mf_upqc, mf_dnqc, &
mf_upbuoy, &
mf_updet, &
mf_upent
mf_upw, mf_dnw, &
mf_upmf, &
mf_upqt, mf_dnqt, &
mf_upthl, mf_dnthl, &
mf_upthv, mf_dnthv, &
mf_upth, mf_dnth, &
mf_upqc, mf_dnqc, &
mf_upbuoy, &
mf_updet, &
mf_upent

real(r8) :: inv_rh2o ! To reduce the number of divisions in clubb_tend

!+++ARH
!real(r8), dimension(pcols,pverp,clubb_mf_nup) :: flip
real(r8), dimension(state%ncol,pverp,clubb_mf_nup) :: flip

!+++ARH
!real(r8), dimension(pcols,pverp) :: lilflip
real(r8), dimension(state%ncol,pverp) :: lilflip

! CFL limiter vars
real(r8), parameter :: cflval = 1._r8
real(r8) :: lambda

!+++ARH
!real(r8), dimension(pcols) :: cflfac, max_cfl, &
real(r8), dimension(state%ncol) :: cflfac, max_cfl, &
real(r8), dimension(state%ncol) :: cflfac, max_cfl, &
th_sfc, max_cfl_nadv

logical :: cfllim

!+++ARH
!real(r8), dimension(pcols) :: mf_ztop, mf_ztop_nadv, &
real(r8), dimension(state%ncol) :: mf_ztop, mf_ztop_nadv, &
real(r8), dimension(state%ncol) :: mf_ztop, mf_ztop_nadv, &
mf_ztopm1, mf_ztopm1_nadv, &
mf_precc_nadv, mf_snow_nadv,&
mf_L0, mf_L0_nadv, &
mf_ddcp, mf_ddcp_nadv, &
mf_cbm1, mf_cbm1_nadv, &
mf_freq_nadv
!+++ARH
!real(r8), dimension(pcols,pver) :: esat, rh
real(r8), dimension(state%ncol,pver) :: esat, rh

!+++ARH
!real(r8), dimension(pcols,pver) :: mq, mqsat
real(r8), dimension(state%ncol,pver) :: mq, mqsat

!+++ARH
!real(r8), dimension(pcols) :: rhlev, rhinv
real(r8), dimension(state%ncol) :: rhlev, rhinv

!+++ARH
! MF local vars
!real(r8), dimension(pcols,pverp) :: rtm_zm_in, thlm_zm_in, & ! momentum grid
real(r8), dimension(state%ncol,pverp) :: rtm_zm_in, thlm_zm_in, & ! momentum grid

real(r8), dimension(state%ncol,pver) :: esat, rh
real(r8), dimension(state%ncol,pver) :: mq, mqsat
real(r8), dimension(state%ncol) :: rhlev, rhinv

real(r8), dimension(state%ncol,pverp):: rtm_zm_in, thlm_zm_in, & ! momentum grid
dzt, invrs_dzt, & ! thermodynamic grid
invrs_exner_zt,& ! thermodynamic grid
kappa_zt, qc_zt, & ! thermodynamic grid
Expand Down Expand Up @@ -3264,8 +3237,8 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
if (clubb_mf_Lopt==7 .or. clubb_mf_Lopt==6) then
! Interpolate RH to 500 hPa
rh(:ncol,:) = state%q(:ncol,:,1)/rh(:ncol,:)
call vertinterp(ncol, pcols, pver, state%pmid, 50000._r8, rh, rhlev, &
extrapolate='Z', ln_interp=.true., ps=state%ps, phis=state%phis, tbot=state%t(:,pver))
call vertinterp(ncol, ncol, pver, state%pmid(:ncol,:), 50000._r8, rh, rhlev, &
extrapolate='Z', ln_interp=.true., ps=state%ps(:ncol), phis=state%phis(:ncol), tbot=state%t(:ncol,pver))
else if (clubb_mf_Lopt==8) then
! Mass of q, by layer and vertically integrated
mq(:ncol,:) = state%q(:ncol,:,1) * state%pdel(:ncol,:) * rga
Expand Down Expand Up @@ -3849,7 +3822,6 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
rvm_in(i,k) = rvm(i,pverp-k+1)
wprtp_in(i,k) = wprtp(i,pverp-k+1)
wpthlp_in(i,k) = wpthlp(i,pverp-k+1)
!+++ARH
tke_in(i,k) = tke(i,pverp-k+1)
rtpthlp_in(i,k) = rtpthlp(i,pverp-k+1)
cloud_frac_inout(i,k) = cloud_frac(i,pverp-k+1)
Expand Down Expand Up @@ -4261,14 +4233,6 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &


! pass MF turbulent advection term as CLUBB explicit forcing term
!rtm_forcing(:ncol,1) = 0._r8
!thlm_forcing(:ncol,1) = 0._r8
!mf_qtforcup(:ncol,1) = 0._r8
!mf_thlforcup(:ncol,1) = 0._r8
!mf_qtforcdn(:ncol,1) = 0._r8
!mf_thlforcdn(:ncol,1) = 0._r8
rtm_forcing(:ncol,:) = 0._r8
thlm_forcing(:ncol,:) = 0._r8
mf_qtforcup(:ncol,:) = 0._r8
mf_thlforcup(:ncol,:) = 0._r8
mf_qtforcdn(:ncol,:) = 0._r8
Expand Down Expand Up @@ -4941,15 +4905,9 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
mf_sqtup_output(i,pverp-k+1) = mf_sqtup(i,k)
mf_sqtdn_output(i,pverp-k+1) = mf_sqtdn(i,k)

!+++ARH not bfb (fixed?)
mf_cloudfrac_output(i,pverp-k+1) = mf_cloudfrac_zt(i,k)
!mf_cloudfrac_output(i,pverp-k+1) = mf_cloudfrac(i,k)

mf_ent_output(i,pverp-k+1) = mf_ent_nadv(i,k)

!+++ARH not bfb (fixed?)
mf_qc_output(i,pverp-k+1) = mf_qc_zt(i,k)
!mf_qc_output(i,pverp-k+1) = mf_qc(i,k)
end if

mf_upa_flip(i,pverp-k+1,:clubb_mf_nup) = mf_upa(i,k,:clubb_mf_nup)
Expand Down Expand Up @@ -5525,7 +5483,6 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &

deepcu(:,:) = 0.0_r8
shalcu(:,:) = 0.0_r8
!+++ARH
sh_icwmr(:,:) = 0.0_r8

do k=1,pver-1
Expand Down

0 comments on commit 064f488

Please sign in to comment.