Fix for multiply occurring nml options in active_when attribute#1461
Open
abishekg7 wants to merge 1 commit into
Open
Fix for multiply occurring nml options in active_when attribute#1461abishekg7 wants to merge 1 commit into
active_when attribute#1461abishekg7 wants to merge 1 commit into
Conversation
mgduda
requested changes
May 28, 2026
mgduda
reviewed
May 28, 2026
mgduda
reviewed
May 28, 2026
mgduda
reviewed
May 28, 2026
mgduda
requested changes
May 29, 2026
Contributor
mgduda
left a comment
There was a problem hiding this comment.
I added just two minor comments, and otherwise, I think this is ready to go as an open PR after tidying up the commit history and adding a PR description.
This commit addresses the compiler errors that occur with the generated code when a namelist option appears more than once in an active_when attribute in a package definition in Registry.xml. e.g., config_foo > 0 .and. config_foo < 10. The solution involves modifying the logic in package_logic_routine and gen_pkg_debug_info in src/tools/registry/gen_inc.c to identify the unique namelist options in the active_when attributes. This commit introduces a simple helper function, add_unique_key_to_list, to add unique namelist options to a string list. This list is then iterated over by subsequent logic in order to ensure that there are no multiply defined variables in the generated Fortran code. Presently, the MAX_LIST_SIZE macro caps the maximum number of unique namelist options allowed in the active_when attribute at 20.
aa98712 to
3a8e802
Compare
Collaborator
Author
|
Addressed the last two comments and squashed to a single commit. I think the change set is small enough for one commit, but can also move the new function definition to its separate commit. |
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.
Problem
When declaring a package with the optional
active_whenattribute in Registry.xml, if a namelist option appeared more than once in anactive_whenattribute (e.g., config_foo > 0 .and. config_foo < 10), the code generation logic ingen_inc.cwould produce duplicate Fortran variable declarations andmpas_pool_get_configcalls in the generatedsetup_packages.inc. This caused compiler errors associated the generated code.Solution
The solution involves modifying the logic in
package_logic_routineandgen_pkg_debug_infoingen_inc.cto identify unique namelist options in theactive_whenattributes.This PR introduces a simple helper function,
add_unique_key_to_list, to add unique namelist options to a string list. This list is then iterated over by subsequent logic in order to ensure that there are no multiply defined variables in the generated Fortran code.Presently, the
MAX_LIST_SIZEmacro caps the maximum number of unique namelist options allowed in theactive_whenattribute at 20.