Update LFRic Apps as impacted by removal of module scope configuration variables in LFRic Core driver.#418
Conversation
iboutle
left a comment
There was a problem hiding this comment.
I'm not keen on the way the API for the getter functions has been misused/broken as part of this change. I'll pick get_height_fv to illustrate what I mean, but the same applies to all of the other getter functions for runtime constants.
Currently it takes 2 arguments - the function space and mesh - and returns the height on that function space & mesh. Any valid function space and mesh can be given as arguments, and it will always return the right height field.
The addition of new variables to the argument list does not now adhere to this behaviour. i.e. I cannot give any value of scaled_radius and have it return the correct height for that scaled radius. What will happen is that the first time the getter is called, it will use the scaled radius passed in to calculated the values returned. Then any subsequent call for the same function space & mesh will return the same height field, regardless of the value of scaled_radius passed in. This is both confusing and highly dangerous, and as such, I don't think can be accepted onto trunk.
The easiest way I can think that would be acceptable is to pass modeldb%config into the getter functions. This is an obvious exception to the rest of the API for carrying configuration information into the getter functions that can no longer be passed via module use statements. I think we would be able to be clear that the config is a "fixed" part of the API, whilst all other parts remain variable.
The other option would be to make the API work for all parts being genuinely variable - but I think that's significantly beyond the scope of this work, and also doesn't really have any use case that I can think of!
|
All namelists variables that are used low down in the code via module scope where passed by argument for a number of reasons here (you may not agreed with all of them):
If I have not attempted to place a dependency on
I assume you mean the function_space enumeration? (W0,W3 etc) since a function space is constructed on a specific mesh. Again, if more arguments are required, it is because lower down the calling tree, the code accesses those arguments from module scope.
If
Config holds the namelists configuration for an instance of the application read in from the namelist input file. Initially I had considered passing config_type down. Though this would then rely on the upstream application using
The prime motivation is to get namelists variables out of module scope. No doubt, as this touches a lot of files, it's not going to please everyone all (or any) of the time. Though it will achieve the main goal while exposing what is used where and perhaps lead to developers reconsidering whether they really needed those defensive checks/log messsages so low down in the code. |
That's fair, now it gets the scaled radius passed down which could be from any of multiple configurations, which is ultimately the configuration the rank is working on at the time of the call, just now the application has to manage it
The existing subroutine argument (if it's the one I recall) is not called
Isn't that the point, the value is allowed to change because should there be multiple configurations within a run, you have to allow for the possibility of different values. The values in the arguments are controlled by being passed down from the
I'm not sure how you would do that, essentially every namelist value at present is a "fixed" input if it is read from module scope. If you choose to access a variable from module scope, you are essentially removing the option for future users to vary that namelist item across all the configurations an executable wishes to load at runtime. That is a configuration choice, I don't know which variables will always stay the same (though some more likely than others) can you say for sure which ones will and won't (assumptions like that have already bitten me)? Let's assume there are variables that are accessed from module scope, the value held in will be from the last configuration file that was read in. So users would need to know from the get-go which variables are safe to access from module scope, and those same variables have to remain the same across all configurations loaded. How would you maintain it, which variables are "fixed" for a given revision of a model? and "if" it suddenly becomes necessary to make variable, someone has to go in and replumb it all again. You could make one namelist for those, but that just renaming the big "bucket" method. That would be in danger of users dumping in whatever they don't want to plumb down. |
|
Sorry, meant to edit the the reply, though it's looks like I edited your response. |
|
Having had a closer look at what is calling those functions, there may be a way through. I think only algorithms call functions/routines from It should work, though something may crop up. I'll code it up and see. |
Steven Sandbach (ss421)
left a comment
There was a problem hiding this comment.
Update looks good to me.
This change requires an update to JEDI and Ive created https://github.com/JCSDA-internal/lfric-jedi/pull/1277. Ricky Wong (@mo-rickywong) Can you add that to the linked PRs please?
Tested at: mo-rickywong@181256b
If there are any further API changes in this PR please let me know so I can retest/update.
James Bruten (james-bruten-mo)
left a comment
There was a problem hiding this comment.
Macro looks good
thomasmelvin
left a comment
There was a problem hiding this comment.
All looks fine to me












PR Summary
Sci/Tech Reviewer:
Code Reviewer: Andrew Coughtrie (@andrewcoughtrie)
This is a linked ticket as a result of MetOffice/lfric_core#324 which removes access to module scope namelists access from core:
The knock-on effect is numerous. The majority of changes are to calling statements, though some code has had more extensive changes. Potentially related to multigrid/inner halo tiling/lfric2lfric. Code owners concerned may want to check how it affects them.
Linked PR
The linked PR contains an update macro which had been applied to the working copy which ran the rose test suite output. The effect of the update macro adds entries for tiling to &partitioning and &multigrid which needed to be moved out of driver.
Code Quality Checklist
Testing
Trac.log
As noted in the comments there is one checksum failure on an operational task with the cce-compiler. I think it is a compiler related issue, as the same tasks runs green for other compiler/precision tasks. Shouldn't think this is an issue as for production the emphasis is on speed rather than bit-level reproducibility.
Test Suite Results - lfric_apps - AppsRmGlobalCfg_CoreDriver/run12
Suite Information
Task Information
❌ failed tasks - 2
⌛ waiting tasks - 1
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review