merge new clubb_mf into cam6_4_180#1576
Conversation
…rations on several variables with latest clubb interface and externals.
There was a problem hiding this comment.
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.F90CLUBB+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.
| !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 |
There was a problem hiding this comment.
I'm still looking into this section as one of these variables is causing numberical differences.
| 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) |
There was a problem hiding this comment.
Testing alternate solution to flip array.
| @@ -1,684 +1,3201 @@ | |||
| module clubb_mf | |||
|
|
|||
| ! =============================================================================== ! | |||
There was a problem hiding this comment.
@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.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| @@ -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) | |||
| 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) |
adamrher
left a comment
There was a problem hiding this comment.
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 --> |
There was a problem hiding this comment.
Remove these scam settings, which I put in to accommodate an older version of clubb-mf that couldn't run with clubb subcycling.
| <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> |
There was a problem hiding this comment.
Can you change ent0 to 0.2?
| group="clubb_mf_nl" valid_values="" > | ||
| Entrainment efficiency for individual plumes. Not used if | ||
| do_clubb_mf=FALSE. | ||
| Default: 0.22 |
There was a problem hiding this comment.
Can you change this to 0.20?
| <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> |
| <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 |
There was a problem hiding this comment.
Change max_L0 default to 1.e3
| 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) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) ) |
There was a problem hiding this comment.
remove this commented out code.
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:
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