Fix for multiply occurring nml options in active_when attribute#1461
Fix for multiply occurring nml options in active_when attribute#1461abishekg7 wants to merge 1 commit into
active_when attribute#1461Conversation
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.
aa98712 to
3a8e802
Compare
|
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. |
|
@abishekg7 Could you rebase this PR branch off of the |
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.
3a8e802 to
563a7a2
Compare
Rebased and force pushed. |
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.