Skip to content

When allocating dyn_const_array pre-calculate size to avoid line length limits#724

Open
jimmielin wants to merge 1 commit intoNCAR:developfrom
jimmielin:hplin/host_cap_dyn_const_line_limit
Open

When allocating dyn_const_array pre-calculate size to avoid line length limits#724
jimmielin wants to merge 1 commit intoNCAR:developfrom
jimmielin:hplin/host_cap_dyn_const_line_limit

Conversation

@jimmielin
Copy link
Contributor

[ 50 character, one line summary ]

Avoid syntax error in long dyn_const_array alloc.

[ Description of the changes in this commit. It should be enough
information for someone not following this development to understand.
Lines should be wrapped at about 72 characters. ]

When multiple schemes return dynamic constituents, the host cap generator
builds the allocate statement as a single long expression like:

allocate(tracer_data_test_dynamic_constituents(0+size(ozone_constituents)+size(aerosol_constituents)+size(volcaero_consti&
     tuents)))

This got chopped off mid-identifier, producing a syntax error.

Fix: compute the total size incrementally into num_dyn_consts
before the allocate, so no single line is long enough (hopefully!)
to trigger continuation:

num_dyn_consts = 0
num_dyn_consts = num_dyn_consts + size(ozone_constituents)
num_dyn_consts = num_dyn_consts + size(aerosol_constituents)
num_dyn_consts = num_dyn_consts + size(volcaero_constituents)
allocate(tracer_data_test_dynamic_constituents(num_dyn_consts))

I reset num_dyn_consts to 0 afterward for the packing loop so there is no logic
change downstream.

User interface changes?: No

Fixes: TBA

Testing:
test removed:
unit tests:
system tests:
manual testing: tested to work in CAM-SIMA where it previously was not

Copy link
Collaborator

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

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

This looks great to me, thanks for fixing the bug. I am ok with not creating a separate issue here, because it's all explained nicely in the PR description.

@climbfuji climbfuji added the capgen bugs, requests, etc. that involve ccpp_capgen label Mar 13, 2026
Copy link
Collaborator

@peverwhee peverwhee left a comment

Choose a reason for hiding this comment

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

thanks @jimmielin

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.

3 participants