Fix capgen Fortran parser to recognize nested subroutines/functions#424
Merged
climbfuji merged 4 commits intoNCAR:feature/capgenfrom Jan 4, 2022
Merged
Conversation
Collaborator
|
I'm not sure I believe your assertion that the |
…ntains Do not require label on end subroutine statement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #359 (#359).
The
capgenFortran parser is updated to know whether it is inside acontainssection of a CCPP scheme. If so, the contents is ignored until anend subroutine scheme_name_ccpp_phase(e.g.end subroutine mp_thompson_run) is found.Note that this fix requires that
end subroutinestatements are labeled with the subroutine name, i.e.subroutine mp_thompson_runrequires the end statement to beend subroutine mp_thompson_runand not justend_subroutine). This has been a soft requirement forccpp_prebuild.py, which warns users that an unlabeledend subroutinestatement was found, but in must cases was able to proceed.A more complicated solution that does not require labeled
end subroutinestatements would require counting the number of[begin] subroutineandend subroutinestatements insidecontainsregions.User interface changes?: No (since labeled
end subroutinestatements have been a soft requirement forccpp_prebuild.pyfrom the beginning)Fixes #359.
Testing: The existing test of scheme
temp_calc_adjustwas extended to include acontainssection intemp_calc_adjust_run. Without the changes toscripts/fortran_tools/parse_fortran_file.pyin this PR, thecapgentest for this scheme failed. After making the changes suggested here, all tests pass (cd tests && ./run_test.sh).