Skip to content

Commit

Permalink
bugfix for scalar variable transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Courtney Peverley committed Mar 3, 2024
1 parent 32daa88 commit 2a78b71
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
21 changes: 18 additions & 3 deletions scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,16 @@ def add_var_transform(self, var, compat_obj, vert_dim):

# If needed, modify vertical dimension for vertical orientation flipping
_, vdim = find_vertical_dimension(var.get_dimensions())
if vdim >= 0:
vdim_name = vert_dim.split(':')[-1]
group_vvar = self.__group.call_list.find_variable(vdim_name)
vname = group_vvar.get_prop_value('local_name')
lindices[vdim] = '1:'+vname
rindices[vdim] = '1:'+vname
if compat_obj.has_vert_transforms:
rindices[vdim] = vname+':1:-1'
# end if
# end if
vdim_name = vert_dim.split(':')[-1]
group_vvar = self.__group.call_list.find_variable(vdim_name)
vname = group_vvar.get_prop_value('local_name')
Expand Down Expand Up @@ -1614,20 +1624,25 @@ def write(self, outfile, errcode, errmsg, indent):
for (var, internal_var) in self.__var_debug_checks:
stmt = self.write_var_debug_check(var, internal_var, cldicts, outfile, errcode, errmsg, indent+1)
# Write any reverse (pre-Scheme) transforms.
outfile.write('! Compute reverse (pre-scheme) transforms', indent+1)
if len(self.__reverse_transforms) > 0:
outfile.write('! Compute reverse (pre-scheme) transforms', indent+1)
# end if
for (dummy, var, rindices, lindices, compat_obj) in self.__reverse_transforms:
tstmt = self.write_var_transform(var, dummy, rindices, lindices, compat_obj, outfile, indent+1, False)
# end for
# Write the scheme call.
stmt = 'call {}({})'
outfile.write('',indent+1)
outfile.write('! Call scheme', indent+1)
outfile.write(stmt.format(self.subroutine_name, my_args), indent+1)
# Write any forward (post-Scheme) transforms.
outfile.write('',indent+1)
outfile.write('! Compute forward (post-scheme) transforms', indent+1)
if len(self.__forward_transforms) > 0:
outfile.write('! Compute forward (post-scheme) transforms', indent+1)
# end if
for (var, dummy, lindices, rindices, compat_obj) in self.__forward_transforms:
tstmt = self.write_var_transform(var, dummy, rindices, lindices, compat_obj, outfile, indent+1, True)
#
# end for
outfile.write('', indent)
outfile.write('end if', indent)

Expand Down
18 changes: 14 additions & 4 deletions scripts/var_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,13 @@ def forward_transform(self, lvar_lname, rvar_lname, rvar_indices, lvar_indices,
"vertical_interface_dimension").
"""
# Dimension transform (Indices handled externally)
rhs_term = f"{rvar_lname}({','.join(rvar_indices)})"
lhs_term = f"{lvar_lname}({','.join(lvar_indices)})"
if len(rvar_indices) == 0:
rhs_term = f"{rvar_lname}"
lhs_term = f"{lvar_lname}"
else:
rhs_term = f"{rvar_lname}({','.join(rvar_indices)})"
lhs_term = f"{lvar_lname}({','.join(lvar_indices)})"
# end if

if self.has_kind_transforms:
kind = self.__kind_transforms[1]
Expand Down Expand Up @@ -1016,8 +1021,13 @@ def reverse_transform(self, lvar_lname, rvar_lname, rvar_indices, lvar_indices,
"vertical_interface_dimension").
"""
# Dimension transforms (Indices handled externally)
lhs_term = f"{lvar_lname}({','.join(lvar_indices)})"
rhs_term = f"{rvar_lname}({','.join(rvar_indices)})"
if len(rvar_indices) == 0:
rhs_term = f"{rvar_lname}"
lhs_term = f"{lvar_lname}"
else:
lhs_term = f"{lvar_lname}({','.join(lvar_indices)})"
rhs_term = f"{rvar_lname}({','.join(rvar_indices)})"
# end if

if self.has_kind_transforms:
kind = self.__kind_transforms[0]
Expand Down

0 comments on commit 2a78b71

Please sign in to comment.