-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle dimensions for promoted variables #562
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2230,9 +2230,22 @@ def analyze(self, phase, suite_vars, scheme_library, ddt_library, | |
self.run_env.logger.debug("{}".format(self)) | ||
# end if | ||
|
||
def allocate_dim_str(self, dims, context): | ||
def allocate_dim_str(self, dims, context, suite_var=False): | ||
"""Create the dimension string for an allocate statement""" | ||
rdims = list() | ||
if suite_var: | ||
# adjust horizontal dimension if horizontal_loop_* specified | ||
horiz_dim = find_horizontal_dimension(dims)[0] | ||
vert_dim = find_vertical_dimension(dims)[0] | ||
if horiz_dim and 'horizontal_loop' in horiz_dim: | ||
new_horiz_dim = 'ccpp_constant_one:horizontal_dimension' | ||
if vert_dim: | ||
dims = [new_horiz_dim, vert_dim] | ||
else: | ||
dims = [new_horiz_dim] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the only other possibility? No other dimensions allowed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A very good question. Updated the logic in ccpp_suite to replace the horizontal dimension where it is and not remove other dimensions! This logic is now gone though, as I discovered it was unnecessary (the logic in ccpp_suite to promote variables handles the dimensions) |
||
# end if | ||
# end if | ||
# end if | ||
for dim in dims: | ||
rdparts = list() | ||
dparts = dim.split(':') | ||
|
@@ -2500,7 +2513,7 @@ def write(self, outfile, host_arglist, indent, const_mod, | |
if dims: | ||
timestep_var = svar.get_prop_value('persistence') | ||
if group_type == timestep_var: | ||
alloc_str = self.allocate_dim_str(dims, svar.context) | ||
alloc_str = self.allocate_dim_str(dims, svar.context, suite_var=True) | ||
lname = svar.get_prop_value('local_name') | ||
outfile.write(alloc_stmt.format(lname, alloc_str), | ||
indent+1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a case for this? Is it tested (capgen test seems to run fine without it)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case would be a promoted variable with no horizontal dimension, but the existing dimension(s) do still need to be added to the calling list for the init routine.
That said, thanks to your other suggestion, I reworked the code so this "else" is no more. I also altered the capgen_test to ensure promotion/allocation works as expected for a variable with no horizontal dimension