Skip to content

Multidata fields/pseudo-levels in LFRic2UM - #266

Open
Lottie Turner (mo-lottieturner) wants to merge 45 commits into
MetOffice:mainfrom
mo-lottieturner:lfric2um_pseudL
Open

Lottie Turner (mo-lottieturner) wants to merge 45 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

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
Comment thread applications/lfricinputs/source/lfric2um/lfric2um_main_loop_mod.f90 Outdated
@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
@github-actions github-actions Bot added the cla-modified The CLA has been modified as part of this PR - added by GA label Sep 28, 2026
@github-actions github-actions Bot removed the cla-modified The CLA has been modified as part of this PR - added by GA label Sep 29, 2026
@mo-lottieturner Lottie Turner (mo-lottieturner) added the KGO This PR contains changes to KGO label Sep 29, 2026
@mo-lottieturner
Lottie Turner (mo-lottieturner) marked this pull request as ready for review September 29, 2026 09:20
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
@github-actions

Copy link
Copy Markdown

⚠️ Hello Lottie Turner (@mo-lottieturner)!

Your CLA signature was found on the base branch, but you appear to have modified the CONTRIBUTORS.md file in this PR.

Please do not edit the CONTRIBUTORS.md file. If you have already signed the CLA, revert changes to the file and your signature will be picked up.

Lottie Turner (mo-lottieturner) added a commit to mo-lottieturner/lfric_apps that referenced this pull request Oct 20, 2026

This branch has not been deployed

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

Labels

cla-modified The CLA has been modified as part of this PR - added by GA 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