Skip to content

Infrastructure for PMSL calculation#303

Open
iboutle wants to merge 5 commits intoMetOffice:mainfrom
iboutle:core3.1_pmsl
Open

Infrastructure for PMSL calculation#303
iboutle wants to merge 5 commits intoMetOffice:mainfrom
iboutle:core3.1_pmsl

Conversation

@iboutle
Copy link

@iboutle iboutle commented Mar 6, 2026

PR Summary

Sci/Tech Reviewer: @tommbendall
Code Reviewer: @MatthewHambley

This PR provides 2 pieces of infrastructure required by the revised PMSL calculation in MetOffice/lfric_apps#348:

  • creating the dx_at_w2 and height_wth fields with large halos. These field are needed by the PMSL calculation, and will be populated by a single halo exchange the first time the PMSL code is called
  • creating a utility routine which copies one field to another to a specific (clean) depth in the halo

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 Core rose-stem suite
  • If required (e.g. API changes) I have also run the LFRic Apps test suite using this branch
  • 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_core - core3.1_pmsl/run1

Suite Information

Item Value
Suite Name core3.1_pmsl/run1
Suite User ian.boutle
Workflow Start 2026-03-09T13:18:16
Groups Run developer
Dependency Reference Main Like
lfric_core iboutle/lfric_core@core3.1_pmsl False
SimSys_Scripts MetOffice/SimSys_Scripts@2025.12.1 True

Task Information

✅ succeeded tasks - 384

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

@github-actions github-actions bot added the cla-signed The CLA has been signed as part of this PR - added by GA label Mar 6, 2026
@iboutle iboutle marked this pull request as ready for review March 9, 2026 14:56
@iboutle iboutle requested review from a team and tommbendall as code owners March 9, 2026 14:56
@iboutle iboutle requested review from andrewcoughtrie and removed request for a team March 9, 2026 14:56
@iboutle iboutle added the Linked Apps This PR is linked to a MetOffice/lfric_apps PR label Mar 10, 2026
Copy link
Contributor

@tommbendall tommbendall left a comment

Choose a reason for hiding this comment

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

The changes to the height field look good.

On the new kernel, I have a question for @MatthewHambley as code reviewer and @TeranIvy who may also have a view: the new copy_field_halo_kernel is just a setval_X which can loop to a variable halo depth. I think this kernel might be more natural as a psykal_light routine -- as a column-based kernel we end up with three nested loops (over columns, dofs-per-cell and then layers) and since we are just copying data up to some specified depth, would it be neater to do this explicitly in some psykal_light code?

However this looks fine if we would be happier keeping this kernel as is

@iboutle
Copy link
Author

iboutle commented Mar 13, 2026

The changes to the height field look good.

On the new kernel, I have a question for @MatthewHambley as code reviewer and @TeranIvy who may also have a view: the new copy_field_halo_kernel is just a setval_X which can loop to a variable halo depth. I think this kernel might be more natural as a psykal_light routine -- as a column-based kernel we end up with three nested loops (over columns, dofs-per-cell and then layers) and since we are just copying data up to some specified depth, would it be neater to do this explicitly in some psykal_light code?

However this looks fine if we would be happier keeping this kernel as is

I have no strong preference over how this is done, so am happy with whatever the 3 of you think is best. Just to note that for the purpose I need it, the kernel only gets used on a 2D W3 field, so doesn't actually require any of the nested loops - I only added those in in an effort to make something more generic & flexible!

@TeranIvy
Copy link

TeranIvy commented Mar 13, 2026

The changes to the height field look good.

On the new kernel, I have a question for @MatthewHambley as code reviewer and @TeranIvy who may also have a view: the new copy_field_halo_kernel is just a setval_X which can loop to a variable halo depth. I think this kernel might be more natural as a psykal_light routine -- as a column-based kernel we end up with three nested loops (over columns, dofs-per-cell and then layers) and since we are just copying data up to some specified depth, would it be neater to do this explicitly in some psykal_light code?

However this looks fine if we would be happier keeping this kernel as is

I consulted STFC and here's @arporter's reply:

"For it to be psykal-lite, we could do with a plan for it to be supported. We recently extended the operates_on to include column-based kernels that have to operate into halos:
image
Potentially we could extend the dof and owned_dof in the same way and then have a new builtin (setval_halo_X perhaps?) that operates on owned_and_halo_dof?
Of course, you could also apply redundant computation to the appropriate setval_X but that breaks separation of concerns as that puts science-specific logic into a transformation script."

I would agree with the route that Andy proposed to extend operates_on=dof to be able to loop into halo dofs. Whether this is implemented as a built-in in PSyclone I think is less important as it could be implemented as a dof kernel with the code inlined into PSy-layer (it's not clear to me from the wording "may be extended to annexed and halo DoFs" whether PSyclone 3.2 the we currently use can do that).

I am happy to open a PSyclone issue for this. I'll leave it to the code reviewer (@MatthewHambley) to decide whether to go down the route of requesting a PSyKAl-lite implementation in this PR, or just a reference to the PSyclone issue in the kernel (either is fine with me personally).

@iboutle
Copy link
Author

iboutle commented Mar 13, 2026

The changes to the height field look good.
On the new kernel, I have a question for @MatthewHambley as code reviewer and @TeranIvy who may also have a view: the new copy_field_halo_kernel is just a setval_X which can loop to a variable halo depth. I think this kernel might be more natural as a psykal_light routine -- as a column-based kernel we end up with three nested loops (over columns, dofs-per-cell and then layers) and since we are just copying data up to some specified depth, would it be neater to do this explicitly in some psykal_light code?
However this looks fine if we would be happier keeping this kernel as is

I consulted STFC and here's @arporter's reply:

"For it to be psykal-lite, we could do with a plan for it to be supported. We recently extended the operates_on to include column-based kernels that have to operate into halos: image Potentially we could extend the dof and owned_dof in the same way and then have a new builtin (setval_halo_X perhaps?) that operates on owned_and_halo_dof? Of course, you could also apply redundant computation to the appropriate setval_X but that breaks separation of concerns as that puts science-specific logic into a transformation script."

I would agree with the route that Andy proposed to extend operates_on=dof to be able to loop into halo dofs. Whether this is implemented as a built-in in PSyclone I think is less important as it could be implemented as a dof kernel with the code inlined into PSy-layer (it's not clear to me from the wording "may be extended to annexed and halo DoFs" whether PSyclone 3.2 the we currently use can do that).

I am happy to open a PSyclone issue for this. I'll leave it to the code reviewer (@MatthewHambley) to decide whether to go down the route of requesting a PSyKAl-lite implementation in this PR, or just a reference to the PSyclone issue in the kernel (either is fine with me personally).

Thanks @TeranIvy.

Aside from the philosophical dislike of the transformation script, I'm not sure this would work anyway in this instance, as the depth into the halo we are looping needs to be passed in from the algorithm, since it is changing with each iteration of the solver.

So yes, I think I agree that the best long term solution would be something like an owned_and_halo_dof or setval_halo_X that takes the halo depth argument from the algorithm. Let me know the PSyclone issue number when you have it, and I'll reference in the kernel or PSy-lite code, whichever @MatthewHambley prefers.

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

Labels

cla-signed The CLA has been signed as part of this PR - added by GA Linked Apps This PR is linked to a MetOffice/lfric_apps PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants