Skip to content

fix(path_utils): resolve C(E|T)SM root paths in Python tools (resolves #2658, #3552) - #4207

Open
johnpaulalex wants to merge 3 commits into
ESCOMP:b4b-devfrom
johnpaulalex:fix/2658-ccs-config-path
Open

johnpaulalex wants to merge 3 commits into
ESCOMP:b4b-devfrom
johnpaulalex:fix/2658-ccs-config-path

Conversation

@johnpaulalex

Copy link
Copy Markdown
Contributor

Description of changes

This PR resolves issues #2658 and #3552 where CTSM Python tools (gen_mksurfdata_namelist, subset_data, run_tower, tower_site) failed when executed inside a full CESM checkout layout (<CESM_ROOT>/components/clm).

Key Refactoring:

  1. Added path_under_ctsm() & path_under_top_submodule():
    • path_under_ctsm() strictly resolves submodules under <CTSM_ROOT>/<submodule>.
    • path_under_top_submodule() checks <CTSM_ROOT>/<submodule> first, falling back to <CESM_ROOT>/<submodule> when inside a CESM checkout.
  2. Added path_to_ccs_config() & path_to_top_root():
    • Replaced fragile relative path_to_cime()/../ccs_config calls in gen_mksurfdata_namelist with path_to_ccs_config().
    • Updated subset_data.py, run_tower.py, and tower_site.py to use path_to_top_root() for cesmroot while retaining path_to_ctsm_root() for CTSM-internal config (default_data_2000.cfg, cime_config/usermods_dirs).
  3. Renamed standalone_only to ctsm_only:
    • Updated parameter names across path_utils.py, run_sys_tests, and unit test modules for clearer intent.
  4. Targeted Unit Tests:
    • Added test_setupFiles_cesmCheckoutLayout in test_unit_subset_data.py.
    • Added test_towerSite_cesmCheckoutLayout in test_unit_run_tower.py.

Specific notes

Contributors other than yourself, if any:

  • None

CTSM issues resolved or otherwise addressed, if any:

Description of generative AI usage:
Google Antigravity was used to write the code and tests, followed by human-guided verification.

Any user interface changes (namelist or namelist defaults changes)?
None.

Testing planned or performed, if any:

  • python3 -m unittest python/ctsm/test/test_unit_path_utils.py: 15/15 OK
  • python3 -m unittest python/ctsm/test/test_unit_subset_data.py: 37/37 OK (including test_setupFiles_cesmCheckoutLayout)
  • python3 -m unittest python/ctsm/test/test_unit_run_tower.py: 3/3 OK (including test_towerSite_cesmCheckoutLayout)

Requirements before merge:

  • I have followed the CTSM contribution guidelines.
  • The code in this PR branch builds with no errors.
  • The code in this PR branch runs with no errors. Briefly describe tested configuration(s): Python unit test suites (test_unit_path_utils.py, test_unit_subset_data.py, test_unit_run_tower.py) under macOS python3 environment.
  • This either (a) does not change answers, (b) it only changes answers at roundoff level, or (c) I have performed a scientific evaluation of the answer changes. Which?: (a) Does not change answers (pure toolchain fix).
  • I have reviewed relevant parts of the CLM documentation Tech Note or User's Guide to determine if anything needs to be changed or added. If it does, describe: No changes required.
  • This PR either (a) does not create a need to update the documentation or (b) includes required documentation updates (see guidelines for contributing documentation). Which?: (a) Does not require documentation updates.

@johnpaulalex johnpaulalex changed the title fix(path_utils,subset_data): resolve ccs_config and CESM root paths in Python tools (resolves #2658, #3552) fix(path_utils): resolve ccs_config and CESM root paths in Python tools (resolves #2658, #3552) Sep 13, 2026
@johnpaulalex johnpaulalex changed the title fix(path_utils): resolve ccs_config and CESM root paths in Python tools (resolves #2658, #3552) fix(path_utils): resolve C(E|T)SM root paths in Python tools (resolves #2658, #3552) Sep 13, 2026
@johnpaulalex
johnpaulalex force-pushed the fix/2658-ccs-config-path branch 2 times, most recently from f2b43d2 to 7e24a94 Compare September 13, 2026 13:54
@johnpaulalex
johnpaulalex force-pushed the fix/2658-ccs-config-path branch 4 times, most recently from e3a8344 to 85aafae Compare September 13, 2026 14:12
@johnpaulalex
johnpaulalex force-pushed the fix/2658-ccs-config-path branch from 85aafae to 211a991 Compare September 13, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant