Diagnostics required by lfric2um for PS49 - #658
Conversation
|
Just going to grab this back as a few more have cropped up that make sense to add here |
Adds surface__sea_heat_flux and surface__sea_moisture_flux, equivalent to UM STASH 3-228 SFC SH FLX FROM OPEN SEA:SEA MN and 3-232 EVAP FROM OPEN SEA: SEA MEAN. This is an XML-only change. The open-sea tile is extracted from the existing surface__tile_heat_flux and surface__tile_moisture_flux fields using the surface_tiles_sea_zoom axis, then the pseudo-level coordinate is dropped, following the pattern already used for surface__sea_tile and surface__sea_temperature. A third field is then needed for each because the UM diagnostics are sea means. JULES applies h_sea = (1 - ice_fract) * h_sea and the equivalent for e_sea in the "Calculate sea mean diagnostics" block of jules_ssi_sf_implicit, so the flux is averaged over the whole sea portion of the grid-box with the sea-ice part contributing zero. The LFRic tiled fluxes are per unit open water, being formed as a residual divided by the open-sea tile fraction, so they are multiplied by (1 - surface__sea_ice_fraction) to match. The rescaling cannot be combined with the earlier steps as it needs both operands on the same grid. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
Adds seaice__sea_mean_topmelt_heat_flux, equivalent to UM STASH 3-235 SEAICE TOP MELT LH FLX:SEA MEAN. Unlike the open sea flux diagnostics this cannot be done in XML alone. The UM sums sf_diag%sice_mlt_htf over the sea-ice categories, but LFRic never sets sf_diag%simlt so that array is never filled. The underlying melt rate is available though, as fluxes%sice_melt is copied onto the sea-ice tiles of snowice_melt in jules_imp_kernel_mod, so the diagnostic is reconstructed from there. Averaging over the tiles has to be done in the code rather than in XIOS, following the precedent set for surface__sea_ice_tile. The tile order is land, sea, sea-ice, so averaging the tiled melt rate over the sea and sea-ice tiles, weighted by their fractions, divides by the marine fraction of the grid-box. This gives the ice_fract_ncat weighting the UM applies in jules_ssi_sf_implicit directly, with no rescaling needed in XML, because jules_imp_kernel_mod sets the melt rate on the sea tile to zero and so only the sea-ice contributes to the sum. The latent heat of fusion then converts the melt rate to an energy flux. Note this covers only the surface melt contribution. The second term the UM accumulates in sice_htf, where the ice surface temperature overshoots the melting point, has no LFRic equivalent as sice_htf is never called. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
Adds surface__land_mean_heat_flux and surface__land_mean_latent_heat, the surface sensible and latent heat fluxes averaged over the land portion of the grid-box, matching the UM's land-mean surface flux diagnostics. Both are computed with weighted_ave_kernel_type over the land tiles, weighted by the grid-box tile fractions. Because the land tile fractions sum to the land fraction, that average divides by the land fraction and so reproduces the UM sum over land tiles of the tiled flux weighted by the land-relative tile fraction: LFRic's tile_fraction is a grid-box fraction, and the JULES interface divides it by the land fraction when it fills frac_surft. The tiled fields used are the same ones the UM sums, ftl_surft and le_surft. The latent heat flux is only accumulated when it has been requested, so the new diagnostic is added to the existing test that activates it, and both diagnostics are output on the second loop only, alongside the other tile-averaged diagnostics. The two fields are added to the lfric_atm field definitions and to the hourly instantaneous group of the operational global output stream, alongside the other grid-mean surface fluxes there. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
Adds surface__ssi_mean_heat_flux and surface__ssi_mean_latent_heat, the surface sensible and latent heat fluxes averaged over the sea and sea-ice portion of the grid-box, matching the UM's mean sea surface sensible heat flux and its open sea and sea-ice latent heat flux. Both are computed with weighted_ave_kernel_type over the sea and sea-ice tiles, weighted by the grid-box tile fractions. The tile order is land, sea, sea-ice, so those tiles are contiguous, and because their fractions sum to the marine fraction the average divides by it and so gives a mean over the marine portion of the grid-box. For the sensible heat flux this reproduces the UM residual, the grid-box mean flux less the land contribution divided by the marine fraction, because the interface fills the sea tile with exactly the residual needed to make the tile fractions and tiled fluxes recover the grid-box mean. For the latent heat flux it reproduces the UM sum of the sea-mean evaporation and sea-ice sublimation terms, since JULES rescales those by fractions of the sea whereas the tile fractions here are fractions of the grid-box. The two fields are added to the lfric_atm field definitions and to the hourly instantaneous group of the operational global output stream, alongside the land means. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
The diagnostics that average over the marine portion of the grid-box each worked out the number of sea plus sea-ice tiles for themselves. Derive it once as n_ssi_tile in jules_control_init, alongside the other tile counts and indices, and use it from jules_imp_diags and jules_seaice_diags. n_surf_tile is now expressed in terms of it as well, so the two counts cannot drift apart. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
The sea tile of z0m_tile is filled from the JULES prognostic z0msea in jules_exp_kernel_mod, so extracting it needs no new code: a zoom onto the sea tile in the XML gives the open sea roughness length directly. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
|
Martin Best (@mo-martinbest) this is good to go again now - just added a couple more diagnostics in the same vein as the rest (sea-mean and land-mean fluxes) |
Adds seaice__ice_mean_thickness and seaice__ice_mean_temperature, the sea-ice thickness and bulk temperature aggregated from the categories onto a single level, matching the UM's sea-ice depth and sea-ice temperature after timestep. Those two UM fields are the non-category twins of the by-category thickness and top layer temperature, and are what the UM uses when only one category is active. Both are formed with weighted_ave_kernel_type over the sea-ice categories, weighted by the category fractions, so the kernel divides by the total ice fraction and returns a mean over the ice. For the temperature this is exactly the bulk temperature that sice_htf forms internally, which is otherwise held only in the JULES prognostic structure and so cannot be output. For the thickness the same average is correct because the category thicknesses are physical depths, as their use in the conduction term of sice_htf shows, rather than fraction weighted quantities. The weights are the sea-ice tile fractions already extracted from the tile fractions for seaice__sea_ice_fraction. These are fractions of the grid-box whereas JULES works in fractions of the marine portion, but the normalisation cancels in the ratio so the result is unchanged. Where there is no ice the total weight is zero, the kernel leaves the output at zero, and both fields should be masked on the ice fraction before use. Some of the content of this change has been produced with the assistance of Anthropic Claude Opus 5 (Claude Code).
|
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. |
Martin Best (mo-martinbest)
left a comment
There was a problem hiding this comment.
This all looks fine to me in with regards tot he Sci review.
Matthew Hambley (@MatthewHambley) passing to you for code review.
Matthew Hambley (MatthewHambley)
left a comment
There was a problem hiding this comment.
I'm afraid this change does not comply with the LLM policy Not only has an invalid LLM potentially been used but each commit which includes LLM generated code needs to acknowledge that, which I don't see.
This is likely to be time consuming. Files modified by invalid models need to be redeveloped and the branch will need to be restructured with correct attribution in commit messages. This latter point may break the pull request, requiring this one to be closed and a fresh one to be opened.
Hi Matthew Hambley (@MatthewHambley) - Yaswant Pradhan (@yaswant) was consulted in advance of starting this work, as we're making use of Claude to accelerate work on a large backlog of diagnostics needed for PS49. The wording in the file headers is what we agreed upon, and the LLM policy is in need of an update to show that this is an acceptable usage. Additionally, each commit by Claude is clearly identifiable as a different author to myself. |
|
Matthew Hambley (@MatthewHambley) just noticed #679 - this PR does comply with everything in the modified template (but we've no need to wait for #679 before progressing this). Thanks! |
PR Summary
Sci/Tech Reviewer: Martin Best (@mo-martinbest)
Code Reviewer: Matthew Hambley (@MatthewHambley)
This change add the following diagnostics that have been requested by lfric2um for driving the UKV & Mogreps-UK at PS49, and other downstream uses from PS49 itself:
We have also fixed the calucation of stash 31 / surface__sea_ice_fraction and 505 / surface__land_fraction to be correct for coupled models with 5 sea-ice categories (previously these were only correct for a single sea-ice category)
ecb42cc has been tagged as tag3.1_new_diags for use at vn3.1
Some example output of the new diagnostics to prove they work:













Code Quality Checklist
Testing
trac.log
Test Suite Results - lfric_apps - new_diags/run3
Suite Information
Task Information
✅ succeeded tasks - 1213
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review