Skip to content

Commit

Permalink
Some housekeeping.
Browse files Browse the repository at this point in the history
  • Loading branch information
dustinswales committed Oct 28, 2024
1 parent 4d24e9f commit 93403c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
24 changes: 9 additions & 15 deletions scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def call_string(self, cldicts=None, is_func_call=False, subname=None, sub_lname_
# If so, change Var's local_name need to local dummy array containing
# transformed argument, var_trans_local.
if sub_lname_list:
for (sname, var_trans_local) in sub_lname_list:
for (var_trans_local, var_lname, sname, rindices, lindices, compat_obj, __) in sub_lname_list:
if (sname == stdname):
lname = var_trans_local
# end if
Expand Down Expand Up @@ -1115,8 +1115,6 @@ def __init__(self, scheme_xml, context, parent, run_env):
self.__var_debug_checks = list()
self.__forward_transforms = list()
self.__reverse_transforms = list()
self.__forward_sub_lname_list = list()
self.__reverse_sub_lname_list = list()
self._has_run_phase = True
self.__optional_vars = list()
super().__init__(name, context, parent, run_env, active_call_list=True)
Expand Down Expand Up @@ -1675,10 +1673,9 @@ def add_var_transform(self, var, compat_obj, vert_dim):
compat_obj.v1_stdname))
self.__reverse_transforms.append([local_trans_var.get_prop_value('local_name'),
var.get_prop_value('local_name'),
var.get_prop_value('standard_name'),
rindices, lindices, compat_obj,
var.get_prop_value('standard_name')])
self.__reverse_sub_lname_list.append([var.get_prop_value('standard_name'),
local_trans_var.get_prop_value('local_name')])
# end if
# Register any forward (post-Scheme) transforms.
if (var.get_prop_value('intent') != 'in'):
Expand All @@ -1688,10 +1685,9 @@ def add_var_transform(self, var, compat_obj, vert_dim):
compat_obj.v1_stdname,
compat_obj.v2_stdname))
self.__forward_transforms.append([var.get_prop_value('local_name'),
var.get_prop_value('standard_name'),
local_trans_var.get_prop_value('local_name'),
lindices, rindices, compat_obj])
self.__forward_sub_lname_list.append([var.get_prop_value('standard_name'),
local_trans_var.get_prop_value('local_name')])
# end if
def write_var_transform(self, var, dummy, rindices, lindices, compat_obj,
outfile, indent, forward):
Expand Down Expand Up @@ -1735,7 +1731,7 @@ def write(self, outfile, errcode, errmsg, indent):
my_args = self.call_list.call_string(cldicts=cldicts,
is_func_call=True,
subname=self.subroutine_name,
sub_lname_list = self.__reverse_sub_lname_list)
sub_lname_list = self.__reverse_transforms)
#
outfile.write('', indent)
outfile.write('if ({} == 0) then'.format(errcode), indent)
Expand Down Expand Up @@ -1763,14 +1759,13 @@ def write(self, outfile, errcode, errmsg, indent):
if len(self.__reverse_transforms) > 0:
outfile.comment('Compute reverse (pre-scheme) transforms', indent+1)
# end if
for rcnt, (dummy, var, rindices, lindices, compat_obj, __) in enumerate(self.__reverse_transforms):
for rcnt, (dummy, var_lname, var_sname, rindices, lindices, compat_obj, __) in enumerate(self.__reverse_transforms):
# Any transform(s) were added during the Group's analyze phase, but
# the local_name(s) of the <var> assoicated with the transform(s)
# may have since changed. Here we need to use the standard_name
# from <var> and replace its local_name with the local_name from the
# Group's call_list.
lname = self.__reverse_sub_lname_list[rcnt][0]
lvar = self.__group.call_list.find_variable(standard_name=lname)
lvar = self.__group.call_list.find_variable(standard_name=var_sname)
lvar_lname = lvar.get_prop_value('local_name')
tstmt = self.write_var_transform(lvar_lname, dummy, rindices, lindices, compat_obj, outfile, indent+1, False)
# end for
Expand Down Expand Up @@ -1812,16 +1807,15 @@ def write(self, outfile, errcode, errmsg, indent):
if len(self.__forward_transforms) > 0:
outfile.comment('Compute forward (post-scheme) transforms', indent+1)
# end if
for fcnt, (var, dummy, lindices, rindices, compat_obj) in enumerate(self.__forward_transforms):
for fcnt, (var_lname, var_sname, dummy, lindices, rindices, compat_obj) in enumerate(self.__forward_transforms):
# Any transform(s) were added during the Group's analyze phase, but
# the local_name(s) of the <var> assoicated with the transform(s)
# may have since changed. Here we need to use the standard_name
# from <var> and replace its local_name with the local_name from the
# Group's call_list.
lname = self.__forward_sub_lname_list[fcnt][0]
lvar = self.__group.call_list.find_variable(standard_name=lname)
lvar = self.__group.call_list.find_variable(standard_name=var_sname)
lvar_lname = lvar.get_prop_value('local_name')
tstmt = self.write_var_transform(var, dummy, rindices, lindices, compat_obj, outfile, indent+1, True)
tstmt = self.write_var_transform(lvar_lname, dummy, rindices, lindices, compat_obj, outfile, indent+1, True)
# end for
outfile.write('', indent)
outfile.write('end if', indent)
Expand Down
4 changes: 2 additions & 2 deletions test/unit_tests/test_var_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_valid_unit_change(self):
compat = real_scalar1.compatible(real_scalar2, self.__run_env)
self.assertIsInstance(compat, VarCompatObj,
msg=self.__inst_emsg.format(type(compat)))
self.assertFalse(compat)
self.assertTrue(compat)
self.assertTrue(compat.compat)
self.assertEqual(compat.incompat_reason, '')
self.assertFalse(compat.has_kind_transforms)
Expand All @@ -150,7 +150,7 @@ def test_valid_unit_change(self):
compat = real_scalar1.compatible(real_scalar2, self.__run_env)
self.assertIsInstance(compat, VarCompatObj,
msg=self.__inst_emsg.format(type(compat)))
self.assertFalse(compat)
self.assertTrue(compat)
self.assertTrue(compat.compat)
self.assertEqual(compat.incompat_reason, '')
self.assertFalse(compat.has_kind_transforms)
Expand Down

0 comments on commit 93403c2

Please sign in to comment.