Skip to content

Spectral and Newtonian Nudging - #670

Merged
James Bruten (james-bruten-mo) merged 39 commits into
MetOffice:mainfrom
tommbendall:spectral_nudging
Oct 22, 2026
Merged

James Bruten (james-bruten-mo) merged 39 commits into
MetOffice:mainfrom
tommbendall:spectral_nudging

Conversation

@tommbendall

@tommbendall Thomas Bendall (tommbendall) commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary

Sci/Tech Reviewer: iboutle
Code Reviewer: Ed Hone (@EdHone)

This adds the capability to nudge LFRic prognostic fields to external data (e.g. ERA or AIFS). The technical infrastructure for this was added in #474 -- this PR adds the scientific capability.

This adds:

  • a new algorithm called nudging_alg_mod.x90, which is called from external_forcing
  • new namelist options to control the nudging
  • two methods of nudging: "spectral" and "newtonian"
  • kernels for performing the spectral nudging (to pre-compute weights and to compute the convolution)
  • a kernel for calculating vertical nudging weights
  • a kernel to perform the vertical interpolation of the external data onto the model's mesh
  • tests for Newtonian and spectral nudging, on the dynamics mesh or coarser mesh
  • documentation(!)

Test branch: https://github.com/tommbendall/lfric_apps/pull/16/changes

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 - test_spectral_nudging/run2

Suite Information

Item Value
Suite Name test_spectral_nudging/run2
Suite User thomas.bendall
Workflow Start 2026-08-19T09:40:35
Groups Run all
Dependency Reference Main Like
casim MetOffice/casim@2026.07.1 True
jules MetOffice/jules@2026.07.1 True
lfric_apps tommbendall/lfric_apps@test_spectral_nudging 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 - 1600

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)

Met Office Github Copilot Enterprise used in creating documentation.

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

@tommbendall Thomas Bendall (tommbendall) added the enhancement New feature or request label Jul 27, 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 27, 2026
@tommbendall Thomas Bendall (tommbendall) removed the cla-modified The CLA has been modified as part of this PR - added by GA label Jul 27, 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 28, 2026
@tommbendall Thomas Bendall (tommbendall) added KGO This PR contains changes to KGO macro This PR contains a metadata upgrade macro labels Jul 29, 2026

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

Hi Tom,

Passing this back now, although I'm still reading through the documentation etc, as I think there are a few changes that we probably do want to build into this, in-case they change the way anything is implemented:

  • we need a nudging_stop namelist entry, to turn off the nudging after a set period of time. It needs to accommodate very large numbers, which is why I wondered if it would be better to specify in hours instead of seconds, and make the start times consistent with this
  • we need the ability to stop the nudging above MAX(tropopause_level, nudging_min_tropopause_level) where nudging_min_tropopause_level=48 and tropopause_level is calculated via locate_tropopause_kernel_mod. I think you'll need to call locate_tropopause_kernel on the nudging mesh - possibly you could do this when calculating the weights, and then alter the weights calculation kernel to set them to 0 based on this condition. Essentially this means that the weights calculation will always need to happen when nudging is on, because the tropopause will change every timestep.

Comment thread applications/lfric_atm/metadata/lfric_dictionary.xml Outdated
Comment thread rose-stem/site/meto/groups/groups_lfric_atm.cylc Outdated
Comment thread science/gungho/rose-meta/lfric-gungho/HEAD/rose-meta.conf
Comment thread rose-stem/app/lfric_atm/rose-app.conf
Comment thread science/gungho/rose-meta/lfric-gungho/HEAD/rose-meta.conf
Comment thread science/gungho/rose-meta/lfric-gungho/versions.py Outdated
Comment thread science/gungho/rose-meta/lfric-gungho/versions.py Outdated
@tommbendall

Copy link
Copy Markdown
Contributor Author

iboutle I think this is now ready for review again. I'm afraid there were quite a few changes, but the diff to see them all together is here: https://github.com/tommbendall/lfric_apps/compare/e5a2430..05797a3

What I've done:

  • updated vertical levels in upgrade macro as suggested
  • changed nudging_time variables to use hours rather than seconds
  • separated out nudging_relax_time into an option for each variable
  • added nudging_stop_time variable
  • restored nudging_source as this will be used to specify nudging to UM/LFRic output
  • added nudging_min_tropopause_level option
  • changed the nudging weights to be a 1D array for the vertical weights. This now doesn't need a kernel to calculate it, so it is just calculated in a routine in physics_constants_mod.x90
  • the temporal weights are pulled out into a single number, so weights no longer need updating. The update_nudging_weights routine has been removed
  • added calls so that tropopause level to be used to cap vertical extent of nudging
  • changed convolution_2d_kernel to include vertical and temporal weights, and to have its vertical extent limited
  • introduced newtonian_nudging_kernel to perform Newtonian nudging routine, using vertical and temporal weights
  • psy_lite versions of kernels that use scalar array needed
  • renamed nudging_vert_interp_kernel to include ecmwf since it is specific to ECMWF pressure levels

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

A few minor comments but nothing too serious!

Comment thread rose-stem/site/common/lfric_atm/tasks_lfric_atm.cylc Outdated
Comment thread science/gungho/source/algorithm/physics/external_forcing_alg_mod.X90 Outdated
Comment thread science/gungho/rose-meta/lfric-gungho/versions.py Outdated
@tommbendall

Copy link
Copy Markdown
Contributor Author

A few minor comments but nothing too serious!

Thanks for the suggestions: I've made these now so this is back to you

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

Looks good - over you you Ed Hone (@EdHone)

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

All looks fine from a code owner view

@iboutle
iboutle removed the request for review from Copilot August 19, 2026 13:19

@EdHone Ed Hone (EdHone) 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.

Some minor changes requested for some formatting, but otherwise all looks good

Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/physics/nudging_alg_mod.X90 Outdated
Comment thread science/gungho/source/algorithm/runtime_constants/physics_constants_mod.X90 Outdated
@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label Oct 1, 2026
@tommbendall

Copy link
Copy Markdown
Contributor Author

Some minor changes requested for some formatting, but otherwise all looks good

Thanks for the review! Style fixes made in a1815c5

I've then merged up to head-of-main and fixed conflicts

@james-bruten-mo
James Bruten (james-bruten-mo) merged commit 8de262e into MetOffice:main Oct 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request 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.

9 participants