Skip to content

Commit

Permalink
address review comments; code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
peverwhee committed Oct 29, 2024
1 parent 37cbdf8 commit ca146bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
15 changes: 6 additions & 9 deletions scripts/host_cap.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def suite_part_call_list(host_model, const_dict, suite_part, subst_loop_vars,
sp_lname = sp_var.get_prop_value('local_name')
if sp_var.get_prop_value('type') == 'ccpp_constituent_properties_t':
if dyn_const:
hmvars.append("{}={}".format(sp_lname, sp_lname))
hmvars.append(f"{sp_lname}={sp_lname}")
# end if
continue
# end if
Expand Down Expand Up @@ -578,8 +578,8 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env):
has_dyn_consts = True
continue
else:
errmsg = 'ccpp_constituent_properties_t object "{}" not allowed in "{}" phase'
raise CCPPError(errmsg.format(stdname, spart.phase()))
errmsg = f'ccpp_constituent_properties_t object "{stdname}" not allowed in "{spart.phase()}" phase'
raise CCPPError(errmsg)
# end if
# end if
hvar = const_dict.find_variable(standard_name=stdname,
Expand Down Expand Up @@ -700,8 +700,8 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env):
size_string = "0+"
for var in host_local_vars.variable_list():
vtype = var.get_prop_value('type')
local_name = var.get_prop_value('local_name')
if vtype == 'ccpp_constituent_properties_t':
local_name = var.get_prop_value('local_name')
size_string += f"size({local_name})+"
# end if
# end for
Expand All @@ -714,10 +714,10 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env):
cap.write("num_dyn_consts = 0", 3)
for var in host_local_vars.variable_list():
vtype = var.get_prop_value('type')
local_name = var.get_prop_value('local_name')
if vtype != 'ccpp_constituent_properties_t':
continue
# end if
local_name = var.get_prop_value('local_name')
cap.write(f"do const_index = 1, size({local_name})", 3)
cap.write(f"{dyn_const_array}(num_dyn_consts + const_index) = {local_name}(const_index)", 4)
cap.write("end do", 3)
Expand Down Expand Up @@ -752,10 +752,7 @@ def write_host_cap(host_model, api, module_name, output_dir, run_env):
cap.write("", 0)
const_names_name = constituent_model_const_stdnames(host_model)
const_indices_name = constituent_model_const_indices(host_model)
dyn_const_names = list()
for suite in api.suites:
dyn_const_names.append(suite_dynamic_constituent_array_name(host_model, suite.name))
# end for
dyn_const_names = [suite_dynamic_constituent_array_name(host_model, suite.name) for suite in api.suites]
ConstituentVarDict.write_host_routines(cap, host_model, reg_name, init_name,
numconsts_name, queryconsts_name,
copyin_name, copyout_name,
Expand Down
6 changes: 1 addition & 5 deletions scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,6 @@ def add_call_list_variable(self, newvar, exists_ok=False,
newvar = oldvar.clone(subst_dict, source_name=self.name,
source_type=stype, context=self.context)
# end if
stdname = newvar.get_prop_value('standard_name')
vtype = newvar.get_prop_value('type')
dimensions = newvar.get_prop_value('dimensions')
self.call_list.add_variable(newvar, self.run_env,
exists_ok=exists_ok,
gen_unique=gen_unique,
Expand All @@ -458,8 +455,7 @@ def add_call_list_variable(self, newvar, exists_ok=False,
continue
elif vardim == '':
emsg = f"{self.name}: Cannot have unnamed/empty string dimension"
raise ParseInternalError(emsg.format(self.name,
vardim, stdname))
raise ParseInternalError(emsg)
# end if
dvar = self.find_variable(standard_name=vardim,
any_scope=True)
Expand Down

0 comments on commit ca146bd

Please sign in to comment.