Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug switch to capgen (perform variable allocation checks etc) + fix spelling: var_compatability --> var_compatibility #512

Merged
merged 25 commits into from
Jan 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7682ec1
Add capability to parse Fortran pointer variables to fortran_tools/pa…
climbfuji Nov 8, 2023
a660e2f
Add --debug option to capgen (framework_env.py)
climbfuji Nov 8, 2023
a67b0bc
Add pointer attribute to Var class, add code to convert active attrib…
climbfuji Nov 8, 2023
e532774
Add debug checks for variables (scalars, arrays) before and after sch…
climbfuji Nov 8, 2023
ddae076
Fix typo in var_props.py
climbfuji Nov 8, 2023
29ee9ae
For advection tests, add --debug flag to capgen and update test reports
climbfuji Nov 8, 2023
de0891f
Add active attribute to variable water_vapor_specific_humidity in cap…
climbfuji Nov 8, 2023
b1b215d
For var_action tests, add --debug flag to capgen and update test reports
climbfuji Nov 8, 2023
adeef17
Clean up based on self-review
climbfuji Nov 8, 2023
7256311
Add scripts/parse_tools/fortran_conditional.py
climbfuji Nov 22, 2023
af16935
Cleanup: replace var_dicts with cldicts in write_debug_checks in suit…
climbfuji Nov 22, 2023
edb1bd5
Update comment on ddt_type property in metavar.py
climbfuji Nov 22, 2023
13b6363
Add doctests for conditional function of Var class
climbfuji Nov 22, 2023
fddde47
Add docstring documentation for add_var_debug_check and write_var_deb…
climbfuji Nov 28, 2023
8834299
Merge branch 'feature/capgen' of https://github.com/ncar/ccpp-framewo…
climbfuji Nov 29, 2023
b4f108b
Simplify logic for variable debug checks in suite_objects.py
climbfuji Nov 29, 2023
2e72cc8
Update variable lists for var_action_test
climbfuji Nov 29, 2023
3a4c056
Update scripts/framework_env.py
climbfuji Dec 11, 2023
464f62a
Fix wrong comment about group variables in scripts/suite_objects.py
climbfuji Dec 11, 2023
dfa59eb
In scripts/suite_objects.py: rename 'dummy' variables for var_debug_c…
climbfuji Dec 11, 2023
7367f98
Bug fix in scripts/suite_objects.py: also check variable allocations …
climbfuji Dec 15, 2023
fc6fec3
Remove stray debugging statement in scripts/suite_objects.py
climbfuji Dec 15, 2023
94b2755
Merge branch 'feature/capgen' of https://github.com/ncar/ccpp-framewo…
climbfuji Jan 18, 2024
70ae2b0
Fix spelling: compatability --> compatibility
climbfuji Jan 18, 2024
63aee18
Add missing instruction in test_prebuild/test_blocked_data/README.md
climbfuji Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions scripts/suite_objects.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1149,9 +1149,8 @@ def analyze(self, phase, group, scheme_library, suite_vars, level):
found, dict_var, vert_dim, new_dims, missing_vert = args
if found:
if self.__group.run_env.debug:
# Add variable allocation checks for suite and host model variables only
gvar = self.__group.find_variable(standard_name=vstdname, any_scope=False)
if dict_var and not gvar:
# Add variable allocation checks for group, suite and host variables
if dict_var:
self.add_var_debug_check(dict_var)
# end if
if not self.has_vertical_dim:
Expand Down Expand Up @@ -1302,12 +1301,13 @@ def add_var_debug_check(self, var):
def replace_horiz_dim_debug_check(self, dim, cldicts, var_in_call_list):
climbfuji marked this conversation as resolved.
Show resolved Hide resolved
"""Determine the correct horizontal dimension to use for a given variable,
depending on the CCPP phase and origin of the variable (from the host/suite
or defined as a module variable for the parent group. Return the dimension
length and other properties needed for the variable debug checks."""
or defined as a module variable for the parent group, or local to the group.
Return the dimension length and other properties needed for debug checks."""
if not is_horizontal_dimension(dim):
raise Exception(f"Dimension {dim} is not a horizontal dimension")
if self.run_phase():
if self.find_variable(standard_name="horizontal_loop_extent"):
if var_in_call_list and \
self.find_variable(standard_name="horizontal_loop_extent"):
ldim = "ccpp_constant_one"
udim = "horizontal_loop_extent"
else:
Expand Down Expand Up @@ -1359,17 +1359,27 @@ def write_var_debug_check(self, var, internal_var, cldicts, outfile, errcode, er
active = var.get_prop_value('active')
allocatable = var.get_prop_value('allocatable')

# Need the local name as it comes from the group call list
# or from the suite, not how it is called in the scheme (var)
# Need the local name from the group call list,
# from the locally-defined variables of the group,
# or from the suite, not how it is called in the scheme (var)
# First, check if the variable is in the call list.
dvar = self.__group.call_list.find_variable(standard_name=standard_name, any_scope=False)
if dvar:
var_in_call_list = True
else:
var_in_call_list = False
for var_dict in self.__group.suite_dicts():
dvar = var_dict.find_variable(standard_name=standard_name)
if dvar:
break
# If it is not in the call list, try to find it
# in the local variables of this group subroutine.
dvar = self.__group.find_variable(standard_name=standard_name, any_scope=False)
if dvar:
print(f"DOM DEBUG - found the variable in the LOCAL GROUP!")
dustinswales marked this conversation as resolved.
Show resolved Hide resolved
else:
# This variable is handled by the group
# and is declared as a module variable
for var_dict in self.__group.suite_dicts():
dvar = var_dict.find_variable(standard_name=standard_name, any_scope=False)
if dvar:
break
if not dvar:
raise Exception(f"No variable with standard name '{standard_name}' in cldicts")
local_name = dvar.get_prop_value('local_name')
Expand All @@ -1379,7 +1389,7 @@ def write_var_debug_check(self, var, internal_var, cldicts, outfile, errcode, er
# the variable. We don't have this information earlier in
# add_var_debug_check, therefore need to back out here,
# using the information from the scheme variable (call list).
svar = self.call_list.find_variable(standard_name=standard_name)
svar = self.call_list.find_variable(standard_name=standard_name, any_scope=False)
intent = svar.get_prop_value('intent')
if intent == 'out' and allocatable:
return
Expand Down