Skip to content

cam6_4_173: fix energy bug in physics-dynamics coupling#1554

Merged
jimmielin merged 10 commits into
ESCOMP:cam_developmentfrom
PeterHjortLauritzen:pdc-energy-bug-fix
May 15, 2026
Merged

cam6_4_173: fix energy bug in physics-dynamics coupling#1554
jimmielin merged 10 commits into
ESCOMP:cam_developmentfrom
PeterHjortLauritzen:pdc-energy-bug-fix

Conversation

@PeterHjortLauritzen
Copy link
Copy Markdown
Collaborator

@PeterHjortLauritzen PeterHjortLauritzen commented May 12, 2026

Closes #1551 - Bug in physics tendency scaling
Closes #1553 - RRTMGP diagnostic net_flx bug
Closes #1550 - ZM scheme no longer conserving energy

@PeterHjortLauritzen
Copy link
Copy Markdown
Collaborator Author

Please note that we need to make these changes in CAM-SIMA as well!

@peverwhee peverwhee added the misc tag issue or PR candidate for upcoming misc tag label May 12, 2026
@jimmielin
Copy link
Copy Markdown
Member

Thanks @PeterHjortLauritzen! I checked and the same issue is present in CAM-SIMA.

As I understand from reading your fix, my proposed fix for CAM-SIMA is to create a registry variable saving cp_or_cv_dycore_at_start_of_physics_timestep (to avoid saving it into a temp variable) with the value computed in d_p_coupling, where it calls cam_thermo_water_update to update cp_or_cv_dycore. This value computed at the beginning of the physics timestep is the one that should always be provided to the energy checker/fixer.

When thermo_water_uptake is called within physics, updating cp_or_cv_dycore, its only intended use is for tot_energy_phys diagnostics.

Is that understanding correct? If yes then I can start drafting the equivalent fix in CAM-SIMA which will look different since we don't have physpkg.

@PeterHjortLauritzen
Copy link
Copy Markdown
Collaborator Author

Yes in current CAM! Once we move towards a true variable latent heat formulation in physics we would update cp_pr_cv after each parameterization ...

Copy link
Copy Markdown
Collaborator

@nusbaume nusbaume left a comment

Choose a reason for hiding this comment

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

@cacraigucar cacraigucar changed the title fix energy bug in physics-dynamics coupling cam6_4_173: fix energy bug in physics-dynamics coupling May 12, 2026
@jimmielin jimmielin merged commit 14ad2a0 into ESCOMP:cam_development May 15, 2026
2 checks passed
jimmielin added a commit to ESCOMP/atmospheric_physics that referenced this pull request May 18, 2026
Tag name (The PR title should also include the tag name):
Originator(s): @jimmielin (adapted from original fixes by
@PeterHjortLauritzen)

Description (include issue title and the keyword ['closes', 'fixes',
'resolves'] and issue number):
- CAM-SIMA equivalent of ESCOMP/CAM#1554
- Add missing `thermo_water_update` call (although commented out as not
used) in CAM4 SDF

List all namelist files that were added or changed:

List all files eliminated and why:

List all files added and what they do:

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
main...<your_branch_name>`)
```
M       schemes/conservation_adjust/check_energy/check_energy_chng.meta
M       schemes/conservation_adjust/check_energy/check_energy_scaling.meta
M       schemes/conservation_adjust/check_energy/dycore_energy_consistency_adjust.meta
M       schemes/sima_diagnostics/check_energy_diagnostics.F90
M       schemes/sima_diagnostics/check_energy_diagnostics.meta
  - update cp_or_cv_dycore and scaling_dycore standard names to add _at_start_of_physics_timestep as correctly intended

M       suites/suite_cam7.xml
M       suites/suite_kessler.xml
M       suites/suite_tj2016.xml
  - comment out thermo_water_update as it is used for not-yet-present tot_energy_phys diag.
  - add comments explaining the true purpose of mid-physics thermo_water_update.

M       suites/suite_cam4.xml
  - add missing commented thermo_water_update call to be consistent with other SDFs
```

List all automated tests that failed, as well as an explanation for why
they weren't fixed:

Is this an answer-changing PR? If so, is it a new physics package,
algorithm change, tuning change, etc?

If yes to the above question, describe how this code was validated with
the new/modified features:
jimmielin added a commit to ESCOMP/CAM-SIMA that referenced this pull request May 18, 2026
…498)

Tag name (required for release branches): sima0_14_000
Originator(s): @jimmielin (adapted from original fixes by
@PeterHjortLauritzen)
AI tools used (if applicable; please also add the "AI-generated code"
label to the PR):
  What:
  How:

Description (include the issue title, and the keyword ['closes',
'fixes', 'resolves'] followed by the issue number):
- Companion issue of
ESCOMP/atmospheric_physics#393
- CAM-SIMA equivalent fix of ESCOMP/CAM#1554

Describe any changes made to build system:

Describe any changes made to the namelist:

List any changes to the defaults for the input datasets (e.g. boundary
datasets):

List all files eliminated and why:

List all files added and what they do:

List all existing files that have been modified, and describe the
changes:
(Helpful git command: `git diff --name-status
development...<your_branch_name>`)
```
M       src/data/registry.xml
M       tools/stdnames_to_inputnames_dictionary.xml
  - update long name of cp_or_cv_dycore to clarify its runtime usage
  - add cp_or_cv_dycore_at_start_of_physics_timestep which is used by the dycore energy consistency adjust scheme and energy checker

M       src/dynamics/mpas/dyn_coupling_impl.F90
M       src/dynamics/se/dp_coupling.F90
  - save cp_or_cv_dycore_at_start_of_physics_timestep during d-p coupling
```

If there are new failures (compared to the
`test/existing-test-failures.txt` file),
have them OK'd by the gatekeeper, note them here, and add them to the
file.
If there are baseline differences, include the test and the reason for
the
diff. What is the nature of the change? Roundoff?

derecho/intel/aux_sima:
```
  SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_intel.cam-outfrq_kessler_mpas_derecho (Overall: DIFF) details:
    FAIL SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_intel.cam-outfrq_kessler_mpas_derecho BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_intel: DIFF
  SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_intel.cam-outfrq_se_cslam (Overall: DIFF) details:
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_intel.cam-outfrq_se_cslam BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_intel: DIFF
  SMS_Ln9.ne3pg3_ne3pg3_mg37.FTJ16.derecho_intel.cam-outfrq_se_cslam (Overall: DIFF) details:
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FTJ16.derecho_intel.cam-outfrq_se_cslam BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_intel: DIFF
  - new baselines due to thermo_water_update bug fix.

  SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_intel.cam-outfrq_se_cslam_multitape (Overall: DIFF) details:
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_intel.cam-outfrq_se_cslam_multitape NLCOMP
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_intel.cam-outfrq_se_cslam_multitape BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_intel: DIFF
  - pre-existing failure.
  - new baselines due to thermo_water_update bug fix.
```

derecho/gnu/aux_sima:
```
  SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_gnu.cam-outfrq_kessler_mpas_derecho (Overall: DIFF) details:
    FAIL SMS_Ln9.mpasa480_mpasa480.FKESSLER.derecho_gnu.cam-outfrq_kessler_mpas_derecho BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_gnu: DIFF
  SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_gnu.cam-outfrq_se_cslam (Overall: DIFF) details:
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FKESSLER.derecho_gnu.cam-outfrq_se_cslam BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_gnu: DIFF
  SMS_Ln9.ne3pg3_ne3pg3_mg37.FTJ16.derecho_gnu.cam-outfrq_se_cslam (Overall: DIFF) details:
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FTJ16.derecho_gnu.cam-outfrq_se_cslam BASELINE /glade/campaign/cesm/community/amwg/sima_baselines/latest_gnu: DIFF
  - new baselines due to thermo_water_update bug fix.

  SMS_Ln9.ne3pg3_ne3pg3_mg37.FADIAB.derecho_gnu.cam-outfrq_se_cslam (Overall: FAIL) details:
    FAIL SMS_Ln9.ne3pg3_ne3pg3_mg37.FADIAB.derecho_gnu.cam-outfrq_se_cslam RUN time=13
  - pre-existing failure.
```

derecho/nvhpc/aux_sima (test is run via Github workflow. Only run the
test manually if we need to save new baselines): All PASS

If this changes climate describe any run(s) done to evaluate the new
climate in enough detail that it(they) could be reproduced:

CAM-SIMA date used for the baseline comparison tests if different than
latest:

---------

Co-authored-by: Kuan-Chih Wang <towerman@livemail.tw>
gold2718 pushed a commit to NorESMhub/CAM that referenced this pull request May 19, 2026
gold2718 added a commit to NorESMhub/CAM that referenced this pull request May 19, 2026
noresm3_0_034_cam6_4_121: Energy conservation bug fixes from NCAR

Summary: Incorporate bug fixes for energy conservation errors discovered at NCAR
Contributors: @gold2718 
Reviewers: @oyvindseland, @mvertens 
Purpose of changes: Fix energy conservation bugs
- ESCOMP#1550
- ESCOMP#1551
Github PR URL: #277
Changes made to build system: None
Changes made to the namelist: None
Changes to the defaults for the boundary datasets: None
Substantial timing or memory changes: None
Energy bug fixes from NCAR
- NorESMhub/atmospheric_physics#4
- ESCOMP#1554
Testing:
- aux_cam_noresm on Olivia: All PASS except for namelist change in nuopc.runconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

misc tag issue or PR candidate for upcoming misc tag Must have CESM3

Projects

Status: Tag

Development

Successfully merging this pull request may close these issues.

4 participants