Skip to content

Commit

Permalink
Fix subcycling and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Jan 29, 2025
1 parent 67bfa95 commit 421e026
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion scripts/ccpp_datafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ def _add_suite_object(parent, suite_object):
obj_elem.set("dimension_name", suite_object.dimension_name)
# end if
if isinstance(suite_object, Subcycle):
obj_elem.set("loop", suite_object.loop)
obj_elem.set("loop", suite_object._loop)
# end if
for obj_part in suite_object.parts:
_add_suite_object(obj_elem, obj_part)
Expand Down
13 changes: 6 additions & 7 deletions scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2006,12 +2006,11 @@ def analyze(self, phase, group, scheme_library, suite_vars, level):
if self.name is None:
self.name = "subcycle_index{}".format(level)
# end if
# Create a variable for the loop index
self.add_variable(Var({'local_name':self.name,
'standard_name':'loop_variable',
'type':'integer', 'units':'count',
'dimensions':'()'}, _API_SOURCE, self.run_env),
self.run_env)
# Create a Group variable for the subcycle index.
newvar = Var({'local_name':self.name, 'standard_name':self.name,
'type':'integer', 'units':'count', 'dimensions':'()'},
_API_LOCAL, self.run_env)
group.manage_variable(newvar)
# Handle all the suite objects inside of this subcycle
scheme_mods = set()
for item in self.parts:
Expand All @@ -2025,7 +2024,7 @@ def analyze(self, phase, group, scheme_library, suite_vars, level):

def write(self, outfile, errcode, errmsg, indent):
"""Write code for the subcycle loop, including contents, to <outfile>"""
outfile.write('do {} = 1, {}'.format(self.name, self.loop), indent)
outfile.write('do {} = 1, {}'.format(self.name, self._loop), indent)
# Note that 'scheme' may be a sybcycle or other construct
for item in self.parts:
item.write(outfile, errcode, errmsg, indent+1)
Expand Down
4 changes: 3 additions & 1 deletion test/var_compatibility_test/var_compatibility_suite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<scheme>effr_pre</scheme>
<scheme>effr_calc</scheme>
<scheme>effr_post</scheme>
<scheme>effr_diag</scheme>
<subcycle loop="1">
<scheme>effr_diag</scheme>
</subcycle>
</group>
</suite>

0 comments on commit 421e026

Please sign in to comment.