Skip to content

Improvements to tke diagnostic#487

Open
Adrian Lock (Adrian-Lock) wants to merge 12 commits into
MetOffice:mainfrom
Adrian-Lock:main905c_improve_tke_diag
Open

Improvements to tke diagnostic#487
Adrian Lock (Adrian-Lock) wants to merge 12 commits into
MetOffice:mainfrom
Adrian-Lock:main905c_improve_tke_diag

Conversation

@Adrian-Lock
Copy link
Copy Markdown
Contributor

@Adrian-Lock Adrian Lock (Adrian-Lock) commented May 8, 2026

PR Summary

Sci/Tech Reviewer: MichaelWhitall
Code Reviewer: Cameron Bateman (@cameronbateman-mo)

The boundary layer scheme diagnoses a vertical velocity variance (w_var, and thence turbulent kinetic energy, TKE) that is used by other physics parametrizations to quantify subgrid variability. In the CoMorph convection scheme, for example, the ratio Km/sqrt(w_var) is used as the turbulence length-scale. However, issues with both the local and non-local contributions to TKE have been identified and those are corrected here. The corrections are controlled via the namelist logocal improved_tke_diag

Equivalent changes in the UM: vn14.1_improve_tke_diag

closes #232

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 - main905c_improve_tke_diag/run4

Suite Information

Item Value
Suite Name main905c_improve_tke_diag/run4
Suite User adrian.lock
Workflow Start 2026-05-07T16:29:19
Groups Run all
Dependency Reference Main Like
casim MetOffice/casim@2026.03.2 True
jules MetOffice/jules@2026.03.2 True
lfric_apps Adrian-Lock/lfric_apps@main905c_improve_tke_diag False
lfric_core MetOffice/lfric_core@3c8ccc6 True
moci MetOffice/moci@2026.03.2 True
SimSys_Scripts MetOffice/SimSys_Scripts@cab3315 True
socrates MetOffice/socrates@2026.03.2 True
socrates-spectral MetOffice/socrates-spectral@2026.03.2 True
ukca MetOffice/ukca@1cdb9c2 True

Task Information

❌ failed tasks - 5
Task State
check_lfric_atm_nwp_comorph_dev-C12_azspice_gnu_fast-debug-32bit-crun1 failed
check_lfric_atm_nwp_comorph_dev-C12_ex1a_cce_fast-debug-32bit-crun1 failed
check_lfric_atm_scm_comorph_dev_toga-BiP2x2-50000x50000_azspice_gnu_fast-debug-32bit failed
check_lfric_atm_scm_comorph_dev_toga-BiP2x2-50000x50000_ex1a_cce_fast-debug-32bit failed
validate_rose_meta failed
✅ succeeded tasks - 1530
⌛ waiting tasks - 2
Task State
housekeep_azspice waiting
housekeep_ex1a waiting

Test branch (from main with kgo updated) and update macro applied:

test2_improve_tke_diag

trac.log:

Test Suite Results - lfric_apps - test2_improve_tke_diag/run1

Suite Information

Item Value
Suite Name test2_improve_tke_diag/run1
Suite User adrian.lock
Workflow Start 2026-05-08T13:11:05
Groups Run all
Dependency Reference Main Like
casim MetOffice/casim@2026.03.2 True
jules MetOffice/jules@2026.03.2 True
lfric_apps Adrian-Lock/lfric_apps@test2_improve_tke_diag False
lfric_core MetOffice/lfric_core@3c8ccc6 True
moci MetOffice/moci@2026.03.2 True
SimSys_Scripts MetOffice/SimSys_Scripts@cab3315 True
socrates MetOffice/socrates@2026.03.2 True
socrates-spectral MetOffice/socrates-spectral@2026.03.2 True
ukca MetOffice/ukca@1cdb9c2 True

Task Information

✅ succeeded tasks - 1536

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

Needs to be added to the Boundary Layer documentation paper but will have to wait until it is ported. I've opened issue #490 to do this separately.

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

* As noted above, adding documentation for this change is pending the boundary-layer scheme doc being ported into lfric_apps (underway in PR #465) and will be addressed in a later PR.

(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

class vn31_t487(MacroUpgrade):
# Upgrade macro for #487 by Adrian Lock

BEFORE_TAG = "vn3.1_t368"
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 Adrian, This Before Tag should be vn3.1 as the branch currently is (it might change when main is merged in).

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 James. Ah, I was thinking I would need to follow the revision in the lfric_atm/rose-app.conf, ie https://github.com/Adrian-Lock/lfric_apps/blob/main905c_improve_tke_diag/rose-stem/app/lfric_atm/rose-app.conf, but that's not the case then? This branch is made from main (at revision ...905c) because I didn't want major clashes with Ben's removal of j-loops.

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.

No, it should use the latest AFTER_TAG of the versions.py file they're in, which in this case is still the latest release. This also means that if you were to add multiple macros in the same PR they might have different BEFORE_TAGs.

When apply_macros.py gets run it will copy this macro to places which use um-boundary_layer metadata and update the BEFORE_TAG to match the correct for that file.

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.

OK, thanks, that makes sense and now fixed.

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.

Cheers, macro looks good now

@Adrian-Lock Adrian Lock (Adrian-Lock) added the KGO This PR contains changes to KGO label May 8, 2026
@github-actions github-actions Bot requested a review from MichaelWhitall May 8, 2026 16:15
Comment thread science/physics_schemes/source/boundary_layer/excf_nl_9c.F90 Outdated
Comment thread science/physics_schemes/source/boundary_layer/excf_nl_9c.F90 Outdated
Comment thread science/physics_schemes/source/boundary_layer/excf_nl_9c.F90 Outdated
Comment thread science/physics_schemes/source/boundary_layer/excf_nl_9c.F90 Outdated
Adrian Lock (Adrian-Lock) and others added 4 commits May 11, 2026 12:45
Co-authored-by: iboutle <135141261+iboutle@users.noreply.github.com>
Co-authored-by: iboutle <135141261+iboutle@users.noreply.github.com>
Co-authored-by: iboutle <135141261+iboutle@users.noreply.github.com>
@github-actions github-actions Bot added the cla-modified The CLA has been modified as part of this PR - added by GA label May 11, 2026
Copy link
Copy Markdown
Contributor

@MichaelWhitall MichaelWhitall left a comment

Choose a reason for hiding this comment

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

Many thanks for this Adrian; I've looked through the branch and I think I've satisfied myself this is implementing exactly the same changes as the equivalent UM branch where I've copied the related code from the comorph_dev branch: https://github.com/MetOffice/um/compare/main...MichaelWhitall:um:vn14.1_improve_tke_diag
Just a couple of quick questions Re where I've spotted differences between the above UM branch and the changes here (I think there are good reasons but can I just check I've correctly understood the code?); see the in-line comments...

Cheers!
Mike

Comment thread science/physics_schemes/source/boundary_layer/bdy_expl2.F90
Comment thread science/physics_schemes/source/boundary_layer/ex_coef.F90
Comment thread science/physics_schemes/source/boundary_layer/ex_coef.F90
Comment thread science/physics_schemes/source/boundary_layer/excf_nl_9c.F90
Copy link
Copy Markdown
Contributor

@MichaelWhitall MichaelWhitall left a comment

Choose a reason for hiding this comment

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

That's great, thanks lots for clarifying; that's great you've been tidying-up and removing code for unused options! Sci/Tech review approved.

Cheers!
Mike

@cameronbateman-mo
Copy link
Copy Markdown
Contributor

Hi Adrian, would it be possible to resolve the conflicts on the branch and ill start testing :), thanks. Adrian Lock (@Adrian-Lock)

@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label May 21, 2026
@Adrian-Lock
Copy link
Copy Markdown
Contributor Author

No problem, conflicts merged. I've left the checksums as they were, because main has added a new namelist variable to the comorph_dev app and so those will need to be updated with the data from the merged branch. Is that something you can do?

@cameronbateman-mo
Copy link
Copy Markdown
Contributor

Yes thank you for the resovling that. Yeah leave it with me thank you.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve consistency of diagnosed TKE with diffusivity

6 participants