Skip to content

Commit

Permalink
Bugfix for variables in multiple groups (#618)
Browse files Browse the repository at this point in the history
PR to address issue with variable intents *across* groups.

**Description**
- Current behavior for variables across groups: the intent for the first
group is used as the "truth".
- If variable "foo" is intent "out" in Group A and intent "in" in Group
B, "foo" will be added to the variable dictionary used by the host as
intent "out", which then the host assumes means that the framework will
handle it
- Updated behavior for variables across groups: adjust the intent of the
existing variable to "inout" if a conflict arises across groups (or
suites)

User interface changes?: No

Testing:
  test removed: N/A
unit tests: Updated capgen & ddt test - variable intents across suites
also affected; PASS
  system tests: all PASS
  manual testing: Ran in CAM-SIMA
  • Loading branch information
peverwhee authored Jan 6, 2025
1 parent 48443af commit fca3a9e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 1 addition & 3 deletions scripts/suite_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ def add_vars(self, call_list, run_env, gen_unique=False):
"""Add new variables from another CallList (<call_list>)"""
for var in call_list.variable_list():
stdname = var.get_prop_value('standard_name')
if stdname not in self:
self.add_variable(var, run_env, gen_unique=gen_unique)
# end if
self.add_variable(var, run_env, gen_unique=gen_unique, adjust_intent=True, exists_ok=True)
# end for

def add_variable(self, newvar, run_env, exists_ok=False, gen_unique=False,
Expand Down
2 changes: 1 addition & 1 deletion test/capgen_test/run_test
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ input_vars_ddt="${input_vars_ddt},horizontal_loop_end"
input_vars_ddt="${input_vars_ddt},model_times,number_of_model_times"
input_vars_ddt="${input_vars_ddt},surface_air_pressure"
output_vars_ddt="ccpp_error_code,ccpp_error_message"
output_vars_ddt="${output_vars_ddt},model_times,number_of_model_times"
output_vars_ddt="${output_vars_ddt},model_times,number_of_model_times,surface_air_pressure"
required_vars_temp="ccpp_error_code,ccpp_error_message"
required_vars_temp="${required_vars_temp},coefficients_for_interpolation"
required_vars_temp="${required_vars_temp},configuration_variable"
Expand Down
3 changes: 2 additions & 1 deletion test/capgen_test/test_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,11 @@ program test
'number_of_model_times ', &
'surface_air_pressure ' /)

character(len=cm), target :: test_outvars2(4) = (/ &
character(len=cm), target :: test_outvars2(5) = (/ &
'ccpp_error_code ', &
'ccpp_error_message ', &
'model_times ', &
'surface_air_pressure ', &
'number_of_model_times ' /)

character(len=cm), target :: test_reqvars2(5) = (/ &
Expand Down
2 changes: 1 addition & 1 deletion test/capgen_test/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def usage(errmsg=None):
"horizontal_loop_begin", "horizontal_loop_end",
"surface_air_pressure", "horizontal_dimension"]
_OUTPUT_VARS_DDT = ["ccpp_error_code", "ccpp_error_message", "model_times",
"number_of_model_times"]
"surface_air_pressure", "number_of_model_times"]
_REQUIRED_VARS_DDT = _INPUT_VARS_DDT + _OUTPUT_VARS_DDT
_PROT_VARS_TEMP = ["horizontal_loop_begin", "horizontal_loop_end",
"horizontal_dimension", "vertical_layer_dimension",
Expand Down
2 changes: 1 addition & 1 deletion test/ddthost_test/run_test
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ input_vars_ddt="${input_vars_ddt},horizontal_loop_end"
input_vars_ddt="${input_vars_ddt},model_times,number_of_model_times"
input_vars_ddt="${input_vars_ddt},surface_air_pressure"
output_vars_ddt="ccpp_error_code,ccpp_error_message"
output_vars_ddt="${output_vars_ddt},model_times,number_of_model_times"
output_vars_ddt="${output_vars_ddt},model_times,number_of_model_times,surface_air_pressure"
required_vars_temp="ccpp_error_code,ccpp_error_message"
required_vars_temp="${required_vars_temp},coefficients_for_interpolation"
required_vars_temp="${required_vars_temp},horizontal_dimension"
Expand Down
3 changes: 2 additions & 1 deletion test/ddthost_test/test_host.F90
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,11 @@ program test
'number_of_model_times ', &
'surface_air_pressure ' /)

character(len=cm), target :: test_outvars2(4) = (/ &
character(len=cm), target :: test_outvars2(5) = (/ &
'ccpp_error_code ', &
'ccpp_error_message ', &
'model_times ', &
'surface_air_pressure ', &
'number_of_model_times ' /)

character(len=cm), target :: test_reqvars2(5) = (/ &
Expand Down
2 changes: 1 addition & 1 deletion test/ddthost_test/test_reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"horizontal_loop_begin", "horizontal_loop_end",
"surface_air_pressure", "horizontal_dimension"]
_OUTPUT_VARS_DDT = ["ccpp_error_code", "ccpp_error_message", "model_times",
"number_of_model_times"]
"number_of_model_times", "surface_air_pressure"]
_REQUIRED_VARS_DDT = _INPUT_VARS_DDT + _OUTPUT_VARS_DDT
_PROT_VARS_TEMP = ["horizontal_loop_begin", "horizontal_loop_end",
"horizontal_dimension", "vertical_layer_dimension",
Expand Down

0 comments on commit fca3a9e

Please sign in to comment.