TM5-style spectral mass fluxes
This page specifies TM5SpectralFluxes, a second construction of the ERA5 spectral mass fluxes for lat-lon (LL), reduced-Gaussian (RG) and direct cubed-sphere (CS) targets. It follows the TM5 meteorological preprocessor (tmm): the face fluxes are quadratures of the retained spectral winds and surface pressure along the target faces, an independent vertical flux is integrated from the spectral divergence, and the horizontal fluxes are balanced layer by layer against the hybrid mass tendency. The existing construction (face- and centre-sampled winds times a face pressure thickness, see ERA5 spectral path) stays the default; the design calls it PointSampledSpectralFluxes.
LL and RG are implemented by TM5-FLUX-1; direct CS is implemented by TM5-FLUX-2b. The point-sampled construction stays the default. Select the new route explicitly:
[preprocessing]
spectral_flux_construction = "tm5_spectral"
spectral_synthesis = "cpu" # reference; omit for GPU (CLI loads CUDA)
# spectral_synthesis_float = "auto" # GPU: auto, Float64 or Float32
# face_quadrature = "gauss_fourier" # LL/RG default
# To select TM5 trapezoids instead:
# face_quadrature = "tm5_trapezoid"
# quadrature_refinement_steps = 2
[numerics]
flux_time_sampling = "window_mean"The selector is spectral_flux_construction, since the existing flux_construction settings describe the face-method family. Existing configs keep their interpretation and default arithmetic. The new route requires a global target, the hourly ERA5 interval and dry basis, a next-day 00 UTC spectral and humidity endpoint, and retained native interfaces (echlevs or layer merging). Pressure-overlap vertical remapping is outside this construction. The hybrid-B extent must run from 0 to 1, with level_top=1 and zero top A. These contracts are checked during configuration planning, before reading meteorology. GPU selection on the legacy point-sampled route is rejected explicitly; its opt-in is deferred.
The page follows the design of 2026-10-30 with the owner answers of that day. Statements marked estimate are estimates, not measurements.
Sources
TM5 citations are file:line in the NOAA CarbonTracker TM5 repository (ct-unified-github at commit 2d60209); pydyn citations are at pydyn commit 0db6e6d. pydyn is a NumPy transcription of the TM5 dynamic core; it starts from the TM5 meteorological archive and has no spectral stage.
| Abbreviation | Repository path |
|---|---|
gts | base/trunk/src/grid_type_sh.F90 |
gi | base/trunk/src/grid_interpol.F90 |
tmm | base/trunk/src/tmm.F90 |
met | base/trunk/src/meteo.F90 (the ct-unified overlay proj/ct-unified/trunk/src/meteo__pclim.F90 carries the same Meteo_Setup_Mass) |
adv | base/trunk/src/advect.F90 |
GTS | proj/ct-unified/branches/speedup/src/grid_type_ll__speedup.F90 |
g3d | base/trunk/src/grid_3d.F90 |
hyb | base/trunk/src/grid_type_hyb.F90 |
binas | base/trunk/src/binas.F90 |
mdat | proj/ct-unified/trunk/src/meteodata__pclim.F90 |
acfl | proj/ct-unified/trunk/src/advectm_cfl.F90 |
| pydyn | pydyn/balance.py, pydyn/kernels.py, pydyn/forward.py |
Conventions
Longitude
, latitude , , m s⁻². is the radius of the target mesh ( EARTH_RADIUS = 6.371e6m, equal to TM5'sae,binas:51); it sets face lengths and cell areas.is the vod2uvradius that entersand (§2). TM5 uses = ae; after owner decision Q4 the two differ.Layers count from the top (
) to the surface ( ); interface is the top of layer , so interfaces run . Hybrid interfaces are , with and . TM5's FillMassChangetakesabs(db)(g3d:366), so the sign convention ofdoes not matter there. (the spectral LNSP field). Fluxes , and the vertical flux are rates in kg s⁻¹ integrated over the whole face. Raw is upward-positive; our stored cmis downward-positive.TM5 and pydyn arrays are bottom-up. Every reference comparison goes through one explicit level-order and sign adapter.
1. Truncation, refinement and ring evaluation
Retained truncation. TM5 keeps the source truncation: ShTruncation = T (gi:1587). For ERA5 this is TL639. The existing route synthesises at the target truncation (target_spectral_truncation,
LL/RG face integration. face_quadrature = "gauss_fourier" is the TM5SpectralFluxes default. Gauss–Legendre nodes integrate
For a latitude width
Explicit TM5 trapezoids. face_quadrature = "tm5_trapezoid" selects the previous LL/RG integration, with quadrature_refinement_steps = 2 by default:
TM5 uses 2 despite comments saying "5 points per sh resolution" (gi:1602–1630,1677,1822,2458). A 1° edge has 3 subdivisions at T255 and 8 at T639. The refinement-16 proposal was rejected on cost. The explicit rule retains our existing open polar policy and complete wind transform; it does not restore TM5's other numerical errors. CS keeps its established cardinal-16 arc integration and refinement 2 (§10); this selector changes LL/RG coordinate faces.
Oversampled rings. For gts:1687–1692, gts:1731). The existing fill_ring_spectrum! (src/Preprocessing/Spectral/spectral_synthesis.jl) already supports this: on a buffer of length ring_max_wavenumber(T, J) = T, so every retained zonal wavenumber is synthesised. The unnormalised bfft is kept.
Legendre corner. TM5 sets gts:713, gts:829–830). compute_legendre_column! evaluates it; this is a documented difference (§13).
CPU cost and golden cases. See §13 for complete changing-hour window measurements, memory and the golden decision. The former refinement-16 proposal cost 6.08× at T255 and 17.10× at T639 (2,577 s/window) and was replaced by Gauss/Fourier integration.
2. Vorticity and divergence to pseudo-winds
With
(gts:2037, gts:2042), the spectral coefficients of
(gts:1837–1849). TM5's shi_vod2uv treats the truncation edge as follows:
| Row | TM5 (gts:1949–2045) |
|---|---|
upper-neighbour term only (gts:1993–1994) | |
upper neighbour gts:2013–2014) | |
the gts:1996–1997) | |
lower neighbour only: the gts:2021–2022) | |
zero (gts:2030–2031) |
The source gives EMOS compatibility as the reason (vorticity and divergence assumed truncated at gts:1851–1852). For ae, 6.371 × 10⁶ m (gts:1951).
Ours is the existing vod2uv! (src/Preprocessing/Spectral/spectral_synthesis.jl): it keeps every neighbour term inside IFS_EARTH_RADIUS, 6.371229 × 10⁶ m, for
Remaining truncation. For vorticity and divergence truncated at vod2uv! drop this row. The new construction's complete_wind_coefficients retains it, using the existing transform within
3. Cell surface pressure: the discrete rule
TM5 evaluates gi:1893), integrates each refined row with piecewise-linear interval quadrature in IntervalQuad_Lin, gi:1907), integrates the row results with cosine-weighted linear quadrature in IntervalQuad_Cos_Lin, gi:1926) and divides by the cell area (key 'exp,aver', tmm:1876). The cell value tm5_trapezoid retains this rule. The default gauss_fourier instead integrates the sampled exponential with Fourier longitude intervals and Gauss latitude weights times
4. Horizontal face fluxes per native layer
For a meridional face at
(tmm:2135–2138, tmm:2167–2170; integrands gi:3429 and gi:3784; units kg s⁻¹, tmm:1966). Native-layer fluxes are summed into the retained layers (FillLevels(..., 'sum'), tmm:2147, tmm:2179). The product of a mean wind and a mean face thickness is not this integral: the covariance of wind and surface pressure along the face matters. TM5 also integrates face surface pressures (spu, spv, tmm:2142, tmm:2174); the plan does not need them.
Poles. TM5's IntLon gives zero meridional flux at either pole (gi:3781–3782); ours does the same. TM5 has two polar-row quirks:
IntLatsets the pole sample to the sum of the adjacent row divided bysize(llf, 1). That row holds theface longitudes , so TM5 divides by and counts the periodic face twice ( gi:3373,gi:3396,gi:3444).IntArea_shi_ll_fghuses the adjacent-row mean at the pole even for theintegrand, which is zero there ( gi:2498–2511,gi:2588–2593).
The construction uses open (pole-free) quadrature nodes in the polar rows instead; the difference is listed in §13.
5. Independent vertical flux
Per native layer, TM5 integrates the horizontal mass divergence directly from the spectral fields. With the two radii of the conventions, the implemented form is
with tmm:2428, tmm:2446, tmm:2450, combined at tmm:2468). TM5 writes the first factor as tmm:2468) because it has
is the upward vertical mass flux at interface tmm:2466–2473, tmm:2517, tmm:2522; TM5 forms tmm:2568). It satisfies the hybrid layer budget FillLevels (call at tmm:2558) chooses the fill mode 'combine' when the target levels are a selection of the source levels (hyb:1050–1058, hyb:2408–2420). The key 'bottom' passed at tmm:2558 is used only by the 'interpol' mode (hyb:2436–2438).
Spectral gradient. For
from gts:1788–1795). The same comment states the gts:1794), but the executable branch computes gts:1804): a sign error. TM5 also truncates the gradient at degree tmm:2450).
TM5 also computes the surface-pressure tendency tsp (tmm:2499–2507). Only the PRISM coupling path consumes it (met:1645–1718), so the plan does not build it.
6. Per-layer balance
TM5 balances each layer's horizontal fluxes against the hybrid mass tendency of the window
(FillMassChange, g3d:366; met:1798, met:1811). The layer residual is GTS:2666–2669, written here top-down). The horizontal target is therefore
using the met:1921–1924, met:2033–2036).
LL solver. Per level, TM5 solves a periodic five-point index-space Poisson problem by FFT: eigenvalues GTS:3028), zero mode removed (GTS:3031, GTS:3166), then the west and south gauges are subtracted so the outer faces stay closed (GTS:3172–3192). The per-layer global-mean residual is left uncorrected; it cancels in the column sum. pydyn transcribes this solve (pydyn/balance.py:183–201). Our dry-pin route first makes the target solvable: for cell c, solve against
CS solver. The direct target uses the same DirectCSPoisson factors a pinned principal minor of the global degree-four graph Laplacian once per serial run and reuses it for both endpoint sets, every layer and every window. Corrections update canonical and mirror entries with the face table's seam signs. This is TM5's layer equation on our CS graph, rather than TM5's periodic FFT five-point solver. The existing CS PCG endpoint target keeps its historical arithmetic through a neutral target-functor split.
A one-thread CPU synthetic solver benchmark gives the following stage times (68 right-hand sides, graph built independently of meteorology):
| Grid | Cells | Factorization | 68 direct solves | One PCG solve |
|---|---|---|---|---|
| C90 | 48,600 | 1.01 s | 0.46 s | 0.30 s (705 iterations) |
| C180 | 194,400 | 0.72 s | 1.56 s | 1.59 s (1433 iterations) |
The first factorization includes compilation. Process peak RSS was 0.77 GB at C90 and 1.06 GB after C180; these are process peaks, not factor sizes. The smooth synthetic RHS leaves maximum relative direct residuals
Guards. CheckMassBalance compares the column convergence with the surface-pressure tendency, relative to the mean surface pressure [s⁻¹] (GTS:2864–2936):
| Stage | rms limit | max limit | On failure |
|---|---|---|---|
| pre-check | abort (met:1893–1894, met:1901–1903) | ||
| post-check | repeat the balance, up to MB_MAX_TRIES = 3 passes (met:1445, met:1917–1920), then abort (met:1943–1946, met:2055–2058) |
These are repeated Poisson passes, not Richardson extrapolation. pydyn raises on the pre-check (pydyn/balance.py:211) but returns ok = False after the third failed post-check (pydyn/balance.py:212–218), and its forward driver ignores the flag (pydyn/forward.py:134). The construction follows the Fortran and raises an error.
Known difference. The existing balance_mass_fluxes! (src/Preprocessing/Spectral/mass_support.jl) skips a level whose largest absolute residual is below
7. Vertical closure and the explicit-dm identity
TM5 interpolates the balanced mdat:760, mdat:879; base meteodata.F90:764, :773) and calls dynam0. In bottom-up indexing with adv:210), it forms
upward at the upper face of layer adv:241–256, adv:265–266, adv:290), with adv:274, adv:282). The archived vertical flux is not advected. The IO-server B-pivot is disabled in this TM5 version (b_pivot_active = .false., "TODO #332 B-pivot REVERT", acfl:928–938). pydyn transcribes dynam0 as fluxes_from_meteo (pydyn/kernels.py:89–112).
Identity. The existing explicit-dm closure recompute_cm_from_dm_target! (src/MetDrivers/ReplayContinuity.jl) integrates
which is TM5's cm, with no assumption about the column residual. TM5's sd also sums from the top (adv:253–256); the two differ only in where recompute_cm_from_dm_target! folds it back over the column. With the endpoint recompute_cm_from_divergence! is already the
8. Pipeline on LL, RG and CS targets
E marks a shared existing function, N a new implemented function.
| # | Stage | Functions | Home |
|---|---|---|---|
| 1 | Read one hour at a time and the next day's hour 00 | with_spectral_hours, read_hour0_spectral, validate_spectral_header; ecCodes indexes and per-hour caches. Full source truncation. Next-day 00 is required. | Spectral/spectral_hour_io.jl |
| 2 | Humidity on native levels | E read_window_qv! (LL), load_rg_qv! (RG), unchanged | Targets/ |
| 3 | Ring evaluation | RingSynthesisPlan, synthesize_rings, synthesize_native_fields, complete_wind_coefficients, lnsp_gradient; batched GEMM and oversized inverse FFT | Spectral/ |
| 4 | Cell PS, face fluxes, | N integrate_surface_pressure!, integrate_face_fluxes!, integrate_vertical_flux!; LL boxes, RG per-ring boxes and LCM face segments (§10) | Spectral/spectral_integral_fluxes.jl |
| 5 | Dry pin on the integrated PS, fluxes not recomputed (Q1) | E pin_global_mean_ps_using_qv! | Spectral/mass_support.jl |
| 6 | Moist masses from the pinned PS | construct_tm5_endpoint: area × (ΔA+ΔB PS)/g | Spectral/tm5_endpoint.jl |
| 7 | Target levels | TM5EndpointPlan prepares plan_vertical once per day; apply_vertical! with MassField and MassFluxField sums; N InterfaceMassFluxField (selects retained interfaces with the body of ConvectionInterfaceFlux); E merge_qv! weighted by the pinned moist masses. The NOAA levels are ml137_tropo34a, not ml137_tropo34. | Vertical/, Spectral/ |
| 8 | Per window: balance both endpoint sets against the window's | balance_window_layers!, balance_tm5_layers!; LL balance_mass_fluxes!, RG balance_compressed_level! with reused DirectRingPoisson; guards and up to three passes | Targets/, MassClosure/ |
| 9 | Dry carrier on target layers, for each balanced endpoint set with its own instant's | dry_target_fluxes!; LL reuses apply_dry_basis_native!, RG uses arithmetic face humidity | Targets/ |
| 10 | Window flux: mean of the two dry endpoint sets (Q2) | balance_window_layers! | Targets/LatLon/tm5_layer_balance.jl |
| 11 | Substep schedule, amounts, column balance, cm, replay gates | E schedule; amounts via MetDrivers.flux_application_seconds; apply_poisson_balance! → balance_column_mass_fluxes! (LL), balance_compressed_column_fluxes! (RG); recompute_cm_from_dm_target! with the dry endpoint | Targets/, MassClosure/, MetDrivers/ |
| 12 | Write | E writers; version-5 header with the construction identity | TransportBinary/, MetDrivers/BinaryFormat/ |
For CS, Spectral/cs_spectral_integrals.jl implements stages 3–4 on regular cell-centred rings without pole nodes. The CS target prepares the shared cs_spectral_face_geometry scalar stencils, face normals and conservative box overlaps once, then supplies them to Spectral without a reverse dependency on MassClosure. CSSpectralIntegralWorkspace applies face and overlap maps on the synthesis backend with portable KernelAbstractions gathers. Refined three-dimensional samples remain there through integration; completed reduced target fields return at the endpoint boundary. CPU surface PS uses Float64; GPU surfaces and three-dimensional kernels follow the selected synthesis precision with typed constants, without Float64 promotion in Float32 kernels.
Targets/CubedSphere/tm5_spectral_day.jl orchestrates the shared post-integral pin and moist merge, per-layer CS balance, adjacent-cell face humidity, endpoint drying and mean. Final dry amounts use the existing CS column balance, diagnose_balanced_cs_cm!, replay and positivity contracts and streaming writer. After residual booking, the direct CS route explicitly zeros the rounded surface-interface remainder before replay, enforcing the closed physical boundary. Positivity retries rebuild amounts from pristine dry rates. The mandatory next-day endpoint closes the final window; no held-endpoint fallback is used. The optional live Calc_Kzz group is assembled through the shared CS PBL writer. Two moist endpoints and one output window are retained.
CS writes TM5SpectralFluxesHeader with unchanged v5 identity fields and no new payload sections. Ordinary provenance keys are cs_face_quadrature = "great_circle_midpoint_cardinal16_v2", samples_per_face, refined_nlon, refined_nlat and cs_cell_quadrature = "conservative_refined_box_mean_v1", plus the actual synthesis backend/precision. Existing v5 LL/RG files require no new keys.
Folders are under src/Preprocessing/ unless they start with MetDrivers/. The order differs on purpose from the existing route:
Existing route: pin → recompute fluxes → dry conversion on native levels → merge → column balance →
cm.TM5 route: moist integration → pin (no recompute) → moist merge → moist per-layer balance with
→ dry conversion of each endpoint set on target layers → window mean → shared dry column balance and closure.
Substep retries. The balanced moist rates [kg s⁻¹] do not depend on the substep schedule, so a positivity-driven retry recomputes only stage 11 from the stored rates; no field already balanced in amount units is rescaled. This is the rule of the cubed-sphere spectral writer (src/Preprocessing/Targets/CubedSphere/cubed_sphere_spectral.jl).
Memory. Both targets decode one spectral hour at a time with ecCodes indexes; the optional decoded cache contains one hour per JLD2 file. The next-day reader also reads only hour 00. Constructed endpoints retain merged PS, mass, humidity, face rates and W, without native C. Only two endpoints survive at a time. RG closes and writes each window immediately. LL closes each window and keeps one completed lookahead window to form the historical delta payload; it retains neither a day of outputs nor a day of pristine rates. Synthesis batches bound the refined-grid field buffers. Surface and 3-D plans share Legendre tables when their precision matches; duplicate face rings share their synthesis. The coefficient working set at T639/L137 is approximately 1.80 GB per hour, plus the required next-day hour (3.60 GB combined), versus 43.25 GB for the previous 24-hour source allocation alone. These decimal sizes exclude plans, quadrature and target buffers. The handoff records the CPU measured extrapolation.
9. Mass consistency under the dry pin
TM5 matches the area mean of the total surface pressure to p_global = 98500 Pa by an additive offset (binas:133; met:1535–1537, met:1764–1766; the offset is added uniformly at GTS:1107–1115). We keep our dry pin, pin_global_mean_ps_using_qv!, which shifts the surface pressure additively so that the global dry mass implied by the native humidity equals GLOBAL_MEAN_DRY_SURFACE_PRESSURE (98325 Pa).
No normalisation factor is needed. Pin the integrated PS with the same native
that is merged later, then merge with the pinned moist masses; merge_qv!preservesexactly. Together, on target layers equals the pinned native dry mass in exact arithmetic. Global water term. The dry pin leaves a global moist tendency equal to the global water change. Before each layer solve, remove the layer's area-weighted global target, so the target is globally solvable. The guard compares the column against the moist tendency minus the known global water tendency distributed by area; global dry-mass drift still fails. This prevents an index-space mean from becoming a polar pressure error. Previously a global fractional water rate G/M appeared as
in the guard, with mean/min area ratio about 290 at 0.25°. Thus even a s⁻¹ global estimate could give nearly s⁻¹ at the smallest cells. The scaled-cap regression exceeds the old maximum threshold and passes after the source projection. Final dry column repair still imposes the stored dry endpoint budget. Local E − P term. The dry conversion leaves a local column residual of about
relative to the column mass (estimate: about s⁻¹ for 3 mm per day, up to s⁻¹ for 10 mm per hour of heavy rain). The shared dry column balance removes it, as in the existing route. limit. After the column balance, the dry route's cmequals the hybrid-B closure in exact arithmetic (covered by the closure and dry-limit tests).
10. Reduced Gaussian and direct cubed-sphere specifics
Owner decision Q11: RG ships with LL from the first flux pull request.
Geometry. RG cells are longitude-latitude boxes on each ring with midpoint ring boundaries; meridional faces between rings are latitude-arc segments of the least-common-multiple subdivision (
src/Grids/ReducedGaussianMesh.jl).Quadrature. TM5's one-dimensional rules apply exactly with a per-ring
. A prefix integral of the refined samples along each face ring gives every LCM segment in . Each ring's FFT length is a multiple of its that is at least . Balance. Per-level balance on the existing compressed ring Laplacian. The column PCG takes about 19 s per window at O90 (measured, header of
src/Preprocessing/MassClosure/ring_poisson_balance.jl); the per-layer route needssolves per window, so it needs a factor-once direct solve of the same Laplacian, reused across levels, endpoint sets and windows. The existing column PCG path stays unchanged. On O90 (35,640 cells, 2,250,376 faces), one-thread compression takes 0.18–0.41 s, factorization 0.70–0.88 s, and 68 reused layer solves 0.40–0.43 s.
The direct RG spectral path already shares the LL primitives (ReducedSpectralSynthesis; spectral_to_ring! and compute_reduced_horizontal_fluxes! in src/Preprocessing/Targets/ReducedGaussian/reduced_transport_helpers.jl).
Direct CS quadrature. Let
For the constant Cartesian normal
The face map uses tensor-product 16-point cardinal interpolation in longitude and latitude of the sampled Cartesian wind–pressure product. It preserves sampled pressure–wind covariance. It integrates that interpolant with equally spaced midpoints in great-circle arc length, including the slerp Jacobian. This differs from TM5's uniform-latitude/longitude trapezoids of LineIntegralFaceFluxes paths retain their original arithmetic.
A zero face integral has no finite relative error. Tests therefore check complex harmonic phases against an absolute integral envelope and also report ordinary relative error when the integral is at least 10% of that envelope. The envelope is the integral of the absolute harmonic amplitude; underflowed modes below test_tm5_cs_harmonic_accuracy.jl. The maximum ordinary relative error is 0.04075% against exact integration and 0.04091% against converged TM5; the maximum envelope-normalized error is 0.02747%. These sweeps cover all 205,120 retained scalar modes and both vector families at T639, and all 32,896 at T255, on each of five faces. Selected high modes also exercise the portable gather in Float32 and Float64. This is a measured bound on those faces and test fields, not a theorem for arbitrary pressure spectra:
Accuracy reference. The CS path targets converged physical integrals (owner decision, 2026-11-02). Default TM5 IntLon has one-degree retained-mode errors of −18.7414% at T255 and −16.6374% at T639; its default and exact integrals cannot simultaneously satisfy a 0.1% bound. Tests preserve those counterexamples and compare accuracy with the IntLat/IntLon rule at converged refinement (1024 subdivisions). Section 13 gives the measured cause, the comment/code refinement mismatch and the real-ERA5 difference. General tilted CS edges have no corresponding TM5 meridian/parallel face.
Polar evaluation. A scalar transform of pseudo-wind coefficients obtains small
The old bilinear source sampler clamps latitude poleward of its outermost ring. The new high-order CS map instead continues Cartesian products through the poles by reflecting latitude and shifting longitude by π. This supplies centred stencils even for face samples closer to a pole than the outermost ring. Neither policy reproduces TM5's duplicate-longitude polar mean or its substituted
PS remains the conservative overlap mean of
Cost and choice. cs_exact_samples supplies a portable, batched direct vector-harmonic evaluation at arbitrary face points without interpolation. It uses selected-precision Legendre/derivative recurrence, Fourier sums and compensated accumulation. Bounded chunks need no per-point Legendre table. A warmed T639 eight-level, 64-point chunk took 1.388 s on one CPU thread. Straight scaling to every C90 face midpoint and two L137 endpoints gives 8.09 million seconds per window, versus 123 seconds for the previous ring-synthesis/face-gather workload. This is an extrapolation of the direct implementation, not an optimized non-uniform FFT or exact-latitude ring implementation. A separate exact-sample-latitude geometry count, grouping absolute latitudes within
Before geometry compaction, C90/T639 warmed batch costs were 3.376 s for eight-level U/V/D synthesis, 0.143 s for polar replacement and 1.325 s for the face gather (previous gather: 0.201 s). Two L137 endpoint equivalents cost 166 s versus 123 s, a 1.35× ratio. These window estimates exclude common surface/cell overlap, balance, closure and IO work. Setup took 55.6 s for the face map. The former expanded Float64 portable gather stored 1.540 GB, shared synthesis plans 3.129 GB, and polar plans 0.118 GB; estimated live synthesis/face buffers total 7.07 GB, excluding source hourly coefficients, cell overlap and graph factors. Setup temporarily retains the 2.165 GB host sparse map. Sizes are decimal GB; times exclude compilation after warmup except the first geometry setup.
A CPU-only GPU model at 500 GB/s effective gather bandwidth gives 1.41 s per two-endpoint L137 C90 window-equivalent for the new gather alone (1.48 s including the padded final batches). A 1 TFLOP/s FP64 recurrence model gives 27,533 s for the direct point method. These are estimates, not GPU measurements, and omit GEMM/FFT, launch and transfer costs. Actual GPU execution remains untested in this CPU-only run.
The corresponding pre-compaction C180/T639 benchmark retains 3056×1528 rings and uses 56 face midpoints. Warmed eight-level synthesis, polar replacement and gather cost 3.382, 0.133 and 3.853 s; the old gather costs 0.364 s. Two-endpoint L137 equivalents are 252 s versus 128 s (1.97×). The expanded gather stored 4.864 GB, estimated live synthesis/face storage is 10.41 GB, and the temporary host sparse map is 6.595 GB. Face-map setup takes 119.8 s. Direct-point scaling gives 16.20 million CPU seconds per window. Under the same GPU assumptions the new gather is 4.44 s (4.67 s with padding) and the direct recurrence 55,066 s. These timings use Julia and BLAS one thread, batch eight, Float64, with no actual GPU execution. The benchmark is retained at scripts/benchmarks/bench_cs_spectral_quadrature.jl. Set ATMOSTR_BENCH_EXACT_LATITUDES=1 to reproduce the exact-ring geometry count, and ATMOSTR_BENCH_FULL_WINDOW=1 to time complete face-path windows. The latter includes all 36 padded batches plus the production Cartesian pressure–wind/forcing kernel. C90/C180 measured 198.1/292.1 s, with peak process RSS 14.63/23.79 GB, including setup and benchmark scratch in the peak. This still excludes common surface synthesis, cell overlap, balance, closure and IO; it is not a full preprocessing-window timing. The day driver reuses the previous endpoint, so steady-state face work is approximately 99.1 s/window at C90 and 146.1 s/window at C180; a 24-window day builds 25 endpoints, giving approximately 103.2/152.2 s/window before the common stages and amortized setup. The GPU gather model likewise halves to 0.74/2.33 s per steady-state window with endpoint reuse. These full-window timings and GPU models describe the expanded geometry before the storage optimization.
The compact map shares scalar stencil indices/weights and each face normal. A paired CPU benchmark against the pre-compaction fix measures:
| T639, Float64, batch eight | C90 | C180 |
|---|---|---|
| Expanded → compact portable geometry (decimal GB) | 1.539983 → 0.515920 | 4.863692 → 1.631599 |
| Compact host geometry (GB; transient during setup) | 0.687375 | 2.173391 |
| Expanded → compact setup (s) | 54.52 → 48.98 | 119.51 → 105.31 |
| Expanded → compact gather median (s; three warmed trials) | 1.2820 → 1.2348 | 4.1868 → 3.8669 |
| Compact Float32 geometry including rounding offsets (GB) | 0.471987 | 1.491874 |
The live-buffer estimates above decrease by the geometry reduction alone: approximately 6.05/7.18 GB instead of 7.07/10.41 GB. These are estimates, not new peak-memory measurements. The benchmark process itself retains both maps and reference scratch; its 44.68 GB peak is not a production requirement. Reconstruction preserves every weight and the X/Y/Z accumulation order. All 4.86 million production-sized output values checked across C90/C180 and Float32/Float64 match the pre-compaction fix bitwise. The CS integration and day fixtures also match bitwise (76 and 4,356 numeric leaves respectively, including all 24 windows in Float64, Float32 and live-PBL fixtures). Timings use one Julia/BLAS CPU thread; setup includes first-call compilation, while gather medians exclude warmup. No GPU execution is claimed. The compact gather model would read 36 rather than 60 bytes per scalar entry/level (12 for shared index/weight and 24 for three source values), but this is a traffic estimate rather than a GPU measurement.
Real endpoint check. Local ERA5 T639 GRIB endpoints on 2021-12-01 at 00:00 and 01:00 were checked at native levels 1, 70 and 137 on four C90 faces (central, tilted, polar and panel boundary). Actual ring-synthesized Cartesian pressure–wind products use the production cardinal weights and are compared with 256-node Gauss integration of direct spectral point values. All eight endpoint/face checks pass; maximum scaled relative error is 0.002885%. This checks individual endpoint rates before balancing; it is not a full-day ERA5 W or transport comparison. The reproducible opt-in file is test/real_data/test_tm5_cs_endpoint_accuracy.jl.
11. Types, dispatch and configuration
abstract type AbstractSpectralFluxConstruction end
struct PointSampledSpectralFluxes <: AbstractSpectralFluxConstruction end # default: today's bodies
struct TM5SpectralFluxes{Q<:AbstractFaceQuadrature} <: AbstractSpectralFluxConstruction
face_quadrature :: Q # GaussFourier() default; TM5Trapezoid() explicit
refinement_steps :: Int # 2; trapezoids and CS
vod2uv_radius :: Float64 # IFS_EARTH_RADIUS (Q4)
end| Dispatch point | Default method | TM5SpectralFluxes method |
|---|---|---|
spectral_resolution(c, grid, T_source) | target_spectral_truncation(grid) | T_source |
LL process_window!(c, …), RG synthesize_and_merge_window!(c, …) | current body, untouched | stages 3–7 |
process_day(c, …) | legacy daily workflow | hourly read, two endpoints, balance_window_layers! for stages 8–10, per-window closure/write |
Backend choices are parsed into
CPUSynthesis/GPUSynthesis, withAutoSynthesisPrecisionor a float type; dispatch constructs the actual plan.InterfaceMassFluxField <: AbstractFieldKind(a kg s⁻¹ interface flux is not a convective flux, even where the selection body is the same).Direct CS dispatches on
TM5SpectralFluxesand usesCSSpectralIntegralWorkspace; legacy face-method choices retain their meaning.[preprocessing].spectral_flux_constructionis parsed once withConfigChecks.parse_choice; absence adds no fields to historical settings, preserving their fingerprint representation.flux_constructionand the existing face-method keys retain their meaning.TM5SpectralFluxeshas the fixed IFS radius, typedface_quadrature(defaultGaussFourier()) and positivequadrature_refinement_steps(default 2; trapezoids and CS).ConfigChecks.check_known_keysrejects unknown preprocessing keys, and native sources reject spectral-only keys. Planning rejects moist basis and sampling other thanwindow_mean. The day driver requires next-day 00 UTC. The new route requires retained native interfaces, rather than pressure-overlap remapping.[preprocessing] include_tm5_pbl = truecan be combined with this construction on LL, RG and CS. The v5 binary retains thetm5_spectralconstruction identity and includes the complete live Calc_Kzz input group. Setinput.surface_dirandinput.thermo_dir, then select[diffusion] kind = "tm5_calc_kzz"at runtime (see TM5 boundary layer). Both constructions share the day-local PBL input cache, area-mean surface fields and T/q assembly, including next-day 00 UTC endpoints. T/q merge weights use each construction's stored window-start total surface pressure. Merged T/q can therefore differ between constructions beyond rounding, consistent with each binary's hybrid layers.The point-sampled construction stays bitwise unchanged; every flux pull request gates the
pre_ll72,pre_o24andpre_c24goldens.
AtmosTransport.Preprocessing.Common.TM5SpectralFluxes Type
TM5SpectralFluxes(; face_quadrature=GaussFourier(), refinement_steps=2)Retained-spectrum target quadrature with independent vertical forcing. LL/RG default to Gauss/Fourier integration; CS keeps its existing arc rule. TM5SpectralFluxes(steps) explicitly selects the historical trapezoid rule.
AtmosTransport.Preprocessing.Common.PointSampledSpectralFluxes Type
Legacy centre/face sampling; the default keeps the existing arithmetic.
source12. Binary identity
A TM5SpectralFluxes binary is written as format version 5: version 4 plus the construction identity. This part is implemented (TM5-0); see Binary format for the full contract.
| Header key | Value |
|---|---|
format_version | 5 |
flux_construction | "tm5_spectral" or "point_sampled_spectral" |
flux_construction_revision | revision of the construction (tm5_spectral only) |
spectral_truncation_used | retained truncation |
face_quadrature | gauss_fourier (LL/RG default) or tm5_trapezoid; parsed once into a type |
quadrature_refinement_steps | nstep of the explicit trapezoid and CS refinement rule (default 2) |
vod2uv_radius_m | vod2uv radius in m (tm5_spectral only) |
The reader decodes the keys into TM5SpectralFluxesHeader or PointSampledSpectralFluxesHeader; a version-4 header decodes to NoFluxConstructionHeader. Readers accept versions 4 and 5. Writers produce version 5 only when the identity is recorded, so every existing output stays version 4. The mesh radius stays in the existing planet_radius_m. The window flux uses the existing version-4 sampling tags (source_flux_sampling = "window_mean", flux_sampling = "window_constant"); the new LL and RG route records these tags from its construction.
The v5 headers also record spectral_synthesis (cpu/gpu), spectral_synthesis_float (the actual Float64/Float32 plan type), and spectral_surface_float (the actual surface precision). LL/RG Gauss/Fourier products use construction revision 2; explicit trapezoids and the existing CS rule retain revision 1. The face_quadrature tag and Gauss/oversampling resolution fields record the LL/RG quadrature. CUDA's math mode is set to PEDANTIC for each transform and restored even on exceptions; FAST_MATH is rejected.
13. Differences from TM5
We use TM5's spectral budget equations, with the numerical corrections and modelling departures inventoried below; we do not reproduce TM5's numerical errors. In particular, LL/RG now use the Gauss/Fourier reference rule as their default, and the direct CS path targets converged face integrals, rather than agreement with TM5's default under-resolved quadrature (owner decision, 2026-11-02). There is no TM5-default-compatible CS quadrature option. The two groups below distinguish numerical corrections from modelling or convention choices; unisolated sizes are explicitly marked not measured.
For this inventory, paired citations identify the two inspected source trees: R/file:line is relative to tm5-moguntia-r1112-revised/base in the TM5-MP r1112 source tree; C/file:line is relative to base/trunk/src in the CarbonTracker TM5 repository (ct-unified-github). These prefixes do not change the CarbonTracker abbreviations in Sources above. Archive settings and the offline coarsener are configuration choices, not universal properties of either base tree; their additional provenance follows the convention table.
Deliberate corrections of TM5 numerical errors
| Where TM5 differs | Here | Why | How much |
|---|---|---|---|
R/grid_type_sh.F90:1769–1772,1796–1805; C/grid_type_sh.F90:1771–1774,1798–1807) | Exact LNSP gradient through degree | The top-row sign in TM5 is a code error; differentiation also generates a nonzero extra degree | Sign-only single-mode difference |
Sets R/grid_type_sh.F90:827–828; C/grid_type_sh.F90:829–830) | Evaluate | A retained Legendre function must not be suppressed | Real L137 global Δu RMS about |
vod2uv drops the upper neighbour at R/grid_type_sh.F90:1998–2029; C/grid_type_sh.F90:2000–2031) | Retain every neighbour and | Complete the vector transform at truncation | Combined truncation-edge probe: L137 cap Δu/Δv RMS 0.140/0.176 m/s (3.53/4.39%); omitted terms |
vod2uv output stops at R/grid_type_sh.F90:1983–2029; C/grid_type_sh.F90:1985–2031) | Complete transform retains it | Required by the vector transform and Gauss identity | Unit VO/D contributes |
Polar endpoint mean includes the duplicated longitude; IntArea substitutes the adjacent-row mean of R/grid_interpol.F90:3200–3214,3229,3260–3264,2495–2509,2550; C/grid_interpol.F90:3202–3216,3231,3262–3266,2497–2511,2552) | LL/RG open polar nodes; CS stable vector evaluation on open rings (§10) | Remove the duplicated-longitude mean and artificial endpoint; avoid cancellation of small pseudo-winds before division by | L137 Fu cap RMS about 8%, L1 cap divergence RMS 40% in the probe below. Unit cosine has spurious mean |
IntLat/IntLon use nstep=2 refinement and linear (trapezoid) quadrature (§10; R/grid_interpol.F90:1624–1626,3275,3629; C/grid_interpol.F90:1626–1628,3277,3631) | LL/RG Gauss latitude nodes and exact Fourier longitude integrals; CS cardinal-16 Cartesian interpolation and resolved arc midpoints | Integrate the retained oscillations accurately; default trapezoids have a measurable integration error | Unit retained-mode TM5 default misses −18.7414% (T255), −16.6374% (T639). Real ERA5 TM5-default/converged difference: 0.02655% relative L2 over 48 sampled rates; 1.7009% at 80°E, 30–31°N, L137, 2021-12-01 01:00 UTC (−501,352 vs −492,967 kg/s). CS harmonic/exact maximum 0.04075% on the §10 sweep; real CS endpoint maximum 0.002885% |
π literal 3.14159265358979 (R/binas.F90:34; C/binas.F90:35) | Julia's | Use the available constant precision | Relative difference |
Measured Gauss/Fourier correction (CPU, 2026-11-03). The default now uses the converged-reference approach above for LL/RG production. The shared Gauss rule and exact Fourier integrator live in src/Preprocessing/Spectral/gauss_fourier.jl; the historical raw-face diagnostic calls that integrator too. There is one home for the integration math.
The order was chosen by measurement. Eight nodes passed the retained-harmonic probe but missed the real T255 all-native-level per-face requirement: maximum meridian relative error 4.50e-6 at 01 UTC. Production therefore uses at least 10 nodes, 15 at T639 on 1° faces, and tenfold longitude-product oversampling (§1). Tests sweep every product frequency through
Real ERA5 checks cover all unique faces and all 137 native levels at 00, 01 and 02 UTC, 2021-12-01, on 360×180 LL in Float64. These are raw face rates before pinning, drying, merging or balance. The table is the maximum of
| Input | Meridian face maximum relative error | Parallel face maximum relative error | Cell forcing C maximum relative error |
|---|---|---|---|
| T255 | 2.984e-07 | 5.633e-09 | 6.611e-08 |
| T639 | 3.301e-07 | 4.375e-09 | 5.949e-07 |
The reference uses 20 Gauss nodes / 6,480 longitudes at T255 and 30 / 7,920 at T639. At hour 00, levels 1/70/137, doubling the actual node and longitude counts (40 / 12,960 and 60 / 15,840) changes the largest relative L2 among PS, both face rates and C by 1.078e-14 / 8.045e-15, well below
Balanced and closed fluxes. The following unweighted relative L2 values pool three complete 00–03 UTC windows, unique horizontal faces (excluding the periodic am duplicate), and all 117 merged layers / 118 cm interfaces. Each stored mass amount is converted to kg/s using its own recorded schedule. Both arms use the production dry pin, moist layer balance, dry closure, replay and positivity gates; schedules are 118/124/126 in both arms.
| Input / reference | am relative L2 | bm relative L2 | cm relative L2 |
|---|---|---|---|
| T255 / retained steps-64 trapezoid binary | 2.954909e-06 | 4.480361e-06 | 4.328223e-05 |
| T639 / own converged Gauss/Fourier result | 2.257483e-13 | 4.515015e-13 | 3.676260e-12 |
Only the T255 steps-64 binary remains in the impact job; T639 is therefore compared against the certified production-kernel reference. The T255 numbers include the finite error of steps 64; they are not the Gauss/Fourier raw-face error reported above. Explicit tm5_trapezoid, steps 2 reproduces the previous job's complete one-window binary payload bitwise at both T255 and T639, excluding the updated metadata header.
Wall time and memory before the fixed-shape correction in §17. The 00–01 UTC window includes decode, planning, hourly humidity, both changing endpoints, pin, merge, balance, closure, replay, positivity and write; package/process startup is excluded from wall time. Settings: Julia threads 16, BLAS 1, native batch 8, L137→L117 at 100 Pa, dry Float64, --heap-size-hint=64G (a GC hint, not a memory cap). Gauss/Fourier divides its 32-cell budget across four band workers, with two FFT threads each; the global FFTW setting remains 1, as used by explicit trapezoids. The complete arms are both warmed first, followed by A B A B, two measured repetitions per rule. The ratio is the ratio of mean measured times. The host is shared; these are CPU window measurements, not full-day or GPU performance guarantees.
RSS below comes from separate single-arm processes, including startup/JIT; it is not the second arm's process-lifetime high-water mark in a paired run.
| Input | Steps-2 reps (s) | Gauss/Fourier reps (s) | Ratio of means | Steps-2 isolated peak RSS (GB) | Gauss/Fourier isolated peak RSS (GB) |
|---|---|---|---|---|---|
| T255 | 18.89 / 19.35 | 22.41 / 23.60 | 1.20× | 6.03 | 7.71 |
| T639 | 99.60 / 100.08 | 83.63 / 83.85 | 0.84× | 14.80 | 16.20 |
Both warmed cost ratios satisfy the ≤1.5× target. T639 Gauss/Fourier peaks at 16.20 GB, 1.095× its isolated trapezoid peak, below the approximately 1.2× target and down from the reviewed 33.28 GB. Before the fixed-shape correction, at each truncation, every 609,094,080-byte one-window payload matched the retained pre-streaming Gauss/Fourier result bitwise (headers excluded); both measured repetitions and the isolated run were checked. Explicit CPU Float64 trapezoid payloads also match their retained counterparts. These checks cover the measured input, precision, backend and window.
Reproduce warmed timing with scripts/benchmarks/bench_tm5_refinement_window.jl CONFIG 2021-12-01 OUT. For isolated RSS, add a fourth argument, tm5_trapezoid or gauss_fourier, in a fresh process per rule. Use a TMPDIR on fast local disk, empty CUDA_VISIBLE_DEVICES, and the settings above. Raw timing tables, payload SHA256 checks, the summary FINAL_MEASUREMENTS.json, the accuracy and balanced-flux evidence and the full work record are kept outside the repository. These warmed/isolated results supersede the earlier ordered cold-pair claim.
Golden policy. Only the two O24 configs pin tm5_trapezoid, steps 2. The following golden stage/window figures predate the memory and CPU scheduling revision; they document the retained pin decision rather than current golden throughput. On the frozen T639 input, a warmed eight-level batch cost 3.093/7.939 s (trapezoid/Gauss), 2.57×. With 18 padded native batches and surface work counted once, projected spectral endpoint cost is 2.64×, beyond the ~2× threshold. The two LL72 configs follow Gauss/Fourier: their warmed batch is 2.283/4.414 s (1.93×) and the spectral endpoint projection is 1.96×. These historical projections cover spectral work, not total golden-suite runtime.
Complete changing-hour windows took 150.91/181.60 s (1.20×) on LL72 and 163.92/294.05 s (1.79×) on O24. Their fixed decode/planning/humidity work and first-arm JIT mask the O24 repeated cost; pinning uses the warmed evidence. Live PBL adds shared non-spectral work. The two LL cases pre_ll72_tm5 and pre_ll72_tm5_tm5pbl are stated numerical deltas in masses, pressures and fluxes, with possible pressure-dependent PBL deltas. C24 keeps its existing arc method and restored refinement 2. No golden references are written here. The only defined runtime consumer of these changed cases is run_ll72_tm5_tm5pbl_cpu_f64, which consumes pre_ll72_tm5_tm5pbl; pre_ll72_tm5 has no runtime consumer in cases.toml. Standard golden check resolves @CASE: inputs from the reference tree, so that runtime case's delta needs a separate record/comparison using regenerated inputs. An unchanged runtime check does not test the new preprocessing products. See test/golden/README.md for the case policy.
Transport impact. Over a full T255 day, balanced cm with steps 2 differs from the converged steps-64 rule by 4.09% relative L2. A 62-day full-physics run (2021-12-01 to 2022-01-31) compared steps-2 trapezoids with the Gauss/Fourier default. It used T255 fluxes on 1° LL L117, conservatively regridded to C90, identical convection and PBL inputs, and the CATRINE tracers. Hourly cm differs by 4.21% relative L2 on LL and 1.28% on C90. On C90, caps poleward of 85° contribute 0.12% of the squared difference, and the largest zonal RMS lies near 37°N and 630 hPa. After four weeks the natural-CO2 difference is 0.031 ppm RMS at the surface and 0.0026 ppm in the column, about 0.3% of the accumulated change. The differences are local: zonal-mean differences stay below 0.06 ppm, while the largest single-cell surface differences at week 4 (3.2 ppm natural, 4.5 ppm fossil CO2) lie in one cell near Tehran on the Alborz slope; the SF6 and Rn maxima lie over Central Asian orography. Surface differences level off within the period; column RMS averaged over the final week is 5–11% above that of the preceding week. In monthly means the effect exceeds the restart noise floor at least 80-fold but stays below 3.7% of the difference between the ERA5 and MERRA-2 runs. The error is real and is corrected here, but it does not explain ERA5–MERRA-2 transport differences.
The historical raw trapezoid derivation and day profiles follow.
TM5's default face-integration error is the composite trapezoid error of a coarsely sampled oscillation, not an error in the exact face integral or a CS-only interpolation effect: a 1°
The inspected source is deps/tm5-mp-r1112/tm5-moguntia-r1112-revised/base/: grid_interpol.F90:1624–1626 defines grid_interpol.F90:1675, also 1820, 2006, 2224, 2713 and 2941). The CarbonTracker tree agrees (base/trunk/src/grid_interpol.F90:1626–1628, comment at 1677). These routines are in grid_interpol, rather than grid_type_sh.F90, which contains the spectral primitives and Nabla bug. IntLat applies the trapezoid to grid_interpol.F90:3248,3275); IntLon applies it to grid_interpol.F90:3609,3629), with
For 1° faces, TM5-default T255/T639 subdivisions are 3/8, giving spacings 0.333333°/0.125°. The shortest retained longitudinal wavelengths
| T255: subdivisions / error | T639: subdivisions / error | |
|---|---|---|
| 2 | 3 / −18.741384% | 8 / −16.637396% |
| 3 | 5 / −6.585504% | 11 / −8.661243% |
| 5 | 8 / −2.551821% | 18 / −3.199522% |
| 8 | 12 / −1.130926% | 29 / −1.227786% |
Holding TM5's default spacing fixed isolates the along-face frequency:
| Along-face | T255 error | T639 error |
|---|---|---|
| 1 / 1 | −0.00028205% | −0.00003966% |
| 63 / 159 | −1.121983% | −1.004755% |
| 126 / 318 | −4.518499% | −4.043503% |
| 253 / 637 | −18.741384% | −16.637396% |
Thus high along-face frequency causes the miss. A near-sectoral harmonic varying slowly along a meridian can instead expose transverse interpolation error (§10); it does not test this trapezoid defect. The analytic response and direct sums separate those two causes. The reproducible 32-case sweep (nstep=2,3,5,8, four wavenumbers at each truncation) is produced by scripts/diagnostics/tm5_default_quadrature.jl harmonics OUT; its day and native-day commands measure the ERA5 impact below. See scripts/diagnostics/README.md for definitions and commands.
Real ERA5 1° LL day: integration-only comparison. On 2021-12-01, all 24 hourly UTC analyses and all 137 native levels were integrated on every meridian and parallel face, using identical complete wind coefficients and surface pressure on both sides. TM5-default here means the eight-subdivision IntLat/IntLon rule, including its meridian polar endpoint means; the reference uses 16-node Gauss latitude integration and Fourier primitives of longitude products. Doubling to 32 Gauss nodes and 11,520 rather than 5,760 product longitudes at hour 00 (levels 1/70/137) changes U/V relative L2 by only
Below, Δ is default minus converged. RMS is unweighted over faces and hours, in kg/s; relative L2 is
| Native level / rate | Global Δ RMS (kg/s) | Global relative L2 | Cap Δ RMS (kg/s) | Cap relative L2 | Relative L2, latitude <89° in magnitude |
|---|---|---|---|---|---|
| 1 / Fu (meridian) | 2,180.504 | 0.316011% | 9,246.98858 | 2.844701% | 0.009494% |
| 1 / Fv (parallel) | 19.426 | 0.013821% | 0.01043 | 0.000075% | 0.013821% |
| 60 / Fu (meridian) | 200,272.242 | 0.187393% | 847,350.73076 | 2.419952% | 0.013917% |
| 60 / Fv (parallel) | 8,662.252 | 0.026106% | 1.87134 | 0.000142% | 0.026106% |
| 70 / Fu (meridian) | 216,055.058 | 0.107259% | 908,277.32706 | 2.102330% | 0.014501% |
| 70 / Fv (parallel) | 17,769.944 | 0.023305% | 3.47345 | 0.000215% | 0.023305% |
| 96 / Fu (meridian) | 633,818.123 | 0.211811% | 2,643,025.22090 | 2.653127% | 0.039553% |
| 96 / Fv (parallel) | 50,661.231 | 0.037187% | 23.91611 | 0.000536% | 0.037187% |
| 137 / Fu (meridian) | 84,455.719 | 0.568389% | 353,524.19361 | 3.715678% | 0.093682% |
| 137 / Fv (parallel) | 6,792.446 | 0.078181% | 5.67749 | 0.001383% | 0.078182% |
The full 137-level profile and the 32 harmonic cases are retained in scripts/benchmarks/results/tm5_quadrature_20261102/, with definitions and reproduction commands. The raw day has 6,576 hour/level/component statistics covering 427,308,480 face/level/time rates, including zero polar parallel rates. All 144 statistics from the independent three-level day agree exactly with their entries in the all-level pass. Pooling every level and component gives relative L2 0.252418% globally, 3.32820% in caps, and 0.0370244% with absolute latitude <89°. The maximum daily per-level Fu relative L2 is 0.670047% at level 129; the Fv maximum is 0.078181% at level
- The full native-level pass used
about 48 CPU minutes including setup and a discarded partial hour; the two preliminary/convergence passes bring the measurement work to about one CPU hour. Independent hourly chunks reduced wall time; no GPU was used.
These are raw analysis face rates, before pin, balance, drying or merging, rather than a balanced transport-day or W comparison. Restricting caps to
The TM5-FLUX-2a real-day memo records the default-versus-TM5 construction comparison, balance diagnostics and flux × PBL transport experiment. Reproduction commands and CSV definitions are in scripts/diagnostics/README.md.
The atmospheric sizes below are measured in the independent 2026-10-31 WIND_DIFF_PROBE report (WIND_DIFF_PROBE.md in that experiment's output directory), using the original ERA5 T639 analysis coefficients for 2022-01-15 00–01 UTC. They cover native levels 1, 60, 96 and 137 on a common 1° target, before pin, balance, drying or merging. Caps mean |latitude| > 85°. They are raw flux and wind differences, not final transport errors or full-day statistics.
| Difference | Real T639 size (probe sections: winds, fluxes, Nabla proxy) |
|---|---|
| Truncation-edge wind rows | L137 cap RMS Δu=0.140 m/s (3.53%), Δv=0.176 m/s (4.39%); cap maxima about 1.1 m/s. On the nearest extra open polar rings, maxima rise to about 11 m/s. |
| Point sampling versus face integration | Global raw net-divergence RMS changes by 9–26%; face RMS by 0.3–6.1%, cap net divergence by 8–54%. Includes wind–pressure covariance and face averaging. |
| Open polar quadrature versus TM5 endpoint rules | L137 Fu cap RMS changes by about 8%; L1 cap net-divergence RMS by 40%. The top-level reference divergence is small. |
| Wind radius convention | 0.003594% coherent wind scale change (approximately 0.0036%). |
| n=T Nabla sign | No direct wind/face effect. L96 forcing proxy δC is 0.41% of global and 26.9% of cap horizontal-divergence RMS. The proxy uses 1° latitude midpoints and eight longitude trapezoids, not full refined IntArea or a full-column W comparison. |
| Suppressed Legendre corner | L137 global u RMS about 3.5×10⁻⁴ m/s; negligible aloft and in polar caps; redundant once the corner wind coefficient is zeroed. |
| Special n=m=T−1 branch | Exactly zero isolated difference on the measured coefficients. |
The unit-coefficient values below are reproducible analytic test anchors; they are not atmospheric amplitudes. The separate missing T+1 gradient, full-column forcing and final balanced transport effects were not isolated by this four-level probe.
For the unit-coefficient tests at
Deliberate modelling or convention choices
| Where TM5 differs | Here | Why | How much |
|---|---|---|---|
Total-pressure area mean additively matched to 98500 Pa (§9; R/binas.F90:129, R/meteo.F90:1730–1735, R/grid_type_ll.F90:1167–1175; C/binas.F90:133, C/meteo.F90:1535–1537, C/grid_type_ll.F90:1025–1033) | Dry pin to 98325 Pa after flux integration, without recomputing fluxes | Fix our dry carrier mass while preserving TM5's ordering of integration before pinning | Global water term, estimate |
Periodic five-point index-space FFT Poisson operator; subtract west/south correction fluxes to close outer faces (§6; R/grid_type_ll.F90:2846–2850,2873–2896; C/grid_type_ll.F90:2703–2707,2730–2753; speedup overlay GTS:3028,3031,3172–3192) | CS uses the global degree-four cell graph, a pinned potential (one principal minor), and canonical/mirror seam signs; reuse the direct factorization | CS topology has panel seams and no LL outer boundary. Its graph distributes face corrections differently; this is a geometry choice, not a demonstrated TM5 error | Isolated atmospheric difference from TM5 not measured. Direct residuals and direct-versus-PCG checks in §6/§10 verify our solver only |
FFT potential zero mode set to zero; the index-space mean layer residual remains uncorrected (§6; R/grid_type_ll.F90:2854–2863; C/grid_type_ll.F90:2711–2720; speedup overlay GTS:3166) | Before the layer solve remove | Closed global faces require a zero-sum target. The dry pin allows a moist global water tendency; distributing its removal by area avoids a polar pressure amplification | Exact target change is the displayed area-weighted term; §9's |
Archive reader derives forecast-day filename keys from R/tmm_mf_tm5_nc.F90:409–415; C/tmm_mf_tm5_nc.F90:408–414); balanced fluxes interpolated to each dynamic-step midpoint (R/meteodata.F90:683–693; C/meteodata.F90:763–773). NOAA selects h06h18tr3 (provenance below) | Hourly analyses; average two endpoint flux sets, each balanced against the same tendency (§7/§8) | Use the available analysis archive and its window-mean flux contract | Endpoint mean exactly integrates the assumed linear interpolation; forecast-versus-analysis effect not measured |
NOAA 1° archive plus offline coarsener (provenance below); base mapper combines stored fields with FillGrid (R/tmm.F90:1264–1273; C/tmm.F90:1258–1267) and sums integrated face fluxes according to CombineKey (R/tmm_param.F90:97–99; C/tmm_param.F90:98–100) | Integrate directly on the target | Avoid an intermediate archive and integrate the target's own boundaries | Direct coarse integrals can differ from sums of 1° fluxes; magnitude not measured |
T and Q use horizontal and vertical mass-aver (R/tmm_param.F90:105–107; C/tmm_param.F90:106–108); horizontal weights are cell area × hybrid pressure thickness (R/tmm.F90:1218–1248; C/tmm.F90:1221–1251) | Reader's target-cell point | Humidity is supplied as a grid-point field rather than spectral coefficients | Isolated difference not measured |
vod2uv imports radius ae=6.371×10^6 m (R/grid_type_sh.F90:1949, R/binas.F90:50; C/grid_type_sh.F90:1951, C/binas.F90:51) | IFS radius | Match the radius used to define the ERA5 coefficients | 0.003594% coherent wind scale change (relative |
Single-radius R/tmm.F90:2487,2499; C/tmm.F90:2468,2480) | Keep independent W consistent with winds synthesized using the IFS radius and faces using the mesh radius | Coefficient ratio | |
Latitude/longitude trapezoids on coordinate faces (R/grid_interpol.F90:3275,3629; C/grid_interpol.F90:3277,3631) | CS uses midpoints in great-circle arc length, with the arc Jacobian (§10) | CS edges are great circles; their natural integration coordinate is arc length | Isolated rule-versus-coordinate effect not measured; combined CS accuracy bounds in §10 |
IntLat integrates R/grid_interpol.F90:3248,3606–3609; C/grid_interpol.F90:3250,3608–3611) | Integrate | General CS faces are neither meridians nor parallels, so IntLat/IntLon are not directly applicable | No one-to-one TM5 face comparison on tilted edges; isolated effect not measured; coincident coordinate-face convergence is tested |
LL poles use neighbouring-row means (R/grid_interpol.F90:3200–3214,3260–3264; C/grid_interpol.F90:3202–3216,3262–3266) | CS uses stable vector evaluation, Cartesian pole reflection and longitude shift; | Continue smooth Cartesian products through the pole without an artificial endpoint mean. The previous bilinear latitude clamp is superseded on the direct CS path | Vector cancellation improvement above; separate reflection/clamping atmospheric effect not measured |
IntArea averages PS and integrates independent C over LL boxes (R/tmm.F90:1864,2447–2449,2465–2471; C/tmm.F90:1845,2428–2430,2446–2452) | Conservative refined-box overlap for CS PS and independent C (§10) | Supply cell means and forcing on CS polygons without a new spectral polygon integral | Separate exact-cell-integral difference not measured; Gauss convergence, closure and replay tests in §10 |
Balance loops through every level and calls Poisson for each coarse cell, with no residual threshold (R/grid_type_ll.F90:2609–2644; C/grid_type_ll.F90:2464–2499) | LL balance_mass_fluxes! skips residuals below src/Preprocessing/Spectral/mass_support.jl:339); this is not a skip in the direct CS solver | Avoid solving negligible LL residuals | Uncorrected residual bounded by |
Builds tsp and passes 'bottom' to FillLevels (R/tmm.F90:2516–2526,2577, R/grid_type_hyb.F90:2178–2189,2201–2203; C/tmm.F90:2497–2507,2558, C/grid_type_hyb.F90:2408–2420,2436–2438); 'bottom' affects interpolation, not retained-interface combination (§5) | Neither tsp nor a 'bottom' interpolation key is built; retain W interfaces directly | No tsp consumer in our construction; no vertical interpolation in this path | Atmospheric effect not measured; neither output is consumed here |
Check_CFL replays air-mass advection over the read interval and reduces the dynamic timestep on failure (R/advectm_cfl.F90:251–333;C/advectm_cfl.F90:190–261) | Preprocessing checks amounts/replay and donor positivity, optionally retries with more substeps, and writes the schedule; runtime consumes it (src/Preprocessing/Targets/CubedSphere/tm5_spectral_day.jl:96–131; src/Models/Runner/driven_stepping.jl:182–187) | Keep our binary schedule and positivity contract rather than TM5's online timestep search | Isolated transport difference not measured |
When reduced-grid mode is enabled, zonal advection combines polar cells and fluxes before the sweep and expands afterwards (R/advectx__slopes.F90:185–240; C/advectx__slopes.F90:246–270) | CS advects on its six panels without polar cell clustering (src/Operators/Advection/CubedSphere/cs_sweep_x.jl:34–49; §10 geometry) | CS has no shrinking LL polar cells requiring that treatment | Isolated transport difference not measured |
Prognostic tracer-mass slopes are advected and updated along with mass (R/advectx__slopes.F90:577–589; C/advectx__slopes.F90:651–663) | SlopesScheme diagnoses slopes anew from neighbouring cell means; PPM uses reconstructed profiles, without persistent TM5 moments (src/Operators/Advection/Reconstruction/reconstruction.jl:242–246,367–386; advection schemes) | Retain the configured advection algorithm; spectral preprocessing does not implement prognostic moments | Isolated transport difference not measured |
Unless without_diffusion is defined, adds dkg/m diffusion terms inside the convection matrix (R/convection.F90:446–451; C/convection.F90:472–477) | Configured implicit diffusion and convection are separate operators; Dkg uses a conservative tridiagonal solve (src/Operators/Diffusion/conservative_dkg.jl:1–9,48–60; TM5 diffusion) | Retain our operator composition, rather than a coupled convection/diffusion matrix | Isolated transport difference not measured |
Convection is the split-order 'v' step, with duration set by nconv/(2*tref(region)) (R/modelIntegration.F90:678–695, R/convection.F90:342; C/modelIntegration.F90:783–807, C/convection.F90:359); Check_CFL may reset nconv=ndyn (R/advectm_cfl.F90:318;C/advectm_cfl.F90:246) | Binary-scheduled runtime defaults to convection once at window end after restoring endpoint air mass; physics_cadence=:substep selects per-step composition (src/Models/Runner/driven_stepping.jl:320–358) | Follow the stored window forcing and configured physics cadence | Isolated transport difference not measured |
The NOAA archive provenance is C/../rc/meteo-tm5-noaa.rc:223–234 (ERA5 forecasts from 06/18 UTC, three-hour model-level records), :415–418,451–454 (source archive selection) and :585–587 (destination keys). The offline rig is outside the base source trees at /work2/noaa/co2/ash/meteo-coarsening/; its source/destination layout, 360×180×137 input and launch/configuration files are recorded in ct-unified-github/docs/meteo_coarsening_pipeline.md:8–23,52–78. The base tmm/tmm_param code cited above implements the coarsening in both trees; the external rig selects archives and launches that mapper. The NOAA configuration is not present in the older R base and is not inferred from its midpoint interpolation. Forecast-day filename keys are also distinct from GRIB lead bookkeeping: the older _fc012up2tr3 selector sets start day/hour and lead step at R/tmm_mf_ecmwf_tm5.F90:1655–1677 and C/tmm_mf_ecmwf_tm5.F90:1667–1689. That legacy 00/12 convention is not evidence for NOAA's ERA5 06/18 selection.
14. Validation tolerances
| Boundary | Criterion |
|---|---|
| Spectral primitives (analytic) | Float64, |
| Quadrature | Observed convergence order matches the rule; the discrete Gauss test (face fluxes against |
| Per-layer balance against pydyn | about pydyn/balance.py:9–12), so bitwise equality is not claimed |
| Closure identity (§7) | |
| Binary and replay | exact same-type round trip; replay |
| Float32 storage conversion | with the synthesis calculation held fixed, equal to that result rounded to Float32 |
A selected Float32 synthesis/quadrature plan performs its own rounded arithmetic; it need not equal a Float64 calculation rounded only at storage. The CPU selected-precision tests check numerical agreement, replay and the dry pin, not cross-precision bitwise equality. The verified explicit-trapezoid bitwise compatibility covers the previous CPU Float64 payload at matched settings (§13), excluding headers; it establishes neither every precision/backend nor bitwise parity with a Fortran TM5 dump. LL/RG Float32 trapezoids now also use Float32 surfaces and integrands, where the previous implementation used Float64. The shared CPU builder honors explicit Float32 for CS too; unchanged CS quadrature and defaults do not imply unchanged explicitly selected precision.
A tolerance is never loosened to cover a wrong grid, product, basis or missing modes, and an absent or skipped fixture is never reported as passed. pydyn has no spectral stage, so it can check stages 8 and 11 (balance and dynam0) but not stages 3–4. Synthetic pydyn fixtures for stages 8 and 11 are local-only, kept outside the repository and not committed. The parity loader and tests load fixtures from ATMOSTR_TM5_FIXTURES_DIR and skip with a clear message when the variable is unset or the required fixtures are absent.
15. Owner decisions (2026-10-30)
Q1 Apply our dry pin after flux integration, without recomputing the fluxes (TM5 order).
Q2 Write the mean of the two window-end flux sets, each balanced against the same window tendency (
window_mean).Q3 Implement the correct mathematics at the truncation edge and document every TM5 difference and its size; no quirk is reproduced.
Q4
vod2uvuses the IFS radiusm. Q9 Running pydyn's pure functions locally on synthetic inputs is approved. A request for a live TM5 dump waits and will be combined with the report of the
Nabla sign error ( gts:1804).Q11 Reduced Gaussian ships with lat-lon from the first flux pull request.
On 2026-10-31 the owner bundled the pull requests: TM5-0 (local-only fixtures, this page and the page TM5 boundary-layer diffusion, binary format gate), TM5-FLUX-1 (S3–S6: plumbing, spectral evaluator and quadrature, moist target construction, per-layer balance, end-to-end LL and RG) and TM5-FLUX-2 (S7 first real day with attributable deltas, S8 cubed-sphere direct target).
16. Implementation status
| Item | Status |
|---|---|
Binary version 5: flux_construction identity keys, readers accepting versions 4 and 5, inspector display | Implemented (TM5-0) |
pydyn balance and dynam0 fixtures | Generated locally outside the repository; not committed; loader and parity tests implemented using ATMOSTR_TM5_FIXTURES_DIR, with a clear skip when unset or fixtures are absent |
Construction types, configuration, dispatch hooks, InterfaceMassFluxField (S3) | Implemented (TM5-FLUX-1) |
| Spectral evaluator and quadrature for LL and RG rings (S4) | Implemented (TM5-FLUX-1) |
| Integrated PS, face fluxes and | Implemented (TM5-FLUX-1) |
| Per-layer balance, TM5 guards, RG factor-once solve (S6a) | Implemented (TM5-FLUX-1) |
End to end for LL and RG, new cases pre_ll72_tm5, pre_o24_tm5 (S6b) | Implemented; golden definitions only, references generated separately |
| First real day and attributable deltas (S7) | Real-day comparison memo and scripts/diagnostics/compare_flux_constructions.jl (TM5-FLUX-2a) |
| Cubed-sphere direct target (S8) | Implemented (TM5-FLUX-2b): refined rings, portable face/overlap gathers, independent W, direct per-layer graph solve, dry endpoint mean and shared CS write gates. Synthetic, exhaustive retained-harmonic and real ERA5 endpoint checks plus CPU cost measurements; pre_c24_tm5, pre_c24_tm5_tm5pbl, run_c24_tm5_cpu_f64 definitions added. Reference recording and GPU measurements remain separate. |
17. Synthesis backends and measurements
Gauss/Fourier executes with a total band budget of 32 target latitude cells, sliced from the existing quadrature geometry. Packed native coefficients are reused across bands; compatible bands refill the same bounded Legendre tables and reuse synthesis/sample buffers. Sequential surface, boundary and forcing Fourier transforms share scratch. Each cell retains its original node order. CPU surface synthesis uses a reusable single-mode panel with the original GEMM dimensions and column positions, preserving its accumulation order without retaining all latitude tables. Native CPU transforms use fixed 32-column GEMMs anchored to global latitude indices, padding partial tiles in both full and streamed execution. Thus band boundaries retain the same GEMM dimensions, leading dimensions and column positions. This avoids the OpenBLAS edge microkernel reductions that otherwise change Float32 and Float64 rounding with band size. CPU streaming retains bitwise equality on the tested CPU/BLAS configurations; this is not a promise of identical bits between different CPU architectures, BLAS versions or FFT libraries. Gauss/Fourier CPU FFTs use aligned scratch for one ring of fields at a time, so their plan shapes also remain independent of band size. This includes the forward and inverse transforms used for Fourier face integrals. These fixed-shape contractions and FFTs can change existing default Gauss/Fourier golden payloads at rounding level; references are not regenerated as part of this correction. Explicit trapezoids retain their existing arithmetic. CPU band pack/scatter/gather uses host loops. Up to four CPU workers divide the cell budget between them, with a fixed two FFT threads each. Plans preserve the global FFTW thread setting; explicit trapezoids keep their existing policy. These CPU measurements do not establish GPU memory fit, bitwise behavior or performance. Bands also limit interior rows to 128, allowing one complete larger cell; the CPU reduces concurrent workers when needed to keep their aggregate interior-row budget at 512 (or one larger cell). Thus coarse cells with more Gauss nodes also stream their tables. The default 32-cell budget is a constant; its division among workers depends on the explicitly configured Julia thread count, never runtime timing or CPU detection. Julia thread count changes scheduling; the two-thread FFT plan setting and native GEMM tiles remain fixed regardless of that division. Golden comparisons must still specify the CPU, precision and library/thread configuration.
After this correction, fresh CPU runs warmed both complete rules before measuring A B A B, with Julia/BLAS/global FFTW threads 16/1/1 and native batch 8:
| Input | Trapezoid reps (s) | Gauss/Fourier reps (s) | Ratio of means |
|---|---|---|---|
| T255 | 19.656 / 19.539 | 29.189 / 28.960 | 1.484× |
| T639 | 101.688 / 103.043 | 106.405 / 101.953 | 1.018× |
Both ratios meet the ≤1.5× target. A fresh isolated T639 Gauss/Fourier run peaked at 16.575 GB, 1.120× the retained isolated trapezoid peak of 14.802 GB. Repeated payloads match bitwise, including warmed versus isolated T639 Gauss/Fourier. Explicit Float64 trapezoid payloads at both truncations and the T255 Gauss/Fourier payload retain their prior bits. T639 Gauss/Fourier changes only am, bm, cm, with relative L2 differences of 2.79e-16, 3.06e-16, 1.23e-15 against the prior payload; mass, pressure, humidity and stored time-delta fields remain bitwise equal in this window. The frozen-input default LL72 non-PBL window also changes only am, bm, cm (relative L2 2.15e-16, 2.80e-16, 6.89e-16); other fields and its six-substep schedule are bitwise equal to the retained result. References were not regenerated. These are shared-host, one-window CPU measurements with the §13 inputs; they do not establish full-day or GPU performance.
CPURingSynthesis uses batched host GEMM and unnormalised FFTW; GPUSpectralSynthesis uses the same portable KernelAbstractions pack/scatter/ gather stages, device GEMM and device FFT. Refined samples stay on the device through quadrature. LL/RG synthesis, surface fields, integrands, FFT products and accumulators use the selected precision throughout (Float32 or Float64), including CPU selection. Geometry and reference coefficients are prepared on the host; device kernels introduce no Float64 arithmetic in Float32 plans. After transfer, endpoint pressure is converted to Float64 for the existing host dry pin and closure budgets. Direct CS three-dimensional products and face/overlap gathers accumulate in the selected synthesis precision (Float32 or Float64), including the total accumulator in cs_apply_face_kernel! (src/Preprocessing/Spectral/cs_face_gather.jl:44–58) and the overlap kernel (src/Preprocessing/Spectral/cs_spectral_integrals.jl:33–42). Reduced CS results are then copied to host Float64 endpoint arrays; that copy does not change the accumulation precision. Batches are limited to eight field levels in the day driver. LL/RG Gauss/Fourier packs U/V/D into one transform batch (24 component columns for eight native levels), reusing the Legendre operator and reducing per-mode launches. Explicit trapezoids keep their historical transform sequence. CPU CS surface LNSP, gradients and PS retain Float64; GPU CS surface work follows selected precision. Core does not load CUDA. With CUDA loaded, automatic precision uses Float64 on A100/H100/B200-class devices and Float32 for 3-D fields on L40S-class devices. FAST_MATH is rejected and the CUDA extension selects pedantic math through CUDA.math_mode!, restoring the caller's mode after each transform. GPU execution is opt-in in tests:
ATMOSTR_TEST_SPECTRAL_GPU=1 julia --project=test test/core/test_spectral_synthesis_backends.jlThe preprocessing CLI loads CUDA when this construction requests GPU synthesis. Library callers load their backend explicitly before planning. No silent CPU fallback occurs. The GPU runtime and performance checks require a GPU session; the CPU-array version exercises the portable kernels in ordinary CI. The spike's mirrored-table optimization, pinned staging and copy-free cuFFT execution are performance follow-ups; this implementation uses bounded batches and standard array/FFT APIs.
Device face construction and qualification
Backend-dispatched kernels pad native coefficients, construct LNSP gradients and form stable CS polar potentials. Samples, Fourier products and reduced face/cell outputs remain on the selected backend across all native-level batches and latitude bands. The default endpoint API transfers the completed reduced fields to the existing Float64 host pin, vertical merge, Poisson balance and closure. host_output=false exposes the resident arrays for validation. Geometry, cardinal-16 sparse assembly and accurate Legendre table precomputation remain host setup; the legacy nonspectral line-integral API is outside this device path. CPU outputs retain the aligned panels, fixed FFT batches and historical reduction order.
On Float32 device arrays, Neumaier compensation is applied to Gauss latitude sums, Fourier alias folding (real and imaginary parts independently), CS cardinal-16 gathers and conservative overlap sums. Float32 FMA also retains multiplication residuals in these reductions and complex Fourier products. Surface pressure transforms first remove the large constant LNSP mode, then restore its pressure factor when exponentiating the small anomaly. This avoids rounding the full logarithm at every FFT butterfly; scalar host setup prepares the pressure factor. All device correction variables and constants are Float32. Float32 LL/RG device plans also use stable vector harmonics at polar rows. CS GPU surface pressure and gradients now use the selected precision, removing the former compulsory Float64 device surface transform. Pedantic CUDA math wraps the complete operation; FAST_MATH/TF32 remains forbidden. CPU CS surface precision is unchanged.
For a fixed device, library stack and plan shape, deterministic GEMM/FFT algorithms and ordered per-face sums are expected to repeat. Actual bitwise repeatability must be measured on the GPU. Band size changes the device GEMM/FFT batch shapes, so bitwise band independence is not guaranteed; the runner reports both bitwise equality and numerical sensitivity. Neither property is established by CPU emulation.
Float32 compensation cannot recover errors in input conversion, vector coefficients, GEMM, FFT or exp(LNSP). A small retained-mode fixture with a nearly cancelling northward longitude integral has approximately 2.2e-5 relative Float32 error before device compensation. This is an observed residual, not a relaxed scientific bound. The LL/RG Gauss/Fourier CPU Float64 retained-harmonic bound remains 1e-6 per face. CS parity uses the existing cardinal-16 CPU quadrature, with its separately documented arc-discretization error. Actual L40S qualification measures scale-aware raw-face errors and end-to-end balanced fluxes separately.
scripts/validation/gpu_face_quadrature.jl runs the Float32-only L40S qualification. It compares retained rotation, sectoral and off-sectoral edge harmonics and all 137 levels of ERA5 2021-12-01 00 UTC at T255/T639, for LL 1°, reduced Gaussian and C90. CSV files report absolute errors, field-peak-scaled errors, resolved-face relative errors and counts outside 1e-6*abs(reference) + 2e-14*max(field_peak,1); the small absolute term handles symmetry zeros. It also measures repeated results, shape-qualified SHA-256 equality across two fresh Julia GPU processes, and LL/RG band budgets 32 versus 4. Two warmed full production windows per backend cover LL 1° and C90, with 16 Julia CPU threads, BLAS 1, global FFTW 1, production native batches and two FFT threads per CPU band worker. These window times include setup, IO, both endpoints, humidity, balance, closure/replay, positivity and binary writing. CUDA pool high-water marks and whole-device sampled memory peaks have separate labels. See scripts/validation/README.md. For each native level, the face scale is 1e-6 mixed per-face bounds remain diagnostic and do not replace these production criteria. CPU correctness jobs finish before timed windows begin.
L40S qualification (2026-11-03)
Actual GPU measurements use an NVIDIA L40S (46068 MiB), driver 615.71.10, Julia 1.12.6, CUDA.jl 5.11.3, CUDA runtime 13.2, CUBLAS 13.4 and CUFFT 12.2. All fields and surfaces use Float32 on the device under pedantic math. The CPU Float64 reference uses the identical quadrature and input coefficients. The real hour is ERA5 2021-12-01 00 UTC, all 137 native levels. Targets are LL 360×180, octahedral RG N64 and C90.
| T | Target | Harmonic max error / level RMS | Harmonic max level relative L2 | ERA5 max error / level RMS | ERA5 max level relative L2 |
|---|---|---|---|---|---|
| 255 | LL 1° | 1.06186e-05 | 4.45574e-07 | 1.9502e-06 | 2.16804e-07 |
| 255 | RG N64 | 4.35975e-05 | 3.7818e-07 | 1.10534e-05 | 1.71609e-07 |
| 255 | C90 | 5.1813e-06 | 2.67717e-07 | 9.41364e-06 | 2.80534e-07 |
| 639 | LL 1° | 1.52054e-05 | 4.89434e-07 | 1.73748e-06 | 2.05081e-07 |
| 639 | RG N64 | 3.37549e-05 | 2.88527e-07 | 9.07991e-06 | 1.73287e-07 |
| 639 | C90 | 2.25479e-05 | 7.81774e-07 | 9.2329e-06 | 3.13005e-07 |
The requested 1e-5 scale-aware maximum is met by all T639 ERA5 targets. The edge-harmonic fixtures exceed it on LL/RG and T639 C90; the largest observed value is 4.36e-5 (T255 RG). T255 RG ERA5 is slightly above it at 1.105e-5. The strict all-case maximum criterion therefore fails. This is retained in the launcher exit status. Resolved per-face relative errors can reach 156.7 on small cancelling T639 LL ERA5 faces, while its maximum error / level RMS is 1.74e-6. Per-level directional and joint L2 values and all historical mixed-bound violation counts remain available in CSV.
Same-plan and two-fresh-process PS/u/v/C arrays match bitwise in every case. LL/RG bands 32 versus 4 change bits; worst face sensitivity is 3.65e-7 of the field peak. CS has no band mode. Captured small LL/CS Float32-kernel PTX (397045 bytes) contains no .f64 registers or instructions. GEMM arrays and FFT plans are Float32; scalar pressure-factor preparation, accurate Legendre tables, geometry, pin, Poisson balance and closure remain host work.
Removing the constant LNSP mode before synthesis reduced T255 LL ERA5 maximum error / level RMS from 2.323e-5 to 1.950e-6 in the pressure-only pilot. PS maximum absolute error fell from 0.2158 to 0.02917 Pa. The final measurements also include FMA product-residual compensation. Both changes are confined to the device Float32 path. Full-day CPU LL72, O24 and C24 goldens retain bitwise equality with origin/main (38af9aca7); eight focused files, quick gate and the structure check pass.
Balanced fluxes, complete-window cost and memory
The actual written T639 00–01 UTC dry binaries use 137 native input levels, 34 merged output levels, merge threshold 100 Pa and Float64 storage. CPU/GPU schedules match: 108 substeps on LL and 8 on C90. Each measured GPU binary is compared with the CPU Float64 build of that same window, after humidity, pin, merge, balance, closure/replay, positivity and write.
| Target | Repetition | am relative L2 | bm relative L2 | cm relative L2 |
|---|---|---|---|---|
| LL | measured_1 | 1.62832e-07 | 4.33507e-07 | 1.86881e-07 |
| LL | measured_2 | 1.62832e-07 | 4.33507e-07 | 1.86881e-07 |
| CS | measured_1 | 1.70303e-07 | 2.07081e-07 | 1.9714e-07 |
| CS | measured_2 | 1.70303e-07 | 2.07081e-07 | 1.9714e-07 |
Worst balanced cm relative L2 is 1.86881e-07 on LL and 1.9714e-07 on C90; both meet the requested ≤1e-4 target. This supports accepting the measured Float32 GPU synthesis and face-product path for these ERA5 windows; there is no measured cm-accuracy need for CPU Float64 face products. The strict all-case raw-face maximum still fails. A workflow requiring that universal bound should retain CPU Float64; an optional GPU-synthesis/CPU- Float64-product split needs its own qualification before claiming the bound.
One warmup precedes two measured complete jobs per backend. Both use 16 Julia threads, BLAS 1 and global FFTW 1; CPU Gauss bands retain two FFT threads each. GPU runs use GPU1 plus 16 host threads. CPU correctness jobs finish before timing. Setup, geometry/table preparation, IO and the full production window are included; these are shared-host complete-job costs.
| Target | CPU16 reps (s) | GPU reps (s) | CPU/GPU mean ratio | Active pool peak (GiB) | Reserved pool peak (GiB) | Sampled device peak (MiB) |
|---|---|---|---|---|---|---|
| LL | 116.632, 119.965 | 84.939, 84.671 | 1.395x | 14.074 | 14.375 | 15699 |
| CS | 153.678, 155.063 | 42.022, 40.979 | 3.720x | 15.508 | 15.562 | 16847 |
CUDA pool high-water marks are exact over the process lifetime, including warmup; vendor allocations outside that pool are excluded. Whole-device usage is sampled every 100 ms and includes context, reservations and vendor allocations; short transients can be missed. Decimal and hexadecimal TOML pool counters are both parsed correctly. All accuracy-process peaks and per-field errors remain in the run's RESULTS.md and CSV files.
Streamed polar plans and LL host costs
Float32 LL/RG workspaces build polar derivative/divided FFT plans once for each compatible band shape. Shapes share one pair of latitude tables sized for the largest polar band; accurate host recurrences refill those tables before the next band executes. Polar sample scratch persists, and native VO/D staging prepares polar coefficients once per endpoint/level batch. This retains bounded latitude-table storage across repeated endpoints. Each shape retains its FFT/sample scratch, while cached polar coefficients scale with the native spectral levels. Other integration temporaries still use backend allocation and GC; the measured pool high-water remains the authoritative memory result.
A GPU1 LL profile after plan reuse captured 8,733 main-thread samples: 42.4% included ring synthesis, 7.4% included CUDA synchronization, and 20.7% included the daily humidity preload. These are overlapping stack fractions from a complete job on the shared host, not isolated phase times. CUDA KA launches, CUBLAS handles and CUFFT plans use the task's current stream. Synthesis now relies on that ordering between pack, GEMM, scatter and FFT, retaining one completion wait per synthesis call; other backends keep their existing barriers.
The matching profile after this change captured 8,768 main-thread samples: 35.1% included ring synthesis, 1.0% CUDA synchronization and 23.0% the humidity preload. Written am/bm/cm payloads were bitwise identical across the scheduling change. Complete profiled jobs took 103.436/104.127 s before/ after with concurrent CPU correctness work, so these profiles establish reduced synchronization overhead, not a complete-job speedup. Final warmed window timings above wait for those correctness jobs to finish.
Remaining performance follow-ups are the host-driven per-order launch/GEMM loop, repeated bounded latitude-table transfers and daily humidity/input IO. The daily preload still reads all 24 hours for a one-window benchmark because that is the production day setup. Chunking inputs or batching spectral orders would need separate implementation and qualification; the 108/8 substep schedules alone do not establish proportional replay cost.
Qualification checks exact case/field/native-level coverage and rejects nonfinite metrics, payloads and timings. Joint horizontal reference RMS must be positive; exact zero references in other fields pass only with zero error and zero scaled metrics. An isolated KA.CPU subprocess enables device staging, polar coefficients, pressure anomalies and Float32 compensation together, including non-unit-product cancellation in a launched gather.
Earlier CPU emulation
CPU execution of the complete portable Float32 kernel path on six LL 1° latitude cells (both poles and equator, all longitudes) gives the following maxima across sampled regions. The real hour includes all 137 native levels; these are bounded investigations using BLAS/FFTW, not GPU measurements.
| Truncation | Harmonic face peak-scaled error | Harmonic resolved-face relative error | Real-hour face peak-scaled error | Real-hour resolved-face relative error |
|---|---|---|---|---|
| T255 | 8.19e-7 | 1.46e-5 | 2.51e-6 | 1.89e-1 |
| T639 | 7.52e-7 | 1.79e-4 | 4.67e-6 | 4.57e-2 |
Resolved faces exceed 1e-12*max(field_peak,1) in magnitude. Large relative errors occur in small cancelling fluxes; the per-face bound fails despite small peak-scaled errors. Compensation and stable polar winds are enabled. These earlier CPU-emulation results precede the pressure-anomaly and FMA-product corrections. Actual CUBLAS/CUFFT measurements use the updated qualification runner. The progress file retains absolute errors and counts.
Measured synthetic divergence-identity residuals with explicit trapezoids
The 2026-10-31 real-wind probe found that point versus face integration changes raw net-divergence RMS by 9–26% in four native layers of one ERA5 window, before balance, pinning and drying. It also measured near-surface polar-cap wind edge differences of about 0.14 m/s in u and 0.176 m/s in v. These establish the importance of face integration and the edge terms; they are not measurements of final balanced cm or tracer differences.
References
Bregman, B., Segers, A., Krol, M., Meijer, E., and van Velthoven, P. (2003). On the use of mass-conserving wind fields in chemistry-transport models. Atmos. Chem. Phys. 3, 447–457.
Krol, M., et al. (2005). The two-way nested global chemistry-transport zoom model TM5. Atmos. Chem. Phys. 5, 417–432.
ECMWF IFS documentation, Part III: Dynamics and numerical procedures (the vorticity-divergence to wind relations used by
vod2uv!).