Reworked Configuration Namelist Access API#175
Conversation
…mentation refers to.
There was a problem hiding this comment.
I notice that across the board you assign namelist values to variables before using them. Can you confirm this is a choice you've made and that, as functions, they can be used in-line. e.g. call something(value, modeldb%config%my_namelist%other_value().
Yes this is a choice, the values can be accessed in-line. I have extracted them as the variables existed and shortens the actual code so it appears cleaner.
documentation/source/how_it_works/build_system/configurator.rst
Outdated
Show resolved
Hide resolved
documentation/source/how_to_use_it/configuration/using_configuration.rst
Outdated
Show resolved
Hide resolved
documentation/source/how_to_use_it/configuration/using_configuration.rst
Show resolved
Hide resolved
documentation/source/how_to_use_it/configuration/using_configuration.rst
Show resolved
Hide resolved
infrastructure/build/tools/configurator/templates/config_type.f90.jinja
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/templates/config_type.f90.jinja
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/templates/extended_namelist_type.f90.jinja
Show resolved
Hide resolved
Co-authored-by: Matthew Hambley <MatthewHambley@users.noreply.github.com>
Co-authored-by: Matthew Hambley <MatthewHambley@users.noreply.github.com>
…f90.jinja Co-authored-by: Matthew Hambley <MatthewHambley@users.noreply.github.com>
…f90.jinja Co-authored-by: Matthew Hambley <MatthewHambley@users.noreply.github.com>
Co-authored-by: Matthew Hambley <MatthewHambley@users.noreply.github.com>
MatthewHambley
left a comment
There was a problem hiding this comment.
Not too many changes, some of which may be postponed to later sets.
infrastructure/build/tools/configurator/tests/app_config/empty_mod.f90
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/tests/app_config/empty_mod.f90
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/tests/app_config/empty_mod.f90
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/tests/app_config/empty_mod.f90
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/tests/app_config/empty_mod.f90
Outdated
Show resolved
Hide resolved
MatthewHambley
left a comment
There was a problem hiding this comment.
There's still much to be done to tidy things up but this gets the basic functionality in place.
mike-hobson
left a comment
There was a problem hiding this comment.
From a code owner's point of view, this seems fine.
documentation/source/how_to_use_it/configuration/using_configuration.rst
Outdated
Show resolved
Hide resolved
documentation/source/how_to_use_it/configuration/using_configuration.rst
Outdated
Show resolved
Hide resolved
infrastructure/build/tools/configurator/tests/app_config/bar_nml_iterator_mod.f90
Outdated
Show resolved
Hide resolved
| :param duplicate: Is this namelist allowed multiple instances. | ||
| """ | ||
| self._namelists.append(name) | ||
| self._duplicates.append(duplicate) |
There was a problem hiding this comment.
I'd agree w/ @MatthewHambley, having synchronised lists to track whether namelist n allows duplicates seems a bit fragile. A list of objects might be more robust. And, the @dataclass decorator makes creating an object much easier. Something like:
@dataclass
class NamelistDetails:
name: str
duplicate: Optional[bool] = False
class AppConfiguration:
def __init__(self, module_name: str):
...
self._namelist_details: List[NamelistDetails] = []
...
def add_namelist(self, name: str, duplicate: bool) -> None:
...
self._namelist_details.append(NamelistDetails(name, duplicate))
...
But that would require a big chunk of rewriting, so perhaps create a new issue? (I'm willing to do the work).
There was a problem hiding this comment.
I agree it's not the best and is definitely fragile. Though in defence, most users will not be running this manually from the command line. The input is determined from the json file that is generated from rose_picker (or other application).
This PR is definitely an iteration to get the new api up and running, I've create issue #260 for this and assigned it to @allynt as requested
…ml_iterator_mod.f90 Co-authored-by: allynt <allyn.treshansky@gmail.com>
…ration.rst Co-authored-by: allynt <allyn.treshansky@gmail.com>
…ration.rst Co-authored-by: allynt <allyn.treshansky@gmail.com>
PR Summary
Sci/Tech Reviewer: @allynt
Code Reviewer: @MatthewHambley
This PR is to allow users more direct access to the namelist configuration values from
Fortran object (rather than global module scope) while maintaining it's read-only nature.
e.g.
modeldb%config%<MyNamelist>%MyNamelistMember()This PR is linked to LFRic-core trac ticket #4702, which provides more details on the change itself
Code Quality Checklist
(Some checks are automatically carried out via the CI pipeline)
style guidelines
readability of the code
Testing
using this branch
acceptable (eg. kgo changes)
tests, unit tests, etc.)
and have been allocated to an appropriate testing group (i.e. the
developer tests are for jobs which use a small amount of compute resource
and complete in a matter of minutes)
trac.log
Security Considerations
Performance Impact
performance measurements have been conducted
AI Assistance and Attribution
of Generative AI tool name (e.g., Met Office Github Copilot Enterprise,
Github Copilot Personal, ChatGPT GPT-4, etc) and I have followed the
Simulation Systems AI policy
(including attribution labels)
Documentation
confirmed that it builds correctly
PSyclone Approval
interface, optimisation scripts, LFRic data structure code) then please
contact the
tooscollabdevteam@metoffice.gov.uk
Sci/Tech Review
Please alert the code reviewer via a tag when you have approved the SR
Code Review