Skip to content
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

Capgen in SCM: Fix to allow for scheme subcycling. #633

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion scripts/ccpp_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ def write_var_set_loop(ofile, varlist_name, var_list, indent,
if add_allocate:
ofile.write(f"allocate({varlist_name}({len(var_list)}))", indent)
# end if
for ind, var in enumerate(sorted(var_list)):
for ind, var in enumerate(var_list):
if start_var:
ind_str = f"{start_var} + {ind + start_index}"
else:
Expand Down
13 changes: 6 additions & 7 deletions scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,12 +2004,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 @@ -2023,7 +2022,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
2 changes: 1 addition & 1 deletion test/var_compatibility_test/effr_calc.F90
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ subroutine effr_calc_run(ncol, nlev, effrr_in, effrg_in, ncg_in, nci_out, &
if (present(nci_out)) nci_out_local = nci_out
effrl_inout = min(max(effrl_inout,re_qc_min),re_qc_max)
if (present(effri_out)) effri_out = re_qi_avg
effrs_inout = effrs_inout + 10.0 ! in micrometer
effrs_inout = effrs_inout + 5.0 ! in micrometer
scalar_var = 2.0 ! in km

end subroutine effr_calc_run
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 @@ -3,7 +3,9 @@
<suite name="var_compatibility_suite" version="1.0">
<group name="radiation">
<scheme>effr_pre</scheme>
<scheme>effr_calc</scheme>
<subcycle loop="2">
<scheme>effr_calc</scheme>
</subcycle>
<scheme>effr_post</scheme>
<scheme>effr_diag</scheme>
</group>
Expand Down