Skip to content

Multidata fields/pseudo-levels in LFRic2UM - #266

Merged
Jenny Hickson (jennyhickson) merged 47 commits into
MetOffice:mainfrom
mo-lottieturner:lfric2um_pseudL
Oct 26, 2026
Merged

Jenny Hickson (jennyhickson) merged 47 commits into
MetOffice:mainfrom
mo-lottieturner:lfric2um_pseudL

Conversation

@mo-lottieturner

@mo-lottieturner Lottie Turner (mo-lottieturner) commented Feb 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary

I recommend that until #806 is on trunk, anyone reviewing the code changes in this PR uses this page instead, as it ignores all changes included in the blocking PR. Blocking PR merged.

This PR adds LFRic2UM functionality to regrid LFRic multidata fields to UM pseudolevel fields

Sci/Tech Reviewer: Mike Hobson (@mike-hobson)
Code Reviewer: Jenny Hickson (@jennyhickson)

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)

The ex1a lfric2um nwp jobs will fail until the new file from #806 is added to $BIG_DATA_DIR

Test Suite Results - lfric_apps - t265_lfric2um_pseudL/run41

Suite Information

Item Value
Suite Name t265_lfric2um_pseudL/run41
Suite User charlotte.turner
Workflow Start 2026-10-20T16:12:38
Groups Run lfricinputs', 'lfric2um_weekly', 'developer
Dependency Reference Main Like
casim MetOffice/casim@996db30 True
jules MetOffice/jules@332ca85 True
lfric_apps mo-lottieturner/lfric_apps@lfric2um_pseudL False
lfric_core MetOffice/lfric_core@d65ef33 True
moci MetOffice/moci@2026.07.1 True
SimSys_Scripts MetOffice/SimSys_Scripts@77a5166 True
socrates MetOffice/socrates@2026.07.1 True
socrates-spectral MetOffice/socrates-spectral@2026.07.1 True
ukca MetOffice/ukca@c372b36 True

Task Information

❌ failed tasks - 4
Task State
rose_ana_lfricinputs_lfric2um-nwp_gal9-C48L70_N48L70_azspice_gnu_fast-debug-64bit failed
rose_ana_lfricinputs_lfric2um-nwp_gal9-C48L70_N48L70_azspice_gnu_full-debug-64bit failed
rose_ana_lfricinputs_lfric2um-nwp_gal9-C48L70_N48L70_ex1a_gnu_fast-debug-64bit failed
rose_ana_lfricinputs_lfric2um-nwp_gal9-C48L70_N48L70_ex1a_gnu_full-debug-64bit failed
✅ succeeded tasks - 1311
⌛ waiting tasks - 2
Task State
housekeep_azspice waiting
housekeep_ex1a waiting

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

@mo-lottieturner Lottie Turner (mo-lottieturner) added the LFRic Inputs Changes by/affecting the LFRic Inputs project, including lfric2lfric, lfric2um, scintelapi, um2lfric label Feb 13, 2026
@mo-lottieturner

Copy link
Copy Markdown
Contributor Author

Currently the problem is that when handling pseudo-levels, it assumes that every level is its own 2d field rather than putting them all in the same field. How to get it to not do this is yet to be discovered

@mo-lottieturner Lottie Turner (mo-lottieturner) changed the title LFRic2UM pseudo-levels Multidata fields/pseudo-levels in LFRic2UM Apr 29, 2026
@mo-lottieturner Lottie Turner (mo-lottieturner) linked an issue May 1, 2026 that may be closed by this pull request
Lottie Turner (mo-lottieturner) added a commit to mo-lottieturner/lfric_apps that referenced this pull request Sep 29, 2026
@github-actions github-actions Bot added the cla-modified The CLA has been modified as part of this PR - added by GA label Oct 7, 2026
@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label Oct 13, 2026
Lottie Turner (mo-lottieturner) added a commit to mo-lottieturner/lfric_apps that referenced this pull request Oct 13, 2026

@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 lfric2UM code is just horrible. You're additions certainly don't make it any worse.

However, I think we could take the opportunity to improve the little bit we are changing here, so I've made some suggestions.

call log_event(log_scratch_space, LOG_LEVEL_DEBUG)

! set level heights to 0.0
! set level heights to 0.0 - potentially except bulev & bhulev?

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.

What does "potentially except bulev & bhulev?" mean. The appear to be set to 0.0 like all the other variables.

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.

In the source UM file, bulev and bhlev are set to the missing data indicator rather than 0.0 - I'm not sure if this is true for all UM files or not, hence the question mark. All the preset variable changes in this file have been separated out to #838 - I think this comment got left behind in the shift


! LFRic modules
use log_mod, only: log_event, LOG_LEVEL_INFO, LOG_LEVEL_ERROR
use log_mod, only: log_event, log_scratch_space, LOG_LEVEL_INFO, LOG_LEVEL_ERROR

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.

I don't think log_scratch_space is used anywhere in this routine - so it can be removed.

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.

Good point - removed. Also added a log message to the new section as there wasn't one

Comment on lines +246 to +263
if ( get_stashmaster_item(stashcode, pseudt) /= 0 ) then

if ( get_stashmaster_item(stashcode, pseudl) == 11 ) then
snow_level_number = ( (level_number + 2)/3 ) * 1000 &
+ (level_number - ((level_number + 2)/3 - 1)*3)
lookup_int(lbuser5) = snow_level_number
write(log_scratch_space, '(A,I0)') &
"Pseudo-level number set as ", snow_level_number
call log_event(log_scratch_space, LOG_LEVEL_INFO)

else
lookup_int(lbuser5) = level_number
write(log_scratch_space, '(A,I0)') &
"Pseudo-level number set as ", level_number
call log_event(log_scratch_space, LOG_LEVEL_INFO)
end if

end if

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.

I think this code needs a few comments. It would be useful to know what pseudt and pseudl are - and the calculation of snow_level_number just appears to be magic.

@mo-lottieturner Lottie Turner (mo-lottieturner) Oct 19, 2026 •

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.

pseudt and pseudl are both described in UM docs C04 as the rest of the "magic words" (bulev, lbuser5, etc) are described in UM docs F03. I think actually they should both be pseudt here - pseudt is the pseudo-level type and is 0 when the field is not a pseudolevel, whereas pseudl is the last pseudo-level code and is subtly different in ways I'm not sure I quite understand (but snow fields are 11 in both, which is the important bit here).

Calculation is pretty much magic - hopefully somewhat better explained by comment? I'm not sure I fully understand it (and have also just realised that this assumes that num_snow_layers is 3 which is true as far as I'm aware but probably best to not have hard coded!)

Lottie Turner (mo-lottieturner) added a commit to mo-lottieturner/lfric_apps that referenced this pull request Oct 20, 2026
@github-actions github-actions Bot added the cla-modified The CLA has been modified as part of this PR - added by GA label Oct 20, 2026
Lottie Turner (mo-lottieturner) added a commit to mo-lottieturner/lfric_apps that referenced this pull request Oct 20, 2026
Lottie Turner (mo-lottieturner) added a commit to mo-lottieturner/lfric_apps that referenced this pull request Oct 21, 2026
@mo-lottieturner

Copy link
Copy Markdown
Contributor Author

So I've realised that the snow layers read-in/calculation isn't quite correct, as some files can have 11 surface_tiles but still 27 snow_layers_and_tiles. Working on fixing

@mo-lottieturner

Copy link
Copy Markdown
Contributor Author

So I've realised that the snow layers read-in/calculation isn't quite correct, as some files can have 11 surface_tiles but still 27 snow_layers_and_tiles. Working on fixing

Not actually as big a problem as previously thought. Workaround to be used in #564, proper implementation to be done as and when we need 11 surface tiles in the UM output (tiles 10 and 11 are sea and sea-ice and are only used in LFRic)

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

I think these changes address the comments I made in my review. The code comments are now sufficient. The comments you added to the PR are actually a little more detailed and some of that detail could have gone in the code comments, but they are fine.

I'm happy for this to pass sci/tech review. Now it's on to Jenny Hickson (@jennyhickson) for code 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.

Looks sensible enough and conversations about the lovely lfric2um code and the magic formulas have been covered already.

@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label Oct 26, 2026
@jennyhickson
Jenny Hickson (jennyhickson) merged commit eaf115e into MetOffice:main Oct 26, 2026
4 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 LFRic Inputs Changes by/affecting the LFRic Inputs project, including lfric2lfric, lfric2um, scintelapi, um2lfric

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LFRic2UM pseudo-levels

3 participants