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

Conversation

climbfuji
Copy link
Collaborator

@climbfuji climbfuji commented Nov 8, 2023

Update 2024/01/18: when pulling in feature/capgen, I noticed a spelling mistake that I corrected in commit 70ae2b0: var_compatability --> var_compatibility. I reran all the tests after pulling in feature/capgen and correcting the spelling, and they all passed.

This PR adds a --debug switch to capgen which enables checking of variables.

This feature is necessary for the transition from ccpp_prebuild.py to capgen.py. The following checks are performed:

  1. If if the variable is not active (based on its active attribute), skip it
  2. Variables that are allocatable or are pointers (scalars, arrays) and that have intent out for a scheme are skipped
  3. For scalars that have intent in or inout, assign the current value to a dummy variable
  4. For arrays, first check the size of the array against what's expected from the metadata, then assign the lower and upper bounds to a dummy (scalar) variable

User interface changes?: Yes
capgen now accepts an additional (but optional) argument --debug

This PR resolves #325. After adding the unit tests (see above), also #433

Testing:
test removed: none
unit tests: ran all unit tests in test/unit_tests
system tests:
- ran all Fortran tests in test/{advection_test,capgen_test,var_action_test}/ (note that the latter fail due to the missing unit conversions, but the new variable debug checks work as expected)
- ran doctests in scripts on all files modified
- ran hashtable tests in test/hashtable
manual testing: n/a

Copy link
Collaborator Author

@climbfuji climbfuji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review

scripts/fortran_tools/parse_fortran.py Outdated Show resolved Hide resolved
scripts/metavar.py Outdated Show resolved Hide resolved
scripts/metavar.py Outdated Show resolved Hide resolved
scripts/metavar.py Show resolved Hide resolved
scripts/suite_objects.py Show resolved Hide resolved
scripts/suite_objects.py Outdated Show resolved Hide resolved
scripts/suite_objects.py Show resolved Hide resolved
scripts/suite_objects.py Outdated Show resolved Hide resolved
scripts/suite_objects.py Outdated Show resolved Hide resolved
@climbfuji climbfuji mentioned this pull request Nov 9, 2023
scripts/metavar.py Outdated Show resolved Hide resolved
scripts/suite_objects.py Outdated Show resolved Hide resolved
scripts/suite_objects.py Outdated Show resolved Hide resolved
@climbfuji climbfuji force-pushed the feature/capgen_debug_checks branch from c2db64d to 681bc4f Compare November 22, 2023 16:49
…e_objects.py; remove pointer attribute in metavar.py and fortran_tools/parse_fortran.py; import Fortran conditional regex statements from parse_tools
@climbfuji climbfuji force-pushed the feature/capgen_debug_checks branch from 681bc4f to af16935 Compare November 22, 2023 17:14
@climbfuji climbfuji changed the title Add debug switch to capgen (perform variable allocation checks etc) - OPEN FOR DISCUSSION Add debug switch to capgen (perform variable allocation checks etc) Nov 29, 2023
@climbfuji
Copy link
Collaborator Author

@dustinswales @peverwhee @gold2718 I cleaned this up as discussed, it's now ready for review. I merged feature/capgen in cleanly after the constituents PR was merged and reran all the tests.

@climbfuji climbfuji marked this pull request as ready for review November 29, 2023 23:42
@climbfuji climbfuji requested a review from mkavulich as a code owner November 29, 2023 23:42
Copy link
Collaborator

@dustinswales dustinswales left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@climbfuji Looks good. Great job!

dustinswales pushed a commit to dustinswales/ccpp-framework that referenced this pull request Dec 4, 2023
…be consistent with how the DEBUG checking is implemented in PR NCAR#512
Copy link
Collaborator

@peverwhee peverwhee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple small comments, but nothing worthy of holding up the PR

scripts/metavar.py Show resolved Hide resolved
scripts/suite_objects.py Outdated Show resolved Hide resolved
Formatting

Co-authored-by: mwaxmonsky <137746677+mwaxmonsky@users.noreply.github.com>
…heck to 'internal_var' variables, and avoid promoting these variables to the module (suite) level
…for variables local to the group and assign correct dimensions for local (group) and module (suite) variables
@climbfuji
Copy link
Collaborator Author

@dustinswales @peverwhee @gold2718 After much debugging (or rather staring at the code and weeding through layers and layers of find_variable, I finally understand what was wrong with my code. I just pushed 7367f98 which makes two important updates:

  • Fix the logic for finding variables that are local to the group in write_var_debug_checks. This allows us to enable allocation checks for locally-defined variables, part of this commit.
  • Fix the logic to determine the horizontal dimensions. As it turns out, variables that are defined as module variables (i.e. managed by the suite) or that are defined locally (managed by the group) in the run phase always run from horizontal_loop_begin to horizontal_loop_end (and in all other phases from 1 to horizontal_dimension).

I added inline comments that explain the above in commit 7367f98. All doctstring tests and all capgen tests pass.

scripts/suite_objects.py Outdated Show resolved Hide resolved
@climbfuji climbfuji linked an issue Dec 28, 2023 that may be closed by this pull request
@climbfuji
Copy link
Collaborator Author

Pinging all remaining reviewers. This PR has sufficient approvals and we are planning to merge this PR on Wednesday, January 17 2024.

@climbfuji
Copy link
Collaborator Author

I am going to pull in feature/capgen today, resolve the conflicts, rerun all the tests and then merge unless someone requests changes today.

@climbfuji climbfuji changed the title Add debug switch to capgen (perform variable allocation checks etc) Add debug switch to capgen (perform variable allocation checks etc) + fix spelling: var_compatability --> var_compatibility Jan 18, 2024
@climbfuji
Copy link
Collaborator Author

@dustinswales Can you please re-review the changes that I made to fix the spelling compatability --> compatibility after I pulled in feature/capgen? Commit 70ae2b0. If you could let me know then I will do a squashed merge with a proper commit message. Thanks!

@climbfuji climbfuji merged commit a4e174f into NCAR:feature/capgen Jan 19, 2024
10 checks passed
@climbfuji climbfuji deleted the feature/capgen_debug_checks branch January 19, 2024 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add debug switch to capgen (30 hours)
4 participants