Skip to content

Commit e637334

Browse files
authored
Merge pull request #1361 from jimmielin/hplin/hb_diff
cam6_4_120: Complete CCPPization of HB PBL scheme and vertical diffusion solver (non-WACCM)
2 parents 7bbbd1a + a4265d6 commit e637334

19 files changed

+1629
-1960
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
[submodule "atmos_phys"]
3030
path = src/atmos_phys
3131
url = https://github.com/ESCOMP/atmospheric_physics
32-
fxtag = atmos_phys0_17_003
32+
fxtag = atmos_phys0_18_000
3333
fxrequired = AlwaysRequired
3434
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics
3535

bld/build-namelist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5281,6 +5281,7 @@ sub check_snapshot_settings {
52815281
push (@validList_ac, ("'chem_timestep_tend'"));
52825282
}
52835283
push (@validList_ac, ("'vertical_diffusion_section'",
5284+
"'orographic_form_drag_stress'",
52845285
"'aero_model_drydep'", "'gw_tend'",
52855286
"'qbo_relax'", "'iondrag_calc_section'",
52865287
"'physics_dme_adjust'"));
@@ -5296,6 +5297,7 @@ sub check_snapshot_settings {
52965297
push (@validList_ac, ("'chem_timestep_tend'"));
52975298
}
52985299
push (@validList_ac, ("'vertical_diffusion_section'",
5300+
"'orographic_form_drag_stress'",
52995301
"'aero_model_drydep'", "'gw_tend'",
53005302
"'qbo_relax'", "'iondrag_calc_section'",
53015303
"'physics_dme_adjust'"));

bld/configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,8 +2186,9 @@ sub write_filepath
21862186
print $fh "$camsrcdir/src/atmos_phys/schemes/rasch_kristjansson\n";
21872187
print $fh "$camsrcdir/src/atmos_phys/schemes/utilities\n";
21882188
print $fh "$camsrcdir/src/atmos_phys/schemes/rayleigh_friction\n";
2189-
21902189
print $fh "$camsrcdir/src/atmos_phys/schemes/cloud_fraction\n";
2190+
print $fh "$camsrcdir/src/atmos_phys/schemes/vertical_diffusion\n";
2191+
print $fh "$camsrcdir/src/atmos_phys/schemes/holtslag_boville\n";
21912192

21922193
# Dynamics package and test utilities
21932194
print $fh "$camsrcdir/src/dynamics/$dyn\n";

bld/namelist_files/namelist_definition.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5672,15 +5672,15 @@ Default:
56725672
</entry>
56735673

56745674
<entry id="cam_take_snapshot_before" type="char*32" category="diagnostics"
5675-
group="phys_ctl_nl" valid_values="chem_emissions,aoa_tracers_timestep_tend,co2_cycle_set_ptend,chem_timestep_tend,vertical_diffusion_section,aero_model_drydep,gw_tend,qbo_relax,iondrag_calc_section,physics_dme_adjust,physics_dme_adjust,dadadj_tend,convect_deep_tend,convect_shallow_tend,convect_diagnostics_calc,macrop_driver_tend,clubb_tend_cam,microp_section,microp_driver_tend_subcol,aero_model_wetdep,radiation_tend,held_suarez_tend,kessler_tend,thatcher_jablonowski_precip_tend,rk_stratiform_tend,rayleigh_friction_tend,user_set" >
5675+
group="phys_ctl_nl" valid_values="chem_emissions,aoa_tracers_timestep_tend,co2_cycle_set_ptend,chem_timestep_tend,orographic_form_drag_stress,vertical_diffusion_section,aero_model_drydep,gw_tend,qbo_relax,iondrag_calc_section,physics_dme_adjust,physics_dme_adjust,dadadj_tend,convect_deep_tend,convect_shallow_tend,convect_diagnostics_calc,macrop_driver_tend,clubb_tend_cam,microp_section,microp_driver_tend_subcol,aero_model_wetdep,radiation_tend,held_suarez_tend,kessler_tend,thatcher_jablonowski_precip_tend,rk_stratiform_tend,rayleigh_friction_tend,user_set" >
56765676
Name of parameterization to take snapshot before running
56775677
user_set is used when a user inserts a call to cam_snapshot_all_outfld
56785678
using cam_snapshot_before_num as the first argument.
56795679
Default: Unused
56805680
</entry>
56815681

56825682
<entry id="cam_take_snapshot_after" type="char*32" category="diagnostics"
5683-
group="phys_ctl_nl" valid_values="chem_emissions,aoa_tracers_timestep_tend,co2_cycle_set_ptend,chem_timestep_tend,vertical_diffusion_section,aero_model_drydep,gw_tend,qbo_relax,iondrag_calc_section,physics_dme_adjust,physics_dme_adjust,dadadj_tend,convect_deep_tend,convect_shallow_tend,convect_diagnostics_calc,macrop_driver_tend,clubb_tend_cam,microp_section,microp_driver_tend_subcol,aero_model_wetdep,radiation_tend,held_suarez_tend,kessler_tend,thatcher_jablonowski_precip_tend,rk_stratiform_tend,rayleigh_friction_tend,user_set" >
5683+
group="phys_ctl_nl" valid_values="chem_emissions,aoa_tracers_timestep_tend,co2_cycle_set_ptend,chem_timestep_tend,orographic_form_drag_stress,vertical_diffusion_section,aero_model_drydep,gw_tend,qbo_relax,iondrag_calc_section,physics_dme_adjust,physics_dme_adjust,dadadj_tend,convect_deep_tend,convect_shallow_tend,convect_diagnostics_calc,macrop_driver_tend,clubb_tend_cam,microp_section,microp_driver_tend_subcol,aero_model_wetdep,radiation_tend,held_suarez_tend,kessler_tend,thatcher_jablonowski_precip_tend,rk_stratiform_tend,rayleigh_friction_tend,user_set" >
56845684
Name of parameterization to take snapshot after running
56855685
user_set is used when a user inserts a call to cam_snapshot_all_outfld
56865686
using cam_snapshot_after_num as the first argument.

doc/ChangeLog

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,101 @@
11
===============================================================
22

3+
Tag name: cam6_4_120
4+
Originator(s): jimmielin
5+
Date: September 26, 2025
6+
One-line Summary: Complete CCPPization of HB PBL scheme and vertical diffusion solver (non-WACCM)
7+
Github PR URL: https://github.com/ESCOMP/CAM/pull/1361
8+
9+
Purpose of changes (include the issue number and title text for each relevant GitHub issue):
10+
- Completes #1300 by CCPPizing compute_hb_diff, compute_hb_free_atm_diff, pblintd, trbintd
11+
- Cleanup, refactoring, and optimization of HB
12+
- Partially completes #1205; and completes #1314 by CCPPizing partial interstitial logic of vertical_diffusion_tend
13+
- Partially completes #1205; and completes #1314 by CCPPizing compute_vdiff in diffusion_solver.F90
14+
- Correctly update 'AST' field in physics buffer in RK stratiform CAM interface for snapshot consistency (bit-for-bit).
15+
- Adds snapshot points for orographic form drag stress (Beljaars in CAM6+ and TMS in CAM5) for future CCPPization work.
16+
17+
Describe any changes made to build system:
18+
- add holtslag_boville CCPP scheme
19+
- add vertical_diffusion CCPP scheme
20+
21+
Describe any changes made to the namelist: N/A
22+
23+
List any changes to the defaults for the boundary datasets: N/A
24+
25+
Describe any substantial timing or memory changes: N/A
26+
27+
Code reviewed by: nusbaume
28+
29+
List all files eliminated:
30+
```
31+
D src/physics/cam/hb_diff.F90
32+
- moved to atmos_phys as CCPPized holstlag_boville scheme
33+
D src/physics/cam/vdiff_lu_solver.F90
34+
- moved to atmos_phys into to_be_ccppized (unchanged)
35+
```
36+
37+
List all files added and what they do: N/A
38+
39+
List all existing files that have been modified, and describe the changes:
40+
R053 src/physics/cam/diffusion_solver.F90 src/physics/cam/diffusion_solver_cam.F90
41+
- this is the "remnant" diffusion solver supporting WACCM with molecular diffusion.
42+
- partial refactor to avoid excessive code divergence with CCPPized diffusion_solver.
43+
- renamed to avoid name conflict with CCPPized diffusion_solver.
44+
45+
M bld/configure
46+
- add holtslag_boville and diffusion_solver folders in atmos_phys/schemes to build.
47+
48+
M src/physics/cam/vertical_diffusion.F90
49+
- use CCPPized subroutines for HB and vertical diffusion solver.
50+
51+
M src/physics/cam/eddy_diff_cam.F90
52+
- use CCPPized vertical diffusion solver.
53+
54+
M src/physics/cam/molec_diff.F90
55+
- dechunkize and use assumed dimensions for vd_lu_qdecomp.
56+
57+
M src/physics/cam/clubb_intr.F90
58+
- use CCPPized HB boundary layer computation.
59+
60+
M src/physics/cam/ref_pres.F90
61+
M src/utils/air_composition.F90
62+
- comment updates for clarification of units/purpose.
63+
64+
M src/physics/cam/rk_stratiform_cam.F90
65+
- Correctly update AST pbuf field in RK stratiform CAM interface for snapshot consistency (bit-for-bit).
66+
67+
M src/physics/cam7/physpkg.F90
68+
M src/physics/cam/physpkg.F90
69+
M bld/build-namelist
70+
M bld/namelist_files/namelist_definition.xml
71+
- move Beljaars, TMS drag call routines to physpkg level for snapshotting.
72+
- add orographic_form_drag_stress snapshot point.
73+
74+
M src/control/cam_snapshot_common.F90
75+
- expand size of cam_in snapshot output maximum because it needs to fit all constituents.
76+
77+
If there were any failures reported from running test_driver.sh on any test
78+
platform, and checkin with these failures has been OK'd by the gatekeeper,
79+
then copy the lines from the td.*.status files for the failed tests to the
80+
appropriate machine below. All failed tests must be justified.
81+
82+
derecho/intel/aux_cam: ALL PASS
83+
84+
SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: PASS) details:
85+
- This test continues to fail most of the time on lnd_set_decomp_and_domain.F90 line 497
86+
despite the updated externals.
87+
It can be re-run to eventually work (as it was done here).
88+
89+
derecho/nvhpc/aux_cam:
90+
ERS_Ln9.ne30pg3_ne30pg3_mt232.FHISTC_LTso.derecho_nvhpc.cam-outfrq9s_gpu_default (Overall: FAIL) details:
91+
- pre-existing failure - See issue: https://github.com/ESCOMP/CAM/issues/1383
92+
93+
izumi/nag/aux_cam: ALL PASS
94+
95+
izumi/gnu/aux_cam: ALL PASS
96+
97+
===============================================================
98+
399
Tag name: cam6_4_119
4100
Originator: peverwhee
5101
Date: 26 September, 2025

src/atmos_phys

Submodule atmos_phys updated 28 files

src/control/cam_snapshot_common.F90

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module cam_snapshot_common
8484
type (snapshot_type) :: state_snapshot(30)
8585
type (snapshot_type) :: cnst_snapshot(pcnst)
8686
type (snapshot_type) :: tend_snapshot(6)
87-
type (snapshot_type) :: cam_in_snapshot(30)
87+
type (snapshot_type) :: cam_in_snapshot(pcnst+31) ! needs to be bigger than pcnst because cam_in is split by constituent.
8888
type (snapshot_type) :: cam_out_snapshot(30)
8989
type (snapshot_type_nd) :: pbuf_snapshot(300)
9090

@@ -1218,6 +1218,9 @@ subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
12181218
real(r8), pointer, dimension(:,:,:,:) :: tmpptr4d
12191219
real(r8), pointer, dimension(:,:,:,:,:) :: tmpptr5d
12201220

1221+
! Special handling of integer type fields (output as real)
1222+
integer, pointer, dimension(:,:) :: tmpptr2d_int
1223+
12211224

12221225
do i=1, npbuf_var
12231226

@@ -1227,28 +1230,40 @@ subroutine cam_pbuf_snapshot_all_outfld(lchnk, file_num, pbuf)
12271230
! Turn on the writing for only the requested tape (file_num)
12281231
call cam_history_snapshot_activate(trim(pbuf_snapshot(i)%standard_name), file_num)
12291232

1230-
! Retrieve the pbuf data (dependent on the number of dimensions)
1231-
ndims = count(pbuf_snapshot(i)%dim_name(:) /= '')
1233+
! Retrieve the pbuf data. Special handling for certain
1234+
! integer-type fields.
1235+
if( trim(pbuf_snapshot(i)%ddt_string) == 'clubbtop') then
1236+
call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d_int)
1237+
! copy into real
1238+
allocate(tmpptr2d(size(tmpptr2d_int, 1), size(tmpptr2d_int, 2)))
1239+
tmpptr2d = real(tmpptr2d_int, r8)
1240+
call outfld(pbuf_snapshot(i)%standard_name, tmpptr2d, pcols, lchnk)
1241+
deallocate(tmpptr2d)
1242+
else
1243+
! For regular real-type data:
1244+
! Retrieve the pbuf data (dependent on the number of dimensions)
1245+
ndims = count(pbuf_snapshot(i)%dim_name(:) /= '')
12321246

1233-
select case (ndims) ! Note that dimension 5 and 6 do not work with pbuf_get_field, so these are not used here
1247+
select case (ndims) ! Note that dimension 5 and 6 do not work with pbuf_get_field, so these are not used here
12341248

1235-
case (1)
1236-
call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d)
1237-
call outfld(pbuf_snapshot(i)%standard_name, tmpptr2d, pcols, lchnk)
1249+
case (1)
1250+
call pbuf_get_field(pbuf, pbuf_idx, tmpptr2d)
1251+
call outfld(pbuf_snapshot(i)%standard_name, tmpptr2d, pcols, lchnk)
12381252

1239-
case (2)
1240-
call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1241-
call outfld(pbuf_snapshot(i)%standard_name, tmpptr3d, pcols, lchnk)
1253+
case (2)
1254+
call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1255+
call outfld(pbuf_snapshot(i)%standard_name, tmpptr3d, pcols, lchnk)
12421256

1243-
case (3)
1244-
call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1245-
call outfld(pbuf_snapshot(i)%standard_name, tmpptr4d, pcols, lchnk)
1257+
case (3)
1258+
call pbuf_get_field(pbuf, pbuf_idx, tmpptr3d)
1259+
call outfld(pbuf_snapshot(i)%standard_name, tmpptr4d, pcols, lchnk)
12461260

1247-
case (4)
1248-
call pbuf_get_field(pbuf, pbuf_idx, tmpptr5d)
1249-
call outfld(pbuf_snapshot(i)%standard_name, tmpptr5d, pcols, lchnk)
1261+
case (4)
1262+
call pbuf_get_field(pbuf, pbuf_idx, tmpptr5d)
1263+
call outfld(pbuf_snapshot(i)%standard_name, tmpptr5d, pcols, lchnk)
12501264

1251-
end select
1265+
end select
1266+
endif
12521267

12531268
! Now that the field has been written, turn off the writing for field
12541269
call cam_history_snapshot_deactivate(trim(pbuf_snapshot(i)%standard_name))

src/physics/cam/clubb_intr.F90

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
21052105
use perf_mod, only: t_startf, t_stopf
21062106

21072107
#ifdef CLUBB_SGS
2108-
use hb_diff, only: pblintd
2108+
use holtslag_boville_diff, only: hb_pbl_dependent_coefficients_run
21092109
use clubb_api_module, only: &
21102110
nparams, &
21112111
setup_parameters_api, &
@@ -2599,6 +2599,10 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
25992599
edsclr, &
26002600
n
26012601

2602+
! dummy outputs for CCPP-ized subroutines
2603+
character(len=512) :: errmsg
2604+
integer :: errflg
2605+
26022606
#endif
26032607

26042608
call t_startf('clubb_tend_cam')
@@ -4699,16 +4703,37 @@ subroutine clubb_tend_cam( state, ptend_all, pbuf, hdtime, &
46994703
kbfs (1:ncol) = calc_kinematic_buoyancy_flux(kinheat(1:ncol), zvir, th(1:ncol,pver), kinwat(1:ncol))
47004704
obklen (1:ncol) = calc_obukhov_length(thv(1:ncol,pver), ustar2(1:ncol), gravit, karman, kbfs(1:ncol))
47014705

4702-
dummy2(:) = 0._r8
4703-
dummy3(:) = 0._r8
47044706

47054707
where (kbfs(:ncol) == -0.0_r8) kbfs(:ncol) = 0.0_r8
47064708

4707-
! Compute PBL depth according to Holtslag-Boville Scheme
4708-
call pblintd(ncol, thv, state1%zm, state1%u, state1%v, &
4709-
ustar2, obklen, kbfs, pblh, dummy2, &
4710-
state1%zi, cloud_frac(:,1:pver), 1._r8-cam_in%landfrac, dummy3)
4711-
4709+
! Compute PBL depth according to Holtslag-Boville Scheme -- only pblh is needed here
4710+
! and other outputs are discarded
4711+
!REMOVECAM - no longer need this when CAM is retired and pcols no longer exists
4712+
pblh(:) = 0._r8
4713+
dummy2(:) = 0._r8
4714+
dummy3(:) = 0._r8
4715+
!REMOVECAM_END
4716+
call hb_pbl_dependent_coefficients_run( &
4717+
ncol = ncol, &
4718+
pver = pver, &
4719+
pverp = pverp, &
4720+
gravit = gravit, &
4721+
z = state1%zm(:ncol,:pver), &
4722+
zi = state1%zi(:ncol,:pverp), &
4723+
u = state1%u(:ncol,:pver), &
4724+
v = state1%v(:ncol,:pver), &
4725+
cldn = cloud_frac(:ncol,:pver), &
4726+
! Inputs from CLUBB (not HB coefficients)
4727+
thv = thv(:ncol,:pver), &
4728+
ustar = ustar2(:ncol), &
4729+
kbfs = kbfs(:ncol), &
4730+
obklen = obklen(:ncol), &
4731+
! Output variables
4732+
pblh = pblh(:ncol), &
4733+
wstar = dummy2(:ncol), &
4734+
bge = dummy3(:ncol), &
4735+
errmsg = errmsg, &
4736+
errflg = errflg)
47124737

47134738
! Assign the first pver levels of cloud_frac back to cld
47144739
cld(:,1:pver) = cloud_frac(:,1:pver)

0 commit comments

Comments
 (0)