Skip to content

Commit

Permalink
Work in progress, no intents
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Goldhaber committed Jun 18, 2023
1 parent 51bb9a2 commit bcd40e0
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
9 changes: 8 additions & 1 deletion scripts/metavar.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,14 +391,21 @@ def compatible(self, other, run_env):

def adjust_intent(self, src_var):
"""Add an intent to this Var or adjust its existing intent.
<src_var> can be a Var object or an intent string
Note: An existing intent can only be adjusted to 'inout'
"""
if 'intent' in self._prop_dict:
my_intent = self.get_prop_value('intent')
else:
my_intent = None
# end if
sv_intent = src_var.get_prop_value('intent')
if isinstance(src_var, Var):
sv_intent = src_var.get_prop_value('intent')
elif isinstance(src_var, str):
sv_intent = src_var
else:
raise ParseInternalError(f"Bad src_var type, {type(src_var)}")
# end if
if not sv_intent:
sv_intent = 'in'
# end if
Expand Down
50 changes: 49 additions & 1 deletion scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def add_variable(self, newvar, run_env, exists_ok=False, gen_unique=False,
if newvar.get_prop_value("intent") is None:
subst_dict = {'intent' : 'in'}
oldvar = newvar
# XXgoldyXX: v debug only
if (oldvar.get_prop_value('standard_name') == "cloud_liquid_dry_mixing_ratio"):
raise ParseInternalError(f"XXG1: {oldvar.get_prop_value('standard_name')}")
# XXgoldyXX: ^ debug only
newvar = oldvar.clone(subst_dict, source_name=self.name,
source_type=_API_GROUP_VAR_NAME,
context=oldvar.context)
Expand Down Expand Up @@ -433,7 +437,7 @@ def add_call_list_variable(self, newvar, exists_ok=False,
# Make sure that this variable has an intent
if ((oldvar.get_prop_value("intent") is None) and
("intent" not in subst_dict)):
subst_dict["intent"] = "in"
subst_dict["intent"] = 'in'
# end if
newvar = oldvar.clone(subst_dict, source_name=self.name,
source_type=stype, context=self.context)
Expand Down Expand Up @@ -1735,6 +1739,50 @@ def find_variable(self, standard_name=None, source_var=None,
if fvar.source.ptype == ConstituentVarDict.constitutent_source_type():
# We found this variable in the constituent dictionary,
# add it to our call list
# First, add the correct intent
intent_in = ""
intent_out = ""
if standard_name == None:
standard_name = fvar.get_prop_value('standard_name')
# end if
# Loop all the schemes and find this variable's intent (if any)
# XXgoldyXX: v debug only
print(f"XXGg: {standard_name}: {self.phase_type}")
# XXgoldyXX: ^ debug only
for scheme in self.schemes():
# XXgoldyXX: v debug only
print(f"XXGs: {scheme.name}")
# XXgoldyXX: ^ debug only
for svar in scheme.variable_list():
if svar.get_prop_value('standard_name') == standard_name:
sintent = svar.get_prop_value('intent')
if sintent == 'in':
intent_in = 'in'
elif sintent == 'out':
intent_out = 'out'
elif sintent == 'inout':
intent_in = 'in'
intent_out = 'out'
else:
emsg = f"Bad intent ({sintent}) for {standard_name}"
raise ParseInternalError(emsg)
# end if
break
# XXgoldyXX: v debug only
else:
print(f"XXGsn: {svar.get_prop_value('standard_name')}")
# XXgoldyXX: ^ debug only
# end if
# end for
if intent_out and (not intent_in):
# If intent(out) comes first, that is sticky
break
# end if
# end for
fvar.adjust_intent(f"{intent_in}{intent_out}")
# XXgoldyXX: v debug only
print(f"XXG: '{intent_in}{intent_out}', {fvar.get_prop_value('intent')}")
# XXgoldyXX: ^ debug only
self.add_call_list_variable(fvar, exists_ok=True)
# end if
# end if
Expand Down
2 changes: 1 addition & 1 deletion test/advection_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(test_host)
ENABLE_LANGUAGE(Fortran)

Expand Down

0 comments on commit bcd40e0

Please sign in to comment.