Skip to content

Commit

Permalink
added some array intiailzaitons that resolves some of the issues
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrher committed Aug 16, 2023
1 parent c72b887 commit 7280f65
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./xmlchange ROF_NCPL=\$ATM_NCPL
./xmlchange GLC_NCPL=\$ATM_NCPL
./xmlchange CAM_CONFIG_OPTS='-phys cam_dev -microphys mg2' --append
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
./xmlchange ROF_NCPL=\$ATM_NCPL
./xmlchange GLC_NCPL=\$ATM_NCPL
./xmlchange CAM_CONFIG_OPTS='-phys cam6 -microphys mg2' --append
25 changes: 14 additions & 11 deletions cime_config/testdefs/testmods_dirs/cam/outfrq9s_clubbmf/user_nl_cam
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
mfilt=1,1,1,1,1,1
ndens=1,1,1,1,1,1
nhtfrq=9,9,9,9,9,9
!nhtfrq=1,1,1,1,1,1
inithist='ENDOFRUN'

do_clubb_mf=.true.
do_clubb_mf_diag=.true.
do_clubb_mf_rad=.true.
Expand All @@ -10,15 +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_alphturb = 0.0D0
clubb_mf_max_L0 = 733.34D0
!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 = 250.
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
5 changes: 4 additions & 1 deletion src/control/cam_snapshot_common.F90
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ module cam_snapshot_common
type (snapshot_type) :: tend_snapshot(6)
type (snapshot_type) :: cam_in_snapshot(30)
type (snapshot_type) :: cam_out_snapshot(30)
type (snapshot_type_nd) :: pbuf_snapshot(250)
!+++ARH
!type (snapshot_type_nd) :: pbuf_snapshot(250)
type (snapshot_type_nd) :: pbuf_snapshot(350)
!---ARH

contains

Expand Down
34 changes: 34 additions & 0 deletions src/cpl/nuopc/atm_comp_nuopc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,14 @@ subroutine DataInitialize(gcomp, rc)
call export_fields( gcomp, model_mesh, model_clock, cam_out, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
else
!+++ARH
if (masterproc) then
write(iam+1000,*) '--------------'
write(iam+1000,*) 'DataInitialize'
write(iam+1000,*) ' cam_run1 sets cam_out'
write(iam+1000,*) ' nstep=',get_nstep()
end if
!---ARH
call cam_read_srfrest( gcomp, clock, rc=rc )
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call import_fields( gcomp, cam_in, restart_init=.true., rc=rc )
Expand Down Expand Up @@ -1093,6 +1101,14 @@ subroutine ModelAdvance(gcomp, rc)
call import_fields( gcomp, cam_in, rc=rc)
if (ChkErr(rc,__LINE__,u_FILE_u)) return
call t_stopf ('CAM_import')
!+++ARH
if (masterproc) then
write(iam+1000,*) '--------------'
write(iam+1000,*) 'Model Advance'
write(iam+1000,*) ' CAM_import sets cam_in'
write(iam+1000,*) ' nstep=',get_nstep()
end if
!---ARH
end if

dosend = .false.
Expand Down Expand Up @@ -1145,6 +1161,15 @@ subroutine ModelAdvance(gcomp, rc)
yr_spec=yr_sync, mon_spec=mon_sync, day_spec=day_sync, sec_spec=tod_sync)
call t_stopf ('CAM_run4')

!+++ARH
if (masterproc) then
write(iam+1000,*) '--------------'
write(iam+1000,*) 'ModelAdvance'
write(iam+1000,*) ' cam_run2,cam_run3,cam_run4'
write(iam+1000,*) ' nstep=',get_nstep()
end if
!---ARH

! Advance cam time step

call t_startf ('CAM_adv_timestep')
Expand All @@ -1157,6 +1182,15 @@ subroutine ModelAdvance(gcomp, rc)
call cam_run1 ( cam_in, cam_out )
call t_stopf ('CAM_run1')

!+++ARH
if (masterproc) then
write(iam+1000,*) '--------------'
write(iam+1000,*) 'ModelAdvance'
write(iam+1000,*) ' CAM_adv_timestep,cam_run1'
write(iam+1000,*) ' nstep=',get_nstep()
end if
!---ARH

end do

if (mediator_present) then
Expand Down
47 changes: 40 additions & 7 deletions src/physics/cam/clubb_intr.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2128,10 +2128,12 @@ subroutine clubb_ini_cam(pbuf2d)
call add_default( 'edmf_uflx' , 1, ' ')
call add_default( 'edmf_vflx' , 1, ' ')
call add_default( 'edmf_qtflx' , 1, ' ')
!+++ARH - not bfb
call add_default( 'edmf_thlforcup', 1, ' ')
call add_default( 'edmf_qtforcup' , 1, ' ')
call add_default( 'edmf_thlforcdn', 1, ' ')
call add_default( 'edmf_qtforcdn' , 1, ' ')
!---ARH
call add_default( 'edmf_thlforc' , 1, ' ')
call add_default( 'edmf_qtforc' , 1, ' ')
call add_default( 'edmf_sqtup' , 1, ' ')
Expand Down Expand Up @@ -3941,6 +3943,9 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
! pressure,exner on momentum grid needed for mass flux calc.
if (do_clubb_mf) then

kappa_zt(:,:) = 0._r8
qc_zt(:,:) = 0._r8
invrs_exner_zt(:,:) = 0._r8
do k=1,pver
do i=1,ncol
kappa_zt(i,k+1) = (rairv(i,pver-k+1,lchnk)/cpairv(i,pver-k+1,lchnk))
Expand All @@ -3953,15 +3958,19 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
qc_zt(:ncol,1) = qc_zt(:ncol,2)
invrs_exner_zt(:ncol,1) = invrs_exner_zt(:ncol,2)

kappa_zm(:,:) = 0._r8
kappa_zm(1:ncol,:) = zt2zm_api(pverp+1-top_lev, ncol, gr, kappa_zt(1:ncol,:))

p_in_Pa_zm(:,:) = 0._r8
invrs_exner_zm(:,:) = 0._r8
do k=1,pverp
do i=1,ncol
p_in_Pa_zm(i,k) = state1%pint(i,pverp-k+1)
invrs_exner_zm(i,k) = 1._r8/((p_in_Pa_zm(i,k)/p0_clubb)**(kappa_zm(i,k)))
end do
end do

th_sfc(:) = 0._r8
th_sfc(1:ncol) = cam_in%ts(1:ncol)*invrs_exner_zm(1:ncol,1)

call calc_ustar( ncol, state1%t(:ncol,pver), state1%pmid(:ncol,pver), cam_in%wsx(:ncol), cam_in%wsy(:ncol), &
Expand Down Expand Up @@ -4121,15 +4130,23 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
if (do_clubb_mf) then


dzt(:,:) = 0._r8
do k=2,pverp
do i=1, ncol
dzt(i,k) = zi_g(i,k) - zi_g(i,k-1)
end do
end do

dzt(:ncol,1) = dzt(:ncol,2)

invrs_dzt(:,:) = 0._r8
invrs_dzt(:ncol,:) = 1._r8/dzt(:ncol,:)

rtm_zm_in(:,:) = 0._r8
thlm_zm_in(:,:) = 0._r8
th_zm(:,:) = 0._r8
qv_zm(:,:) = 0._r8
qc_zm(:,:) = 0._r8
rtm_zm_in(1:ncol,:) = zt2zm_api( pverp+1-top_lev, ncol, gr, rtm_in(1:ncol,:) )
thlm_zm_in(1:ncol,:) = zt2zm_api( pverp+1-top_lev, ncol, gr, thlm_in(1:ncol,:) )
th_zm(1:ncol,:) = zt2zm_api( pverp+1-top_lev, ncol, gr, th_zt(1:ncol,:) )
Expand Down Expand Up @@ -4243,12 +4260,18 @@ 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,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
mf_thlforcdn(:ncol,:) = 0._r8

do k=2,pverp
do i=1, ncol
Expand Down Expand Up @@ -4756,6 +4779,8 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
wp2_zt = zm2zt_api( pverp+1-top_lev, ncol, gr, wp2_in )

! Need moist_qc and cloudfrac on thermo grid for output
mf_qc_zt(:,:) = 0._r8
mf_cloudfrac_zt(:,:) = 0._r8
mf_qc_zt = zm2zt_api( pverp+1-top_lev, ncol, gr, mf_qc)
mf_cloudfrac_zt = zm2zt_api( pverp+1-top_lev, ncol, gr, mf_cloudfrac)

Expand Down Expand Up @@ -4908,9 +4933,15 @@ 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
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
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 @@ -5486,7 +5517,9 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &

deepcu(:,:) = 0.0_r8
shalcu(:,:) = 0.0_r8

!+++ARH
sh_icwmr(:,:) = 0.0_r8
!---ARH
do k=1,pver-1
do i=1,ncol
! diagnose the deep convective cloud fraction, as done in macrophysics based on the
Expand Down
15 changes: 15 additions & 0 deletions src/physics/cam/clubb_mf.F90
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ subroutine integrate_mf( nz,
dynamic_L0 = 0._r8
ztop = 0._r8

!+++ARH - uncomment to recover bgb restarts
! ddcp = 0._r8
! ztopm1 = zm(1)
! return
!---ARH

if (bsort) then
niter_xc = 3
limarea = .true.
Expand Down Expand Up @@ -1424,6 +1430,15 @@ subroutine integrate_mf( nz,
vflx(k) = vflxup(k) + vflxdn(k)
enddo

!+++ARH - uncomment bfb restarts (state only, clubb+mf diags still not bfb)
! thlflx = 0._r8
! qtflx = 0._r8
! sqt = 0_r8
! sthl = 0._r8
! moist_a = 0._r8
! moist_qc = 0._r8
!---ARH

else
ddcp = 0._r8
ztopm1 = zm(1)
Expand Down

0 comments on commit 7280f65

Please sign in to comment.