diff --git a/scripts/suite_objects.py b/scripts/suite_objects.py index 639ee7d5..3e2ad6a3 100755 --- a/scripts/suite_objects.py +++ b/scripts/suite_objects.py @@ -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 @@ -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) @@ -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'): @@ -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): @@ -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) @@ -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 assoicated with the transform(s) # may have since changed. Here we need to use the standard_name # from 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 @@ -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 assoicated with the transform(s) # may have since changed. Here we need to use the standard_name # from 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) diff --git a/test/unit_tests/test_var_transforms.py b/test/unit_tests/test_var_transforms.py index 94a6c4a0..e595bc6f 100755 --- a/test/unit_tests/test_var_transforms.py +++ b/test/unit_tests/test_var_transforms.py @@ -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) @@ -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)