Allow meshes to be renamed on load - #452
Matthew Hambley (MatthewHambley) merged 21 commits into
Conversation
|
Sci/Tech review: Thanks for making these changes to enable using meshes with the same name in lfric2lfric. I am generally happy with the implementation with only a couple of minor comments. But please could I encourage the developer to move any changes that are not essential to this work to a separate PR - it will make it a lot easier for reviewers to give a proper assessment of the work. |
|
All comments addressed, test-suite green, passing back to reviewer |
cjohnson-pi
left a comment
There was a problem hiding this comment.
Many thanks for your response to my previous review. I am happy with those changes. There are still just a couple of minor changes to be made, including reverting further changes that are not required for this ticket.
|
Back with cjohnson-pi |
cjohnson-pi
left a comment
There was a problem hiding this comment.
Thanks for completing the requested changes.
Matthew Hambley (MatthewHambley)
left a comment
There was a problem hiding this comment.
Generally looks okay. I've noted a few issues of code style. If you want to postpone them to a subsequent ticket, please raise the ticket and link to it on this one.
I wont insist on the string changes because I see string handling is shot throughout this change and modifying it would delay further. But consider them for future.
|
Changes made, couple of extra failure in apps test suite exposed rope issues in core. Those areas of code should be cleared up with #463. So the extra update were to get it through the apps test-suite |
Matthew Hambley (MatthewHambley)
left a comment
There was a problem hiding this comment.
Ready for trunk.
c49636e
into
MetOffice:main
PR Summary
Sci/Tech Reviewer: cjohnson-pi
Code Reviewer: Matthew Hambley (@MatthewHambley)
Access to meshes in input files produced from the mesh generators should contain unique mesh names by design. The mesh names are used as a more user-friendly means to reference meshes in downstream applications. This however becomes an issue when applications such as lfric2lfric are required to read in multiple files produced for other applications. Applications which generate their input files may have used mesh(es) with identical names (e.g. dynamics, multigrid_l1, etc) in their individual tasks which produce output.
Adopting a practice of naming a mesh after the process/scheme that uses it, rather than a name that describes the mesh is not ideal. However, this practice has come about as a result of XIOS iodef.xml files which reference the specific mesh name, having the same mesh names allow for a template iodef.xml to be used. The alternative would significantly increase the number of iodef.xml files (with only a mesh name change between them). Having a constant mesh name, thus results in meshes from separate files having the same name.
This poses a problem for applications like lfric2lfric, where it needs to read different meshes from one or more files, were the meshes might have the same name in each of the files.
The simple solution here is to allow an application to read in the meshes (which have the same name) from individual files as separate instances and allow the application (lfric2lfric) to rename when the instance are created. This allows a method for an application to not violate the unique naming of objects restrictions in the mesh collections. This neatly allows lfric2lfric to use the meshes it requires (with the names they wish) without impacting the upstream applications that produced the input files.
Implementation
Allowing the meshes to be renamed before storing them in the collections is relatively straight forward. An optional argument on the method on the mesh constructors (global/local) allow the mesh objects to be renamed on creation before storing them in the collection. After that, the application should only worked with the "stored mesh names".
Complications
Mesh inter-grid maps: These where designed to be valid at the point of mesh generation, i.e. applications should only use maps between meshes sourced from the same file. In this case, the meshes are being renamed and potentially from separate files. The maps themselves are logged from mesh to mesh via their ids, which remain unique, so that shouldn't be an issue. The complication comes when identifying which maps from which files should be assigned to which mesh during setup.
The solution here is to log at the point of creation the original mesh name and file that the mesh came from. This means that during the intergrid map setup, maps are only read, created and attached if the meshes (using their original names) came from the same file. After the maps are read and attached, the rest of the code should proceed as normal.
Chi transforms (Out-of-Scope see Refactor code implementing initial chi transform with respect to North Pole and Schmit stretching #460): This does a lot of unnecessary things, however changes to make it more sensible change kgos. So it should be done as separate PR.
Mapping factors: Implementation of mapping factors is too low in the code, in addition it computes for every mesh in the mesh collection which is overkill. It should only need to do this for meshes that are required to be aligned. The routine was overloaded so that a mapping factor could be computed between a global_mesh and a single reference global mesh rather than the whole collection.
Potential downstream issues
Linked PRs
Code Quality Checklist
Testing
Test Suite Results - lfric_core - lfric2lfric_in_and_out/run1
Suite Information
Task Information
✅ succeeded tasks - 433
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