Skip to content

cam6_4_086: Rayleigh Friction to CCPP #1245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
[submodule "atmos_phys"]
path = src/atmos_phys
url = https://github.com/ESCOMP/atmospheric_physics
fxtag = atmos_phys0_12_000
fxtag = atmos_phys0_13_000
fxrequired = AlwaysRequired
fxDONOTUSEurl = https://github.com/ESCOMP/atmospheric_physics

Expand Down
2 changes: 2 additions & 0 deletions bld/build-namelist
Original file line number Diff line number Diff line change
Expand Up @@ -5262,6 +5262,7 @@ sub check_snapshot_settings {
"'qbo_relax'", "'iondrag_calc_section'",
"'physics_dme_adjust'"));
push (@validList_bc, ("'dadadj_tend'", "'convect_deep_tend'",
"'rayleigh_friction_tend'",
"'convect_diagnostics_calc'"));
} else {
# CAM physpkg
Expand All @@ -5276,6 +5277,7 @@ sub check_snapshot_settings {
"'qbo_relax'", "'iondrag_calc_section'",
"'physics_dme_adjust'"));
push (@validList_bc, ("'dadadj_tend'", "'convect_deep_tend'",
"'rayleigh_friction_tend'",
"'convect_shallow_tend'"));
if ($microphys =~ /^mg/) {
if ($clubb_sgs =~ /$TRUE/io) {
Expand Down
1 change: 1 addition & 0 deletions bld/configure
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,7 @@ sub write_filepath
print $fh "$camsrcdir/src/atmos_phys/schemes/hack_shallow\n";
print $fh "$camsrcdir/src/atmos_phys/schemes/rasch_kristjansson\n";
print $fh "$camsrcdir/src/atmos_phys/schemes/utilities\n";
print $fh "$camsrcdir/src/atmos_phys/schemes/rayleigh_friction\n";

print $fh "$camsrcdir/src/atmos_phys/schemes/cloud_fraction\n";

Expand Down
4 changes: 2 additions & 2 deletions bld/namelist_files/namelist_definition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5665,15 +5665,15 @@ Default:
</entry>

<entry id="cam_take_snapshot_before" type="char*32" category="diagnostics"
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,user_set" >
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" >
Name of parameterization to take snapshot before running
user_set is used when a user inserts a call to cam_snapshot_all_outfld
using cam_snapshot_before_num as the first argument.
Default: Unused
</entry>

<entry id="cam_take_snapshot_after" type="char*32" category="diagnostics"
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,user_set" >
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" >
Name of parameterization to take snapshot after running
user_set is used when a user inserts a call to cam_snapshot_all_outfld
using cam_snapshot_after_num as the first argument.
Expand Down
83 changes: 83 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,88 @@
===============================================================

Tag name: cam6_4_086
Originator(s): katetc
Date: 18 April 2025
One-line Summary: CCPP-ize Rayleigh Friction
Github PR URL: https://github.com/ESCOMP/CAM/pull/1245

Purpose of changes (include the issue number and title text for each relevant GitHub issue):
- Brings in new atmospheric_physics external and changes Rayleigh Friction code to use CCPP compatible interfaces
- Closes #1153 - Conversion of Rayleigh Friction to CCPP

Describe any changes made to build system:
bld/configure
- Add src/atmos_phys/schemes/rayleigh_friction to the build tree

Describe any changes made to the namelist:
bld/build-namelist
bld/namelist_files/namelist_definition.xml
- Changes to add rayleigh_friction_tend snapshot capability

List any changes to the defaults for the boundary datasets: N/A

Describe any substantial timing or memory changes: N/A

Code reviewed by: nusbaume, cacraig

List all files eliminated:
D src/physics/cam/rayleigh_friction.F90
- moved to atmospheric_physics: rayleigh_friction scheme

List all files added and what they do:
A src/physics/cam/rayleigh_friction_cam.F90
- Contains the read_nl code and namelist parameters for ccppized Rayleigh Friction scheme

List all existing files that have been modified, and describe the changes:
M .gitmodules
M src/atmos_phys
- New atmospheric_physics external tag atmos_phys0_13_000 and updated submodule

M bld/build-namelist
M bld/namelist_files/namelist_definition.xml
- Add snapshot cpability for rayleigh_friction_tend

M bld/configure
- Add src/atmos_phys/schemes/rayleigh_friction to the build tree

M src/control/runtime_opts.F90
- Change module for rayleigh_friction_readnl from rayleigh_friction to rayleigh_friction_cam

M src/physics/cam/physpkg.F90
M src/physics/cam7/physpkg.F90
- Non-Answer changing modifications to use the CCPP version of Rayleigh Friction

If there were any failures reported from running test_driver.sh on any test
platform, and checkin with these failures has been OK'd by the gatekeeper,
then copy the lines from the td.*.status files for the failed tests to the
appropriate machine below. All failed tests must be justified.

derecho/intel/aux_cam:
ERP_Ln9.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq9s (Overall: FAIL) details:
SMS_Lh12.f09_f09_mg17.FCSD_HCO.derecho_intel.cam-outfrq3h (Overall: DIFF) details:
- pre-existing failures due to HEMCO not having reproducible results (issues #1018 and #856)

SMS_D_Ln9_P1280x1.ne0CONUSne30x8_ne0CONUSne30x8_mt12.FCHIST.derecho_intel.cam-outfrq9s (Overall: FAIL) details:
- pre-existing failures due to build-namelist error requiring CLM/CTSM external update

derecho/nvhpc/aux_cam:
ERS_Ln9.ne30pg3_ne30pg3_mg17.F2000dev.derecho_nvhpc.cam-outfrq9s_gpu_default (Overall: PASS) details:
- Compare against cam6_4_082_nvhpc baselines due to machine error preventing the test from running for the last few tags.

izumi/nag/aux_cam:
- All pass

izumi/gnu/aux_cam:
- All pass

CAM tag used for the baseline comparison tests if different than previous
tag: Nvhpc baseline comapare against cam6_4_082_nvhpc due to machine problems between tags

Summarize any changes to answers:
No answer changes, all b4b

===============================================================

Tag name: cam6_4_085
Originator(s): jimmielin
Date: 11 April 2025
Expand Down
2 changes: 1 addition & 1 deletion src/control/runtime_opts.F90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ subroutine read_namelist(nlfilename, single_column, scmlat, scmlon)
use aircraft_emit, only: aircraft_emit_readnl
use cospsimulator_intr, only: cospsimulator_intr_readnl
use vertical_diffusion, only: vd_readnl
use rayleigh_friction, only: rayleigh_friction_readnl
use rayleigh_friction_cam, only: rayleigh_friction_readnl

use cam_diagnostics, only: diag_readnl
use radheat, only: radheat_readnl
Expand Down
45 changes: 41 additions & 4 deletions src/physics/cam/physpkg.F90
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,7 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )
use tracers, only: tracers_init
use aoa_tracers, only: aoa_tracers_init
use rayleigh_friction, only: rayleigh_friction_init
use rayleigh_friction_cam, only: rf_nl_k0, rf_nl_krange, rf_nl_tau0
use vertical_diffusion, only: vertical_diffusion_init
use phys_debug_util, only: phys_debug_init
use rad_constituents, only: rad_cnst_init
Expand Down Expand Up @@ -791,6 +792,11 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )
! temperature, water vapor, cloud
! ice, cloud liquid, U, V
integer :: history_budget_histfile_num ! output history file number for budget fields

! Needed for rayleigh friction
character(len=512) errmsg
integer errflg

!-----------------------------------------------------------------------

call physics_type_alloc(phys_state, phys_tend, begchunk, endchunk, pcols)
Expand Down Expand Up @@ -879,7 +885,9 @@ subroutine phys_init( phys_state, phys_tend, pbuf2d, cam_in, cam_out )

call gw_init()

call rayleigh_friction_init()
call rayleigh_friction_init(pver, rf_nl_tau0, rf_nl_krange, rf_nl_k0, masterproc, &
iulog, errmsg, errflg)
if (errflg /= 0) call endrun(errmsg)

call vertical_diffusion_init(pbuf2d)

Expand Down Expand Up @@ -1360,11 +1368,11 @@ subroutine tphysac (ztodt, cam_in, &
use cam_diagnostics, only: diag_phys_tend_writeout
use gw_drag, only: gw_tend
use vertical_diffusion, only: vertical_diffusion_tend
use rayleigh_friction, only: rayleigh_friction_tend
use rayleigh_friction, only: rayleigh_friction_run
use constituents, only: cnst_get_ind
use physics_types, only: physics_state, physics_tend, physics_ptend, physics_update, &
physics_dme_adjust, set_dry_to_wet, physics_state_check, &
dyn_te_idx
dyn_te_idx, physics_ptend_init
use waccmx_phys_intr, only: waccmx_phys_mspd_tend ! WACCM-X major diffusion
use waccmx_phys_intr, only: waccmx_phys_ion_elec_temp_tend ! WACCM-X
use aoa_tracers, only: aoa_tracers_timestep_tend
Expand Down Expand Up @@ -1456,6 +1464,10 @@ subroutine tphysac (ztodt, cam_in, &
! For aerosol budget diagnostics
type(carma_diags_t), pointer :: carma_diags_obj

! For rayleigh friction CCPP calls
character(len=512) errmsg
integer errflg

!-----------------------------------------------------------------------
carma_diags_obj => carma_diags_t()
if (.not.associated(carma_diags_obj)) then
Expand Down Expand Up @@ -1676,14 +1688,39 @@ subroutine tphysac (ztodt, cam_in, &
! Rayleigh friction calculation
!===================================================
call t_startf('rayleigh_friction')
call rayleigh_friction_tend( ztodt, state, ptend)
if (trim(cam_take_snapshot_before) == "rayleigh_friction_tend") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_before_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat)
end if

call physics_ptend_init(ptend, state%psetcols, 'rayleigh friction', ls=.true., lu=.true., lv=.true.)

! Initialize ptend variables to zero
!REMOVECAM - no longer need these when CAM is retired and pcols no longer exists
ptend%u(:,:) = 0._r8
ptend%v(:,:) = 0._r8
ptend%s(:,:) = 0._r8
!REMOVECAM_END

call rayleigh_friction_run(pver, ztodt, state%u(:ncol,:), state%v(:ncol,:), ptend%u(:ncol,:),&
ptend%v(:ncol,:), ptend%s(:ncol,:), errmsg, errflg)
if (errflg /= 0) call endrun(errmsg)

if ( (trim(cam_take_snapshot_after) == "rayleigh_friction_tend") .and. &
(trim(cam_take_snapshot_before) == trim(cam_take_snapshot_after))) then
call cam_snapshot_ptend_outfld(ptend, lchnk)
end if
if ( ptend%lu ) then
call outfld( 'UTEND_RAYLEIGH', ptend%u, pcols, lchnk)
end if
if ( ptend%lv ) then
call outfld( 'VTEND_RAYLEIGH', ptend%v, pcols, lchnk)
end if
call physics_update(state, ptend, ztodt, tend)
if (trim(cam_take_snapshot_after) == "rayleigh_friction_tend") then
call cam_snapshot_all_outfld_tphysac(cam_snapshot_after_num, state, tend, cam_in, cam_out, pbuf,&
fh2o, surfric, obklen, flx_heat)
end if
call t_stopf('rayleigh_friction')

if (do_clubb_sgs) then
Expand Down
Loading