Skip to content

PPM option limiter = "hord12": FV3's hord = 12 tracer reconstruction - #183

Merged
cfranken merged 2 commits into
RemoteSensingTools:mainfrom
pera-noaa:hord12-limiter
Nov 28, 2026
Merged

cfranken merged 2 commits into
RemoteSensingTools:mainfrom
pera-noaa:hord12-limiter

Conversation

@pera-noaa

Copy link
Copy Markdown
Contributor

Adds [advection] scheme = "ppm", limiter = "hord12" (PPMScheme(Hord12Limiter())): the horizontal tracer PPM of FV3's xppm/yppm with hord = 12, GCHP's hord_tr default. It keeps the CW84 edges and swept-parabola flux and replaces the profile limiter by Lin's form of Huynh's second constraint (GCHP fork tp_core.F90:556-575, commit 643f3c44). With vertical = "fv3_kord8" it is GCHP's hord_tr = 12 / kord_tr = 8 pair in split sweeps. Lat-lon and cubed sphere, CPU and GPU, same stencil and halo; forward only (the inversion driver rejects it).

Two interface changes on top of #179: limited_slope, limited_moment and ppm_limit_profile fall back to MonotoneLimiter behaviour on AbstractLimiter (a missing method was a MethodError inside the kernel), and ppm_limit_profile gets a five-argument form with the donor's neighbours. Built-in limiters are bitwise unchanged.

Why. It moves AT's cross-tropopause exchange to where Lin–Rood ORD 7 puts it, the scheme the CATRINE protocol notes as closest to GCHP above 100 hPa. C90 L72 MERRA-2, Dec 2021–Mar 2022, pulses at 0.07 ps (strat) and 0.2 ps (UT), fraction above 100 hPa minus ORD 7:

default PPM hord12
strat pulse, global, day 28 / 112 +0.0038 / +0.0036 +0.0001 / +0.0010
UT pulse entering, global, day 112 −1.0 % +0.6 %

At 30–60°N hord12 drifts back toward the default by March. In a C24 age-of-air test the default PPM is 15 d older than hord12 above 100 hPa after two years.

Caveat. "hord 12" depends on the FV3 line: in NOAA-GFDL main and GEOS-ESM this branch is iord == 10, and 12 is the LR96 positive-definite scheme. Hord12Limiter follows the GCHP fork; the docstring says so.

Tests. New test/core/test_ppm_hord12_limiter.jl (hand-computed FV3 profiles, a loop transcription of xppm to 1e-14, positivity, conservation, convergence); hord12 added to the advection-kernel and cubed-sphere loops. Orion CPU, on 85e91b1d: the 9 touched test files pass (hord12 limiter 143/143); main vs branch digests for every built-in scheme (LL 6 + CS 3, Float32/Float64): byte-identical, 18/18 lines; check_structure.jl passes with the code map regenerated. Not run: GPU, full suite.

Questions. (1) Keep the name, or FV3HuynhLimiter with a "hord12" alias? (2) Should hord12 with vertical = "same_as_horizontal" require fv3_kord8 on the cubed sphere? (3) Are the silent monotone fallbacks wanted?

🤖 Generated with Claude Code

@cfranken cfranken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, this is a clean addition and fits the design: the limiter is a type selected by dispatch, it builds on the public limiter functions from #179, the stencil and halo stay the same, and the inversion driver refuses it explicitly.

Checked

  • The Huynh constraint matches the pinned GCHP tp_core.F90 (xppm): both clamps, the ¾ factor, the curvature test and the 1e-25 flattening (Float32-safe). Derived independently, not from the comments.
  • Every PPM face flux (x, y, z; cubed-sphere seams, packed tracers, same_as_horizontal vertical) passes the neighbour tuple in the right order; no path falls back to the 4-argument form for hord12.
  • test_ppm_hord12_limiter.jl (143/143) and test_advection_kernels.jl pass on CPU. The Float32 kernel code compiles branch-free with no allocation. Not run: GPU.

Must fix: the positivity claim. The docstring and advection_schemes.md say the constraint keeps a non-negative tracer non-negative in 1-D uniform flow up to Courant 1. Counterexample: periodic row, unit air masses, means [0, 1, 1/8, 0, 1, 0], mass flux 0.5 to the right. After one sweep the fourth cell is −7/96 (the third cell exports −1/96, the fourth 1/16), in Float32 and Float64, reproduced with an independent implementation of the formula. This is FV3's own behaviour: in the GCHP fork only hord 9 and 13 add the positivity filter. It matters for zero-background tracers (Rn-222, pulses, flux anomalies), not for CO₂ on a 400 ppm background.

Design: no silent AbstractLimiter fallbacks (your question 3).

  • They can break limiters defined elsewhere: an external limited_slope(::Float32, ::Float32, ::Float32, limiter) method that resolved before is now ambiguous.
  • They hide mistakes: a missing method silently becomes van Leer/CW84 (limited_slope(…, CW84Limiter()) now returns a value instead of an error). We prefer explicit errors for unsupported combinations.
  • Suggested instead: keep explicit methods, give the new limiter its own one-line limited_moment, and make the 4-argument ppm_limit_profile for it throw instead of using CW84.

Smaller points

  • Name (question 1): since "hord 12" means different schemes in different FV3 lines, name the type after the method (FV3HuynhLimiter) and keep limiter = "hord12" as the config value GCHP users know.
  • Question 2: no need to force fv3_kord8; document that GCHP pairs hord 12 with kord 8.
  • Optional, later: the closed union of limiters that use van Leer edges and the swept-parabola flux could become a trait, so a limiter defined outside the package can opt in.
  • Before merging: a short GPU run with the new limiter and a GPU speed check of the built-in PPM (it now passes four extra neighbour values).

I'll push these changes onto this branch (maintainer edits are on) and merge once CI and the GPU checks pass.

…sitivity docs

- Rename Hord12Limiter -> FV3HuynhLimiter ("hord 12" names different schemes in
  different FV3 lines); the config value stays limiter = "hord12".
- Remove the AbstractLimiter fallbacks of limited_slope, limited_moment and the
  three-value ppm_limit_profile: a missing method stays a MethodError instead of
  silently becoming the monotone rule, and external scalar-typed methods no
  longer become ambiguous. FV3HuynhLimiter gets its own limited_moment (no
  clamp); its three-value ppm_limit_profile throws, since the constraint needs
  the neighbours. The five-argument form still forwards to a limiter's
  three-value method.
- Docs and CHANGELOG: the FV3 Huynh constraint is neither monotone nor
  positive-definite (cell means [0, 1, 1/8, 0, 1, 0], Courant 0.5: a zero cell
  becomes -7/96; GCHP adds a filter only for hord 9 and 13). New regression test.

Checks: touched test files pass on CPU; advection kernel tests pass on the L40S
(CPU-GPU agreement incl. the new limiter); structure check passes, code map
regenerated; C90 L72 4-tracer GPU benchmark: built-in PPM and upwind unchanged
(0.0494-0.0495 s and 0.0451-0.0452 s per window on main and this branch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qfkez3tXkdGpzp8H8U6PPz
@pera-noaa

Copy link
Copy Markdown
Contributor Author

Thanks, you're right about positivity: by hand from the test's xppm transcription, cell 4 ends at −7/96. My ring test only tried a step and a cosine bell. The wording and regression test in c2410bad look right to me.

Since the C90 pulses start from zero, I checked the table above. Over all 113 days, hord12's negative mass is at most 9e-5 of the strat pulse and 2.7e-4 of the UT pulse, no more than the default PPM and a tenth of ORD 7. Zeroing negatives moves no table entry by more than 1e-5, so the numbers stand.

I agree with the rest: the FV3HuynhLimiter name, explicit errors instead of fallbacks, and documenting the kord 8 pairing.

@codecov

codecov Bot commented Nov 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.66%. Comparing base (85e91b1) to head (c2410ba).

Files with missing lines Patch % Lines
src/Models/Runner/DrivenRunner/summary.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #183   +/-   ##
=======================================
  Coverage   88.66%   88.66%           
=======================================
  Files         342      342           
  Lines       37185    37210   +25     
=======================================
+ Hits        32970    32993   +23     
- Misses       4215     4217    +2     
Files with missing lines Coverage Δ
src/Models/Physics/RuntimePhysicsMetadata.jl 71.42% <100.00%> (+0.41%) ⬆️
src/Models/Physics/RuntimePhysicsSpecs.jl 92.45% <ø> (ø)
src/Models/Runner/DrivenRunner/DrivenRunner.jl 95.08% <ø> (ø)
...erators/Advection/Reconstruction/reconstruction.jl 98.78% <100.00%> (+0.11%) ⬆️
src/Operators/Advection/Reconstruction/schemes.jl 83.87% <100.00%> (+1.11%) ⬆️
src/Models/Runner/DrivenRunner/summary.jl 68.57% <0.00%> (-2.02%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cfranken
cfranken merged commit 0890187 into RemoteSensingTools:main Nov 28, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants