Skip to content

part of atmos_phys0_31_000: Use CCPP-framework provided constituent lookup instead of homegrown method - #451

Closed
nusbaume wants to merge 2 commits into
ESCOMP:mainfrom
nusbaume:remove_const_utils
Closed

nusbaume wants to merge 2 commits into
ESCOMP:mainfrom
nusbaume:remove_const_utils

Conversation

@nusbaume

@nusbaume nusbaume commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Tag name (The PR title should also include the tag name):
Originator(s): nusbaume (with actual code mods coming from Claude Opus-5.5)

Description (include issue title and the keyword ['closes', 'fixes', 'resolves'] and issue number):

This PR replaces the use of the locally-provided ccpp_const_get_idx with the CCPP-framework provided ccpp_constituent_index subroutine, and removes the no-longer-needed ccpp_const_utils.F90. Beyond just code clean-up, this switch provides two major advantages:

  1. It increase physics scheme portability, as all CCPP host models should have access to ccpp_constituent_index
  2. It improves performance by replacing a linear search method with a hash table, thus improving performance from O(n) to O(1).

Fixes #215
Addresses #137

List all namelist files that were added or changed: N/A

List all files eliminated and why:

D       to_be_ccppized/ccpp_const_utils.F90
 - The module is no longer needed/used.

List all files added and what they do:

A       test/musica/musica_test_constituents.F90
  - Helper routine used to run the MUSICA test.

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/bretherton_park/bretherton_park_diff.F90
M       schemes/bretherton_park/bretherton_park_diff.meta
M       schemes/hack_shallow/hack_convect_shallow.F90
M       schemes/holtslag_boville/holtslag_boville_diff_interstitials.F90
M       schemes/holtslag_boville/holtslag_boville_diff_interstitials.meta
M       schemes/musica/musica_ccpp.F90
M       schemes/musica/util/musica_ccpp_species.F90
M       schemes/sima_diagnostics/diffusion_solver_diagnostics.F90
M       schemes/sima_diagnostics/diffusion_solver_diagnostics.meta
M       schemes/sima_diagnostics/gravity_wave_drag_common_diagnostics.F90
M       schemes/sima_diagnostics/gravity_wave_drag_common_diagnostics.meta
M       schemes/vertical_diffusion/vertical_diffusion_interstitials.F90
M       schemes/vertical_diffusion/vertical_diffusion_interstitials.meta
 - Update schemes to use 'ccpp_constituent_index'

M       test/musica/CMakeLists.txt
M       test/musica/aerosol/CMakeLists.txt
M       test/musica/aerosol_stub/CMakeLists.txt
A       test/musica/musica_test_constituents.F90
M       test/musica/test_musica_api.F90
M       test/musica/test_musica_species.F90
M       test/musica/tuvx/CMakeLists.txt
M       test/musica/tuvx/test_tuvx_gas_species.F90
M       test/musica/util/CMakeLists.txt
 - Update MUSICA test to use 'ccpp_constituent_index'

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?

No, this PR will not change answers.

If yes to the above question, describe how this code was validated with the new/modified features:

@nusbaume nusbaume self-assigned this Oct 1, 2026
@nusbaume nusbaume added enhancement New feature or request cleanup This issue indicates an opportunity for code cleanup. labels Oct 1, 2026
@nusbaume
nusbaume requested a review from jimmielin October 5, 2026 15:20

@jimmielin jimmielin 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.

Thanks @nusbaume! Just a few notes that didn't fit in particular locations:

  • This changes several schemes (HB, UW, ...) to remove const_props, so a CAM update is needed
  • If a CAM update is made, the lookup might need to be updated to be case-insensitive, and also return errcode=0 with int_unassigned instead of errcode=1 when not found (this might crash a good amount of CCPP schemes)

@nusbaume

nusbaume commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Great catch @jimmielin! I've made ESCOMP/CAM#1711 to implement the needed CAM-side changes.

@nusbaume
nusbaume requested a review from peverwhee October 8, 2026 15:23

@peverwhee peverwhee 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.

looks great to me!

@jimmielin jimmielin changed the title Use CCPP-framework provided constituent lookup instead of homegrown method part of atmos_phys0_31_000: Use CCPP-framework provided constituent lookup instead of homegrown method Oct 12, 2026
@jimmielin

Copy link
Copy Markdown
Collaborator

merged as part of #433

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

Labels

cleanup This issue indicates an opportunity for code cleanup. enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Replace temporary ccpp_const_get_idx subroutine with official CCPP-framework version

3 participants