Skip to content

Refactor fast physics - #368

Merged
Lottie Turner (mo-lottieturner) merged 29 commits into
MetOffice:mainfrom
iboutle:fast_refactor
Apr 28, 2026
Merged

Lottie Turner (mo-lottieturner) merged 29 commits into
MetOffice:mainfrom
iboutle:fast_refactor

Conversation

@iboutle

@iboutle iboutle commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary

Sci/Tech Reviewer: MichaelWhitall
Code Reviewer: Lottie Turner (@mo-lottieturner)

This PR refactors fast physics to enable 2 key pieces of science infrastructure (which are also implemented by this PR):

  • allow the implicit boundary layer to be called before convection (needed by Comorph-B)
  • allow different convection schemes to be called on different outer loops (specifically LLCS on the first outer loop)

To enable this, it has been necessary to properly separate the boundary layer and convection increments, which were previously badly inter-mixed. Fast physics now tracks "latest" fields which are updated by each scheme in turn (since the physics here is sequential by design), and then finally constructs an increment from the difference between the final and initial fields. Because this changes the calculation order, it changes many KGOs for lfric_atm

The calls to these schemes in slow physics have also had to be updated to be consistent, and diagnostics previously produced in bl_imp_alg but that depend on convection have had to be separated into their own algorithm to be called after BL and convection have definitely both been done.

Ideally, the new "BL before conv" functionality would be switched on in the comorph_dev tests, however these currently fail when doing so. I will investigate this separately, as the failure is not connected to the code introduced by this PR (particularly the refactoring, which we want to consolidate back to main asap), but is a feedback on model evolution. Doing so would also conflict with several other PRs in flight (#292, #326) so is best left as a separate PR.

closes #228

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 - fast_refactor/run1

Suite Information

Item Value
Suite Name fast_refactor/run1
Suite User ian.boutle
Workflow Start 2026-03-17T14:04:49
Groups Run developer', 'lfric_atm_extra
Dependency Reference Main Like
casim MetOffice/casim@2026.03.2 True
jules MetOffice/jules@2026.03.2 True
lfric_apps iboutle/lfric_apps@fast_refactor False
lfric_core MetOffice/lfric_core@2026.03.2 True
moci MetOffice/moci@2026.03.2 True
SimSys_Scripts MetOffice/SimSys_Scripts@2026.03.2 True
socrates MetOffice/socrates@2026.03.2 True
socrates-spectral MetOffice/socrates-spectral@2026.03.2 True
ukca MetOffice/ukca@2026.03.2 True

Task Information

✅ succeeded tasks - 1310

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

@iboutle iboutle added this to the Summer 2026 milestone Mar 13, 2026
@iboutle iboutle added KGO This PR contains changes to KGO macro This PR contains a metadata upgrade macro labels Mar 13, 2026
@github-actions github-actions Bot added the cla-signed The CLA has been signed as part of this PR - added by GA label Mar 13, 2026
@iboutle
iboutle marked this pull request as ready for review March 17, 2026 15:33
@github-actions github-actions Bot removed the cla-signed The CLA has been signed as part of this PR - added by GA label Mar 30, 2026
@iboutle

iboutle commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author

Ah I just found the "submit review" button! I think its been hiding all my in-line comments from you until I press this button... Can you see the comments now?

Hopefully I've addressed all of these...

@MichaelWhitall

Copy link
Copy Markdown
Contributor

Hopefully I've addressed all of these...

Yep this all looks good to me :) The bot seems to've already automatically moved this out of sci/tech review for me (I assumed I'd need to press a button somewhere to sign this off?) Maybe it counts as signed-off once all the comments are marked as "resolved"?)

Cheers!
Mike

@MichaelWhitall MichaelWhitall 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.

Oh no wait there actually is an "approve" button in here, which I hadn't pressed yet; I think the bot's activity was a bit premature? Anyhow I'm pressing the button now ;)

@iboutle

iboutle commented Mar 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Hopefully I've addressed all of these...

Yep this all looks good to me :) The bot seems to've already automatically moved this out of sci/tech review for me (I assumed I'd need to press a button somewhere to sign this off?) Maybe it counts as signed-off once all the comments are marked as "resolved"?)

Cheers! Mike

The bot moved it to "changes requested" - I should have moved it back to sci/tech after doing them. I think you need to tick the boxes in the science review section, and then tag the code reviewer in a comment saying your happy it's passed - the bot is supposed to move it to code review, although I've never actually got that to work!

@MichaelWhitall

Copy link
Copy Markdown
Contributor

Sci/Tech review approved on this one, passing over to Lottie Turner (@mo-lottieturner) for code review...

Cheers!
Mike

@github-actions github-actions Bot added the cla-modified The CLA has been modified as part of this PR - added by GA label Apr 28, 2026
!>@param[in] clock Model time information
subroutine stph_main_alg( du_stph, dtheta_stph, dmv_stph, &
dtheta, mv, rho, u, &
subroutine stph_main_alg( du_stph, dtheta_stph, dmv_stph, dtheta, &

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.

Suggested change
subroutine stph_main_alg( du_stph, dtheta_stph, dmv_stph, dtheta, &
subroutine stph_main_alg( du_stph, dtheta_stph, dmv_stph, &

changed name variable has been duplicated in merge

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.

Well caught, thanks for pointing it out!

if (use_spt) then
call spt_main_alg(dtheta_stph, dmv_stph, dtheta, mv, &
convection_fields, &
call spt_main_alg(dtheta_stph, dmv_stph, dtheta, &

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.

Suggested change
call spt_main_alg(dtheta_stph, dmv_stph, dtheta, &
call spt_main_alg(dtheta_stph, dmv_stph, &

changed name variable has been duplicated in merge

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.

Thanks Ian

@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label Apr 28, 2026
!>@param[in] clock Model time information
subroutine stph_main_alg( du_stph, dtheta_stph, dmv_stph, &
dtheta, mv, rho, u, &
subroutine stph_main_alg( du_stph, dtheta_stph, dmv_stph, dtheta, &

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.

Well caught, thanks for pointing it out!

if (use_spt) then
call spt_main_alg(dtheta_stph, dmv_stph, dtheta, mv, &
convection_fields, &
call spt_main_alg(dtheta_stph, dmv_stph, dtheta, &

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.

Thanks Ian

@mo-lottieturner
Lottie Turner (mo-lottieturner) merged commit cf625d2 into MetOffice:main Apr 28, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

KGO This PR contains changes to KGO macro This PR contains a metadata upgrade macro

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add option to call implicit boundary-layer before convection

7 participants