Skip to content

merge new clubb_mf into cam6_4_180#1576

Open
jtruesdal wants to merge 14 commits into
ESCOMP:cam_developmentfrom
jtruesdal:clubbdev
Open

merge new clubb_mf into cam6_4_180#1576
jtruesdal wants to merge 14 commits into
ESCOMP:cam_developmentfrom
jtruesdal:clubbdev

Conversation

@jtruesdal

@jtruesdal jtruesdal commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

This PR merges updated CLUBB+MF (clubb-mf) changes into CAM, extending the CLUBB interface to support the enhanced integrate_mf call, adding new EDMF diagnostics/outputs, and introducing additional namelist controls for CLUBB+MF behavior (radiation coupling, microphysics, TKE contribution, etc.).

Changes:

  • Expanded clubb_intr.F90 CLUBB+MF interface: new pbuf fields, history coords, diagnostic outputs, and enhanced MF plumbing.
  • Added new CLUBB+MF namelist entries + defaults, and wired them into build-namelist.

The majority of the code updates reside in clubb_mf.F90. In addition to the new science, clubb_mf is now agnostic to the direction of the vertical level, adjusting the looping and indexes as needed depending on the top down or bottom up nature of the input arrays. Additionally the number of vertical levels for the new mf arrays are consistent with their associated thermodynamic or momentum grid. There are order of operation differences between this update and Adam's original cam6_4_124 version of clubb_mf which cause roundoff precision differences from the base code. On top of these roundoff differences there are bug fixes which are answer changing.

This PR closes #1370

jtruesdal and others added 2 commits June 9, 2026 09:08
…rations on several variables with latest clubb interface and externals.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR merges updated CLUBB+MF (clubb-mf) changes into CAM, extending the CLUBB interface to support the enhanced integrate_mf call, adding new EDMF diagnostics/outputs, and introducing additional namelist controls for CLUBB+MF behavior (radiation coupling, microphysics, TKE contribution, etc.).

Changes:

  • Expanded clubb_intr.F90 CLUBB+MF interface: new pbuf fields, history coords, diagnostic outputs, and enhanced MF plumbing.
  • Added new CLUBB+MF namelist entries + defaults, and wired them into build-namelist.
  • Updated COSP namelist documentation text (but introduced encoding issues that need correction).

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 18 comments.

File Description
src/physics/cam/clubb_intr.F90 Adds/updates CLUBB+MF fields, diagnostics, and MF integration interface wiring.
bld/namelist_files/namelist_definition.xml Adds new CLUBB+MF namelist definitions and edits COSP localtime documentation.
bld/namelist_files/namelist_defaults_cam.xml Adds default values for the new CLUBB+MF namelist entries.
bld/build-namelist Adds add_default(...) plumbing for (most) new CLUBB+MF namelist variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/physics/cam/clubb_intr.F90 Outdated
Comment thread src/physics/cam/clubb_intr.F90 Outdated
Comment thread src/physics/cam/clubb_intr.F90 Outdated
Comment thread bld/namelist_files/namelist_definition.xml Outdated
Comment thread bld/namelist_files/namelist_definition.xml Outdated
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread bld/namelist_files/namelist_defaults_cam.xml Outdated
Comment thread bld/build-namelist
Comment on lines +5201 to +5219
!jt check with Adam These are not bfb with nonclubbmf run
!jt check with Adam ! Values to use above top_lev, for variables that have not already been
!jt check with Adam ! set up there. These are mostly fill values that should not actually be
!jt check with Adam ! used in the run, but may end up in diagnostic output.
!jt check with Adam !$acc parallel loop gang vector collapse(2) default(present)
!jt check with Adam do k=1, top_lev-1
!jt check with Adam do i=1, ncol
!jt check with Adam upwp_pbuf(i,k) = 0._r8
!jt check with Adam vpwp_pbuf(i,k) = 0._r8
!jt check with Adam rcm(i,k) = 0._r8
!jt check with Adam wprcp(i,k) = 0._r8
!jt check with Adam cloud_frac(i,k) = 0._r8
!jt check with Adam rcm_in_layer(i,k) = 0._r8
!jt check with Adam zt_output(i,k) = 0._r8
!jt check with Adam zi_output(i,k) = 0._r8
!jt check with Adam khzm_pbuf(i,k) = 0._r8
!jt check with Adam qclvar(i,k) = 2._r8
!jt check with Adam end do
!jt check with Adam end do

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still looking into this section as one of these variables is causing numberical differences.

Comment on lines +5782 to +5795
mf_upa_flip(i,k,:clubb_mf_nup) = mf_upa(i,k_clubb,:clubb_mf_nup)
mf_upw_flip(i,k,:clubb_mf_nup) = mf_upw(i,k_clubb,:clubb_mf_nup)
mf_upmf_flip(i,k,:clubb_mf_nup) = mf_upmf(i,k_clubb,:clubb_mf_nup)
mf_upqt_flip(i,k,:clubb_mf_nup) = mf_upqt(i,k_clubb,:clubb_mf_nup)
mf_upthl_flip(i,k,:clubb_mf_nup) = mf_upthl(i,k_clubb,:clubb_mf_nup)
mf_upthv_flip(i,k,:clubb_mf_nup) = mf_upthv(i,k_clubb,:clubb_mf_nup)
mf_upth_flip(i,k,:clubb_mf_nup) = mf_upth(i,k_clubb,:clubb_mf_nup)
mf_upqc_flip(i,k,:clubb_mf_nup) = mf_upqc(i,k_clubb,:clubb_mf_nup)
mf_upent_flip(i,k,:clubb_mf_nup) = mf_upent(i,k_clubb,:clubb_mf_nup)
mf_updet_flip(i,k,:clubb_mf_nup) = mf_updet(i,k_clubb,:clubb_mf_nup)
mf_upbuoy_flip(i,k,:clubb_mf_nup) = mf_upbuoy(i,k_clubb,:clubb_mf_nup)
mf_dnw_flip(i,k,:clubb_mf_nup) = mf_dnw(i,k_clubb,:clubb_mf_nup)
mf_dnthl_flip(i,k,:clubb_mf_nup) = mf_dnthl(i,k_clubb,:clubb_mf_nup)
mf_dnqt_flip(i,k,:clubb_mf_nup) = mf_dnqt(i,k_clubb,:clubb_mf_nup)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing alternate solution to flip array.

Comment thread src/physics/cam/clubb_intr.F90
Comment thread src/physics/cam/clubb_intr.F90
Comment thread src/physics/cam/clubb_intr.F90
Comment thread src/physics/cam/clubb_intr.F90
@@ -1,684 +1,3201 @@
module clubb_mf

! =============================================================================== !

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamrher You'll probably want to difference this code against your cam6_4_124 clubbmf merge to see my changes. The code is now top-down, bottom-up agnostic so the indexing and loops have all changed. I tried to put some commenting in about the generalization of the vertical coordinates but like the original its still pretty dense. Additionally the vertical dimensions for momentum and thermodynamic arrays are consistent with those grids. It would help if you could make sure the different arrays are dimensioned for the correct grid as well as checking some of the special if logic loops that are not executed by default to make sure the vertical indexing is OK. I've checked all loops that are executed by default and they are roundoff consistent (12-14 digits) consistent with the order of operation differences between this code and your cam6_4_124 clubbmf merge.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 14 comments.

Comment thread src/physics/cam/clubb_intr.F90 Outdated
Comment thread src/physics/cam/clubb_intr.F90 Outdated
Comment thread src/physics/cam/clubb_intr.F90 Outdated
Comment thread src/physics/cam/clubb_intr.F90 Outdated
@@ -4773,6 +5598,17 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
end do
end do

rcm_macmic(:ncol,nzt_clubb*(macmic_it-1)+1:nzt_clubb*macmic_it) = rcm(:ncol,:nzt_clubb)
Comment thread src/physics/cam/clubb_intr.F90 Outdated
cldfrac_macmic(:ncol,pver*(macmic_it-1)+1:pver*macmic_it) = cld_pbuf(:ncol,:pver)
wpthlp_macmic(:ncol,pverp*(macmic_it-1)+1:pverp*macmic_it) = wpthlp_output(:ncol,:pverp)
wprtp_macmic(:ncol,pverp*(macmic_it-1)+1:pverp*macmic_it) = wprtp_output(:ncol,:pverp)
wpthvp_macmic(:ncol,nzm_clubb*(macmic_it-1)+1:nzm_clubb*macmic_it) = wpthvp_pbuf(:ncol,:nzm_clubb)
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread bld/namelist_files/namelist_definition.xml
Comment thread src/physics/cam/clubb_intr.F90 Outdated
@cacraigucar cacraigucar marked this pull request as ready for review June 23, 2026 16:47

@adamrher adamrher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi John. I've completed my first round of the code review, getting about about half-way through clubb_intr. The code merge removed a lot of stuff that Gunther cleaned up in cam6_4_144, and I tried to catch all those instances. I also found about 8 or so *_macmic variables that I'd like to remove from the pbuf.

<cld_macmic_num_steps microphys="mg2" clubb_sgs="1" dtime="225" > 1 </cld_macmic_num_steps>
<cld_macmic_num_steps microphys="mg3" clubb_sgs="1" dtime="450" > 2 </cld_macmic_num_steps>
<cld_macmic_num_steps microphys="mg3" clubb_sgs="1" dtime="225" > 1 </cld_macmic_num_steps>
<!-- ARH - SCAM time-stepping -->

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these scam settings, which I put in to accommodate an older version of clubb-mf that couldn't run with clubb subcycling.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

<do_clubb_mf_addtke > .false. </do_clubb_mf_addtke>
<clubb_mf_L0 > 50.0 </clubb_mf_L0>
<clubb_mf_ent0 > 0.22 </clubb_mf_ent0>
<clubb_mf_ent0 > 0.22 </clubb_mf_ent0>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change ent0 to 0.2?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

group="clubb_mf_nl" valid_values="" >
Entrainment efficiency for individual plumes. Not used if
do_clubb_mf=FALSE.
Default: 0.22

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change this to 0.20?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<clubb_mf_a0 > 2.0 </clubb_mf_a0>
<clubb_mf_b0 > 0.5 </clubb_mf_b0>
<clubb_mf_nup > 10 </clubb_mf_nup>
<clubb_mf_max_L0 > 10.e3 </clubb_mf_max_L0>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change max_L0 to 1.e3

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<entry id="clubb_mf_max_L0" type="real" category="conv"
group="clubb_mf_nl" valid_values="" >
Real: limiter on entrainmnet length scale + threshold to disable TKE enhanced entrainmnet
Default: 10.e3

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change max_L0 default to 1.e3

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

if (do_clubb_mf) then
call pbuf_get_field(pbuf, mf_wpthlp_macmic_idx, mf_thlflx_macmic)
call pbuf_get_field(pbuf, mf_wprtp_macmic_idx, mf_qtflx_macmic)
call pbuf_get_field(pbuf, mf_wpthvp_macmic_idx, mf_thvflx_macmic)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these three mf_*_macmic pbufs

rrho_tmp = calc_ideal_gas_rrho(rair, state_loc%t(i,pver), state_loc%pmid(i,pver))
ustar = calc_friction_velocity(cam_in%wsx(i), cam_in%wsy(i), rrho_tmp)
rrho(i) = calc_ideal_gas_rrho(rair, state_loc%t(i,pver), state_loc%pmid(i,pver))
ustar = calc_friction_velocity(cam_in%wsx(i), cam_in%wsy(i), rrho(i))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert these rrho(i) to rrho_tmp in these two lines.

thlm_zm(:,:) = 0._r8
th_zm(:,:) = 0._r8
qv_zm(:,:) = 0._r8
qc_zm(:,:) = 0._r8

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these zero array initializations unnecessary?

! pressure,exner on momentum grid needed for mass flux calc.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the zero initialization seems unnecessary since th_sfc is of size ncol.

th_sfc(1:ncol) = cam_in%ts(1:ncol)*invrs_exner_zm(1:ncol,nzm_clubb)

!call calc_ustar( ncol, state_loc%t(:ncol,pver), state_loc%pmid(:ncol,pver), cam_in%wsx(:ncol), cam_in%wsy(:ncol), &
! rrho(:ncol), ustar2(:ncol) )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this commented out code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants