Skip to content

[feature/capgen-v1] Bug fix in group_cap.py: use full access path for variables that are not control - #790

Open
climbfuji wants to merge 1 commit into
feature/capgen-v1from
bugfix/ddt_comp_var_decl
Open

climbfuji wants to merge 1 commit into
feature/capgen-v1from
bugfix/ddt_comp_var_decl

Conversation

@climbfuji

@climbfuji climbfuji commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Reported by @dustinswales via email: with a unit transform active, the generated group cap declares the transformation temporary with a bare dimension name instead of the host's full access path.

real(kind=kind_phys), dimension(lb:ub, levs), target :: re_cloud_l   ! wrong
real(kind=kind_phys), dimension(lb:ub, GFS_Control%levs), target :: re_cloud_l

Everything else about the transform — the pre- and post-scheme assignments and the pointer wiring — was correct.

Cause. _dim_decl_local (capgen/generator/group_cap.py) resolved each dimension standard name to entry.local_name. For a DDT-held dimension that is the leaf (levs); the full path is entry.access_path (GFS_Control%levs). The rule is already documented in suite_resolver.py:523, using this exact example — this was one site not following it. Fixed by routing through _render_value_expr.

Why it surfaced now. The declaration is only emitted when a transform is needed (if arg.temp_name, group_cap.py:983). UFS performed no variable transformations until now. Changing mp_tempo.meta from microns to meters created the first transform on a DDT-dimensioned array.

Scope. One site. The other entry.local_name uses in the emitters are control variables — cap dummy arguments, where the local name is correct. That includes the horizontal_dimension branch of the same function.

Test gap. TestDimDeclLocal covered vertical dimensions already, but every fixture used plain module-level host variables, where local_name and access_path are the same string. Added test_ddt_component_dim_uses_full_access_path.

Verified against the reported configuration: the emitted declaration is now , dimension(lb:ub, GFS_Control%levs).

run_tests.py --doctest   → 1584, OK
pytest -q unit-tests/    → 1502 passed, 57 subtests
--doctest-modules capgen  → 97 passed
end-to-end tests → all passed

Once this lands, @dustinswales' workaround scaling those fields at the end of mp_tempo_run can be removed.

Closes #791

🤖 Generated with Claude Code

https://claude.ai/code/session_018LCwe5wtTR5m9qJtPRGMWe

…n-control variables in variable declarations so that DDT-components are found correctly
@climbfuji
climbfuji requested review from a team as code owners September 28, 2026 15:14
@climbfuji climbfuji self-assigned this Sep 28, 2026
@climbfuji climbfuji added the capgen bugs, requests, etc. that involve ccpp_capgen label Sep 28, 2026
@climbfuji climbfuji changed the title Bug fix in capgen/generator/group_cap.py: use full access path for no… Bug fix in group_cap.py: use full access path for variables that are not control Sep 28, 2026
@climbfuji climbfuji changed the title Bug fix in group_cap.py: use full access path for variables that are not control [feature/capgen-v1] Bug fix in group_cap.py: use full access path for variables that are not control Sep 28, 2026

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

@climbfuji LGTM. Thank you for fixing this.
"access_path"!

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

Labels

capgen bugs, requests, etc. that involve ccpp_capgen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Variable transform temporary declared with bare dimension name instead of DDT access path

2 participants