Skip to content

lfric2lfric: Allow multiple meshes to be created and reorganise configs - #655

Open
cjohnson-pi wants to merge 3 commits into
MetOffice:mainfrom
cjohnson-pi:multiple_meshes
Open

lfric2lfric: Allow multiple meshes to be created and reorganise configs#655
cjohnson-pi wants to merge 3 commits into
MetOffice:mainfrom
cjohnson-pi:multiple_meshes

Conversation

@cjohnson-pi

@cjohnson-pi cjohnson-pi commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

PR Summary

App tasks (e.g. lfric_atm) specify which mesh to run with (in the resolution setting). A mesh task is then created to create that mesh. But this only allows for one mesh to be created per app task. lfric2lfric requires 2 meshes, and so this PR allows for more multiple meshes to be created per task.

The lfric2lfric tasks are also reorganised so that there will be 3 main types of configuration file:

  • rose-app-src_mesh_levels.conf (the source data e.g. data filename, mesh, vertical levels - all this info is kept together as the data will always be for a particular mesh and levels )
  • rose-app-dst_mesh.conf (the destination mesh)
  • rose-app-dst_levels.conf (the destination vertical levels - this is separate to the mesh as they are not necessarily together)

At the moment only horizontal regridding is applied, so there are no dst_levels configurations on this PR.

The reorganisation of the configs means that some of the fail-ifs in the rose-meta have needed to be removed so that the validate rose-meta task suceeds.

Sci/Tech Reviewer: Mike Hobson (@mike-hobson)
Code Reviewer: James Bruten (@james-bruten-mo)

This makes it a little easier to add new tasks, and avoids assumed dependencies on other tasks e.g. at the moment some lfric2lfric tasks are using meshes created by other tasks. This might cause failures if those meshes are not created in time or if the associated tasks are removed.

Single mesh (including multigrid) tasks (as current implementation):

{% do task_dict.update({
    "resolution": "C224_MG",

Multiple-mesh (double or more) tasks (new):

{% do task_dict.update({	
    "resolution": ["melbourne","C224"],

To enable this, the following files are changed.

rose-stem/templates/graph/populate_gen_weights_graph.cylc
• Lfric2lfric weight generation needs to use 2 meshes rather than 1.
• This is setup as:
build_mesh => run_mesh1 => run_mesh2 => generate_weights

rose-stem/templates/graph/populate_graph_sections.cylc
• Lfric2lfric regridding needs to use 2 meshes rather than 1.
• This is set up as:

build_mesh => run_mesh1
build_mesh => run_mesh2
build_application => run_application

(This assumes that building the application takes longer than building and creating the meshes, as also assumed currently).

rose-stem/templates/runtime/generate_runtime_application.cylc
• Remove adding the mesh .conf file to the lfric2lfric task options (its only needed to generate the meshes)

blocks #660
This is a small part split from #530

Code Quality Checklist

  • I have performed a self-review of my own code
  • My code follows the project's style guidelines
  • Comments have been included that aid understanding and enhance the readability of the code
  • My changes generate no new warnings
  • All automated checks in the CI pipeline have completed successfully

Testing

  • I have tested this change locally, using the LFRic Apps rose-stem suite
  • If any tests fail (rose-stem or CI) the reason is understood and acceptable (e.g. kgo changes)
  • I have added tests to cover new functionality as appropriate (e.g. system tests, unit tests, etc.)
  • Any new tests have been assigned an appropriate amount of compute resource 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

Test Suite Results - lfric_apps - multiple_meshes/run5

Suite Information

Item Value
Suite Name multiple_meshes/run5
Suite User christine.johnson
Workflow Start 2026-07-23T10:03:58
Groups Run all
Dependency Reference Main Like
casim MetOffice/casim@2026.07.1 True
jules MetOffice/jules@2026.07.1 True
lfric_apps cjohnson-pi/lfric_apps@multiple_meshes False
lfric_core MetOffice/lfric_core@2026.07.1 True
moci MetOffice/moci@2026.07.1 True
SimSys_Scripts MetOffice/SimSys_Scripts@2026.07.1 True
socrates MetOffice/socrates@2026.07.1 True
socrates-spectral MetOffice/socrates-spectral@2026.07.1 True
ukca MetOffice/ukca@2026.07.1 True

Task Information

✅ succeeded tasks - 1592

Security Considerations

  • I have reviewed my changes for potential security issues
  • Sensitive data is properly handled (if applicable)
  • Authentication and authorisation are properly implemented (if applicable)

Performance Impact

  • Performance of the code has been considered and, if applicable, suitable performance measurements have been conducted

AI Assistance and Attribution

  • Some of the content of this change has been produced with the assistance 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

  • Where appropriate I have updated documentation related to this change and confirmed that it builds correctly

PSyclone Approval

  • If you have edited any PSyclone-related code (e.g. PSyKAl-lite, Kernel interface, optimisation scripts, LFRic data structure code) then please contact the TCD Team

Sci/Tech Review

  • I understand this area of code and the changes being added
  • The proposed changes correspond to the pull request description
  • Documentation is sufficient (do documentation papers need updating)
  • Sufficient testing has been completed

(Please alert the code reviewer via a tag when you have approved the SR)

Code Review

  • All dependencies have been resolved
  • Related Issues have been properly linked and addressed
  • CLA compliance has been confirmed
  • Code quality standards have been met
  • Tests are adequate and have passed
  • Documentation is complete and accurate
  • Security considerations have been addressed
  • Performance impact is acceptable

@cjohnson-pi cjohnson-pi self-assigned this Jul 22, 2026
@github-actions github-actions Bot added the cla-modified The CLA has been modified as part of this PR - added by GA label Jul 22, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Hello cjohnson-pi!

Your CLA signature was found on the base branch, but you appear to have modified the CONTRIBUTORS.md file in this PR.

Please do not edit the CONTRIBUTORS.md file. If you have already signed the CLA, revert changes to the file and your signature will be picked up.

@mike-hobson Mike Hobson (mike-hobson) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ability to support providing multiple meshes to a task is definitely something we need. I'm no expert on how this should be done in the suites. James knows far more about this than I do and is the code reviewer, so I'll leave it to him to make any technical judgements.

When I added a coupling test to the Core test suite, this needed to use two meshes and James set this up for me. We should make sure that whatever the method used to specify two meshes is, it is consistent across all tasks that need it in Apps and Core repository test suites.

Over to James Bruten (@james-bruten-mo) for a proper review

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Christine,
This looks reasonable. For the populate_graph_sections file, could you have a look at doing it in the same way as we've done in core to help with maintainability. I've linked to the relevant changeset below.

For populate_gen_weights_graph, I think it does what you've described in the PR description. But I'm unclear why we need to wait for the first mesh to be built before building the 2nd one?

Comment on lines +53 to +57
{% if task_values["resolution"] is iterable and task_values["resolution"] is not string %}
{% set resolutions = task_values["resolution"] %}
{% else %}
{% set resolutions = [task_values["resolution"]] %}
{% endif %}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% if task_values["resolution"] is iterable and task_values["resolution"] is not string %}
{% set resolutions = task_values["resolution"] %}
{% else %}
{% set resolutions = [task_values["resolution"]] %}
{% endif %}
{% if task_values["resolution"] is string %}
{% set resolutions = [task_values["resolution"]] %}
{% endif %}

I think you can simplify this by just checking whether it's a string

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I could just check for a string. But I'll still need to have both parts, because sometimes its a string (for cases with 2 meshes) and sometimes its not (for cases with 1 mesh).

{% endif %}


{# ################################### #}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this file, Mike and I did something very similar in lfric core a while ago. Could you look to do it in the same way here (I think they're functionally identical), so that the 2 files remain as similar as possible. The changeset for lfric_core is at MetOffice/lfric_core@03f9e4d#diff-239288cf861d4d3cf49db1b9cb5fb35fb70a23d90e4c7d9679df64e7c9b0df39

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing me to that change. I will have a go at trying to align my changes with that.

@cjohnson-pi

Copy link
Copy Markdown
Contributor Author

Hi Christine, This looks reasonable. For the populate_graph_sections file, could you have a look at doing it in the same way as we've done in core to help with maintainability. I've linked to the relevant changeset below.

For populate_gen_weights_graph, I think it does what you've described in the PR description. But I'm unclear why we need to wait for the first mesh to be built before building the 2nd one?

Many thanks for the review.

Ah you're right, we don't need to wait for the first mesh to be built before the second one. But the reason I did it like this is that both meshes need to have completed before the lfric2lfric task. And the logic for ( mesh1 and mesh2 and lfric2lfric build) => lfric2lfric seemed too complicated. So I decided the mesh1 => mesh2 => lfric2lfric would solve this requirement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-modified The CLA has been modified as part of this PR - added by GA macro This PR contains a metadata upgrade macro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants