TM5 boundary-layer diffusion (Calc_Kzz)
This page specifies TM5CalcKzzField and TM5CalcKzzCSField, interface-exchange (dkg) fields for the existing ImplicitVerticalDiffusion operator. It transcribes TM5's live Calc_Kzz: the friction velocity, the hydrostatic interface heights, the Holtslag–Boville boundary-layer scheme bldiff, and the conversion of the heat diffusivity into an exchange rate in kg s⁻¹ across each level interface. It is a new field type; the existing diffusion schemes and the preprocessing port tm5_bldiff.jl stay unchanged.
Lat-lon and reduced-Gaussian column physics, v5 inputs and runtime integration are implemented. Cubed-sphere live refresh and its tracer adjoint are also implemented. Local pydyn fixtures are read only through ATMOSTR_TM5_FIXTURES_DIR; they are never committed (§14).
The page follows the design of 2026-10-30, with the owner answers of that day. Statements marked estimate are design 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.
| Abbreviation | Repository path |
|---|---|
K | proj/ct-unified/trunk/src/diffusion_kernels.F90 (ustar_calc, bldiff_core) |
SP | proj/ct-unified/branches/speedup/src/diffusion__speedup.F90 (Calc_Kzz) |
PC | proj/ct-unified/trunk/src/meteo__pclim.F90 (the active overlay of base/trunk/src/meteo.F90) |
MI | proj/ct-unified/trunk/src/modelIntegration.F90 |
conv | base/trunk/src/convection.F90 |
binas | base/trunk/src/binas.F90 |
lev | proj/levels/ml137/tropo34/src/dims_levels__ml137_tropo34.F90 |
rc | base/trunk/rc/meteo-tm5-noaa.rc |
| pydyn | pydyn/diffusion.py, pydyn/simple_diffusion.py |
Conventions
The equations of §2–§7 use TM5's bottom-up indexing: layers
The mask function of TM5 is
(jqif, K:1026–1037): pydyn/diffusion.py:71–73).
1. Inputs and cadence in TM5
Calc_Kzz is called from Proces_Update (MI:544), which runs once per dynamic step (base/trunk/src/tm5.F90:1303, after Meteo_Setup_Other at :1297). Its inputs:
Interface pressures
phlband layer massescome from spm, the surface pressure linearly interpolated to the middle of the step (SP:954–966;spmatPC:2209–2218).The heights
use the advected prognostic surface pressure sp(PC:1570,PC:5994,PC:6006–6020).The winds come from the balanced, time-interpolated mass fluxes
pu,pv.For ERA5 (
rc:287–298): model-level fields such asand are 3-hourly and interpolated ( interp3), instantaneous surface fields hourly (interp1), accumulated surface fields are hourly interval means (aver1); orography and land-sea mask are constant and the Olsson/Ganzeveld roughnesssrolsis monthly (rc:319–324).
Cache mode. NOAA production has read a precomputed dkg cache since 2026-05-07 and runs live Calc_Kzz only on a cache miss (base/trunk/src/diffusion.F90:72–76; rc:424–434). pydyn reports that this cache differs from live Calc_Kzz by about docs/state.md:382–386 in pydyn), and pydyn's physics dumps were made with the cache. The parity target here is live Calc_Kzz (owner decision Q10).
2. Friction velocity
ustar_calc (K:175–283, called by dd_calc_ustar, K:137–170), NOAA default branch. The TM5-4DVAR land variant (K:260–264) is off by default (K:100), and the speedup overlay aborts if it is requested (SP:255–259).
With the land fraction K:216), the surface stress
(K:189, K:228–233, K:265–270, K:277). The 10-m wind is carried up the log profile of the clipped ECMWF roughness to 75 m, where the wind is assumed independent of the surface (K:254–256), and back down with the Olsson roughness; the NOAA branch uses bldiff uses K:630, binas:152). pydyn: ustar (pydyn/diffusion.py:76–89).
Roughness (owner decision Q8). TM5's sr, listed among the analysis surface fields (rc:119), and srols (rc:120, rc:323–324). Q8 replaces only srols: its role (fsr. sr keeps its role (sr when present and otherwise uses fsr for both roles. If ERA5 provides the roughness only as fsr, both roles use the same field
In every case the formula needs srols is unknown until both datasets are compared on the same grid.
3. Interface heights
Meteo_Produce_Gph (PC:6006–6020), with
The top value is assigned, so K:595, K:601–603):
The top centre height is interpolated toward 200 km, and the boundary-layer height falls back to it when no crossing is found (§6). pydyn: geopotential (pydyn/diffusion.py:92–104).
4. Thermodynamics and surface buoyancy
Constants (K:486–509, K:873, binas):
| Symbol | Value | Source |
|---|---|---|
| 9.80665 m s⁻² | binas:55 | |
| 0.4 | binas:152 | |
| 1004 J kg⁻¹ K⁻¹ | binas:137 | |
binas:140 | ||
K:493 | ||
K:490, binas:98, binas:116 | ||
K:492, K:503 | ||
K:502 | ||
zacb, tiny | 0.3, 100, | K:505–507 |
sffrac, ssfrac, | 0.1, 0.1, 15 | K:488, K:495, K:509 |
fak, fakn | 8.5, 7.2 | K:499–500 |
K:486, K:873, K:855 |
Three dry-air gas constants appear and are kept separate. The heights use the literal 287.05 (PC:6014) with the virtual-temperature factor 0.608. bldiff uses binas:98), which gives 287.2979. The existing preprocessing port uses TM5_CONSTANTS.r_air = 287.307 (src/Parameters/PhysicalConstants.jl), Calc_Kzz constants are separate named values.
With K:595–597, K:624–630, K:752–754):
sshf and slhf are ECMWF downward-positive fluxes [W m⁻²]; the factor
5. Winds and free-atmosphere diffusivity
TM5 recovers the winds from the face mass fluxes (K:644–668): ae). pydyn: _winds (pydyn/diffusion.py:113–120).
At the interface above layer K:684–727):
The shear floor applies before the division by
6. Boundary-layer height: two passes
Vogelezang and Holtslag (1996), as cited at K:736; K:749–855. For each layer centre,
(K:762–764, K:827–829), and the bulk Richardson number is
Each pass scans upward to the first crossing of K:800, K:854). Work flags freeze the result once found, and an offset of 0.1 after the crossing keeps later denominators nonzero (K:791–796, K:845–850).
Pass 1 starts at
with ( K:760–800). At, gives , which never crosses, and the interpolation there would start from the surface ( K:771–772,K:780–782).Pass 2 starts at
( K:807–854). Withand the pass-1 height : , and ; the denominator keeps . The result is
( K:855).
The scan uses the full
7. Boundary-layer diffusivity, Prandtl number and entrainment
K:887–966, at the interface above layer
Masks. K:891–910).
Stable and neutral (Beljaars and Viterbo 1998, K:866).
(K:916–924).
Unstable (Holtslag and Boville 1993, K:639). With
(K:928–961; in the Prandtl number K:952). TM5 divides by _prandtl_inverse (src/Operators/Diffusion/pbl_physics.jl) is not its reciprocal and is not reused.
Entrainment. At the interface whose centre heights straddle K:903–905), and
(K:964–966). TM5 applies no threshold, ceiling or floor here; §9 describes the one guard we add.
8. Exchange rate and the mixing cutoff
(K:980–988), in kg s⁻¹, built directly from the interface diffusivity without a centre-dkg (pydyn/diffusion.py:256–263).
tropo34. NOAA's 34 levels (lev:43–47) are AtmosTransport's ml137_tropo34a (ECHLEVS_ML137_TROPO34A in src/Parameters/MetSourceConstants.jl), not ml137_tropo34. There lev:34; the comment at lev:32–33 places the top of layer 26, ECMWF half-level 57, near 86 hPa). In top-down indexing, layers
Other level sets (owner decision Q7). The cutoff is the pressure equivalent of tropo34a level 26: mix only the layers whose reference mid-layer pressure exceeds the pressure of ECMWF L137 half-level 57. From config/era5_L137_coefficients.toml, gchp_pbl_layer_count (src/Operators/Diffusion/gchp_nonlocal_pbl.jl), leaving the GEOS-Chem results bitwise unchanged. The cutoff is stored as the exact 8614.336891 Pa literal in Parameters, rather than reading the coefficient file at runtime. A coefficient-file test verifies the literal and the tropo34a count. Free-atmosphere
9. Guards and the entrainment NaN
| Item | TM5 | Implemented here |
|---|---|---|
| sea | same | |
| Shear and bulk | floor | same |
| signed | same | |
| same | ||
| Masked branches | arithmetic masks | selection ifelse(j, x, y); selects the same value wherever both branches are finite |
| Entrainment | unguarded (below) | K_vh = ifelse(jE & isfinite(K_entr), K_entr, K_BL) |
| same |
The entrainment NaN. If MAX with a NaN argument is processor-dependent, so TM5's pydyn/diffusion.py:20–25, :250–252); its readable version simple_diffusion.py selects the used branch instead (:19–21).
The guard keeps a finite @fastmath, no reassociation, and integer powers such as u_s^3, the form pydyn uses. Julia's exp, log and power functions are not the C library's, so parity is tested against the tolerances of §14, not bit for bit.
Two other unused-branch paths. TM5's masks also evaluate two expressions that are non-finite only in the branch that is not used:
Equal consecutive bulk Richardson numbers. Before the crossing (
), the interpolation term is evaluated anyway; equal values give a division by zero, and the mask makes NaN ( K:784–785,K:839–840; pydynsimple_diffusion.py:19–21names this case). At an actual crossing the two values cannot be equal, because the previous one is at most 0.3 and the new one exceeds it.exactly. With the stable term of is ( K:921), and the NaN reachesthrough , which is processor-dependent.
Branch selection takes the used branch in both cases (the previous
10. Integration in AtmosTransport
Topology-specific fields inside the existing operator.
struct TM5CalcKzzField{FT,N,D<:AbstractArray{FT,N},S,P,M} <: AbstractTimeVaryingField{FT,N}
dkg::D # topology-native compact interface exchange [kg/s]
scratch::S # bottom-up column inputs and intermediates
params::P # precision-specific TM5 constants and mixing cutoff
metrics::M # mesh metrics built by Models.Physics, adapted with the field
guard_warned::Base.RefValue{Bool} # host-side once-per-run warning state
endFiles:
src/Operators/Diffusion/TM5CalcKzzField.jl(type, Adapt,refresh_tm5_calc_kzz!) andsrc/Operators/Diffusion/tm5_calc_kzz.jl(one pure@inlinecolumn function for CPU and GPU, generic in the float type, with no Float64 promotion; in Float32 it forms, the bulk-Richardson numerator and the log-pressure ratios with reduced cancellation, and compensates the pressure sum, §14). The column function returns and its intermediates ( , , , , Ri, both height passes, , full and active guard counts); column tests call it directly. Solve.
DkgExchangereads interface exchange directly. Its factor method feeds the existing structured and face-indexed backward-Euler solves, including their flux-form tracer-mass update and column ledger.TM5CalcKzzCSFieldsupplies six interior D panels to the same six-panel solver. It has nopanel_fieldmethod: a generic Kz path must fail rather than interpret exchange in kg/s as diffusivity in m²/s.Refresh. A new
_refresh_pbl_kz_for_window!method (src/Models/Runner/driven_physics_refresh.jl) runs once per met window, after the window-advance air-mass reset;_refresh_dz_for_window!gets a no-op method. No new hook is needed.Configuration.
[diffusion] kind = "tm5_calc_kzz", with the existing surface-flux couplings (SplitSurfaceFluxCouplingby default,DiffusiveSurfaceFluxBoundarywithsurface_flux_boundary = true, which reduced-Gaussian runs reject today).is computed when the field is materialised (§8). PrecomputedCSDkgFieldandGCHPNonlocalPBLFieldstay untouched.
CS metrics and bounded scratch. The field owns one column-chunked scratch, shared across all panels, with at most 65,536 columns. LL/RG use the same chunking with their existing indexing and arithmetic order. Scratch is approximately 16 working-precision values per chunk column and layer, plus a guard count. At L137 the default chunk needs about 575 MB in Float32 or 1.15 GB in Float64 (decimal units), excluding D and metrics. D is stored on interior arrays; mass and fluxes are read through their halos without exchanging D halos.
For a CS cell of area A and mass m, recover face-normal speeds from the stored amounts over s seconds:
With cs_face_edge_lengths and panel_cell_local_tangent_basis, then rounded once. Calc_Kzz uses squared wind differences, so any fixed orthonormal frame per column gives the same D. This also handles GEOS-native panel orientation. Both surface couplings are supported on CS.
Inputs (owner decision Q5). Pressure, carrier mass and winds come from the runtime state; the binary adds only
Calc_Kzz input | TM5 | Implemented |
|---|---|---|
| Pressure (for | sp; phlb and spm | one profile from the window-start carrier mass: |
| midpoint moist mass | runtime carrier mass | |
balanced midpoint pu, pv over the midpoint | stored window amounts: flux_application_seconds(window_dt, steps, flux_kind) and panel_cell_local_tangent_basis | |
| 3-hourly, interpolated to the step midpoint | tm5_t, tm5_q: mean of the two hourly analysis endpoints on target levels, merged with mass weights | |
sr | hourly, interpolated | mean of the two hourly endpoints; sr if available, otherwise fsr |
sshf, slhf, ewss, nsss | hourly forecast interval means | ERA5 reanalysis hourly accumulations over the window divided by its length |
lsm, oro | constant | constant; lsm stored as a fraction |
srols | monthly Olsson/Ganzeveld | ERA5 forecast surface roughness fsr (Q8) |
Estimate: using dry instead of moist mass ratios changes the recovered winds by tm5_q is used instead of the qv_start and qv_end sections because cubed-sphere binaries do not carry humidity endpoints.
Binary section group tm5_pbl (implemented). Optional, valid only in format version 5, all-or-nothing, one record per window:
| Sections | Shape | Units and sign |
|---|---|---|
tm5_t, tm5_q | cell | K; kg kg⁻¹ of total air |
tm5_lsm | surface | fraction 0–1 |
tm5_sr, tm5_fsr | surface | m (tm5_fsr replaces srols, Q8) |
tm5_u10, tm5_v10 | surface | m s⁻¹ |
tm5_ewss, tm5_nsss | surface | N m⁻², interval mean |
tm5_sshf, tm5_slhf | surface | W m⁻², ECMWF downward-positive (unlike the existing upward-positive pbl_hflux) |
tm5_oro | surface | m² s⁻² |
Estimate: about 40 % of a C90 L34 window payload.
Enable the input writer with [preprocessing] include_tm5_pbl = true, input.thermo_dir and input.surface_dir. This is an hourly ERA5 spectral LL/RG/CS option. LL/RG can combine it with [preprocessing] spectral_flux_construction = "tm5_spectral"; those binaries carry both the TM5 flux identity and the complete tm5_pbl group. CS uses its existing spectral staging construction, recorded as point_sampled_spectral. LL-binary→CS remapping also passes the group through, with T/q weighted by source moist mass and surface fields by area. Averaging the stress and 10 m wind components before their magnitudes can underestimate friction velocity where direction varies within a cell; this applies to all targets and matters most for CS cells much coarser than the source. That path records regridded_transport_binary and the source construction. N320→CS input assembly remains deferred pending archive coverage. The thermo sidecar must contain t in K and q in kg/kg; the surface archive must contain the ten primitives, including the next day's 00 UTC endpoint. NetCDF, split ZIP and ARCO surface layouts are supported. Surface primitives (lsm, stresses, heat fluxes, sr/fsr, 10 m winds and orography) are cell-area means on the actual LL, RG or CS mesh, using the package's shared conservative regridder with intensive-field semantics. In particular, lsm is the coastal cell's land fraction, rather than the value at its centre. Excursions of the remapped fraction within 1e-12 of [0, 1] are clamped: rounding in the area mean leaves it up to about 3e-15 above 1 in all-land cells (LL 72×37, 2021-12-01). Larger excursions fail the binary validator. This follows TM5's two-dimensional area-aver input convention (base/trunk/src/tmm.F90:1062–1065). Roughness uses an arithmetic area mean. The shared regridder's spherical-polygon approximation and RG ring-boundary slivers also apply here (see conservative regridding). T/q retain coordinate-aware bilinear sampling at target cell centres and are merged with native moist layer-pressure weights before the endpoint mean. The LL and RG thermo paths share the existing bilinear sampler. The merge weights use each construction's stored window-start total surface pressure. Since that pressure can differ between constructions, merged T/q can differ beyond rounding; each merge is consistent with its binary's hybrid layers. Day-local input ownership reuses the shared hourly thermo endpoint, surface readers (including split-ZIP extraction), and surface remap weights. Thermo files stay open with their bilinear weights for the day. Consecutive records are decoded in temporal-chunk blocks capped at three hours, then only sampled target endpoints are retained. The next-day file supplies just midnight. This avoids repeated chunk decompression while preserving each record's scalar conversion, orientation and interpolation; the pressure-dependent layer merge and endpoint average keep their operation order. grid.target_vertical pressure-overlap remapping and grid.level_top != 1 are rejected before synthesis; at least two output layers are required. ERA5 reanalysis accumulations are hourly interval totals labelled by their ending time, not cumulative forecast-since-initialisation values. The reader validates units and divides by the supplied interval; already exported rates keep their values and ECMWF heat-flux signs.
Select the runtime with:
[diffusion]
kind = "tm5_calc_kzz"
surface_flux_boundary = falseThe (1-q) pressure correction dispatches on carrier-mass basis, rather than surface_pressure_basis: these are independent contracts. In particular, the normal dry-mass binary records total surface pressure but still needs the dry-to-total layer-mass correction. Archived ps does not set the runtime pressure profile.
Runtime column scratch holds approximately 16 × ncells × nlevels floating-point values, plus one integer guard count per cell; the D cache adds one field of ncells × nlevels. PBL height is a local scalar, with no extra stored diagnostic. For 34 layers and about 542,000 cells this is approximately 1.18 GB of Float32 scratch before D, metrics and solver workspaces. LL72/O24 sizes and CPU timing are measured in the implementation handoff; large RG runs must budget this allocation. A smaller-scratch implementation remains future work.
11. Differences from TM5
| Topic | TM5 | Implemented here | Note |
|---|---|---|---|
| Refresh cadence | every dynamic step | once per hourly met window | follows the analysis-window decision |
| Pressure | two: advected sp for spm for phlb and | one, from the window-start runtime state | refreshed once per window, so the difference spans up to the surface-pressure change over the window |
| Inputs | forecast fields, midpoint interpolation | analysis window means; accumulations over the window | surface primitives are area means on both LL and RG; T/q use point interpolation (§10), whereas TM5 supports area/mass averaging for 3-D inputs |
| Mass basis of | moist spm mass | runtime carrier mass (dry) | |
| Roughness | Olsson/Ganzeveld srols for | ERA5 forecast roughness fsr for sr keeps its role (§2) | Q8; size not yet measured |
| Wind recovery length | effective face-metric lengths; on uniform LL, the relative differences are approximately | ||
| Entrainment NaN | propagates or compiler-defined | guarded (§9) | differs only where TM5 is non-finite |
| Masked arithmetic | both branches evaluated | ifelse selection | same value where finite |
| Cutoff | pressure equivalent on any level set (§8) | Q7; identical on tropo34a | |
| Solve | dense inverse of a matrix combined with convection (conv:475–476, conv:521–529), split x y z v s c c s v z y x (base/trunk/src/dims.F90:93–94) | separate backward-Euler diffusion solve at the palindrome centre | Q6: the combined matrix is deferred; the splitting difference remains |
| Precision | Float64 on CPU | Float32 on GPU in production; parity target is Float64 on CPU | Q12; Float64 keeps TM5's literal arithmetic; Float32 uses algebraically identical forms with reduced cancellation (§14); tests report Float32 crossing changes separately |
| Data | production dkg cache | live Calc_Kzz | Q10 |
| Runtime composition | diffusion inside convection, Check_CFL, slopes, polar clustering | runtime unchanged | bounds any "TM5-style" claim |
TM5's combined matrix also divides by the prognostic mass m_dat (conv:314, conv:475–476), whereas spm mass.
12. Relation to the existing schemes
All existing schemes stay bitwise unchanged.
| Aspect | tm5_bldiff.jl (preprocessing) | WindowPBLKzField, LocalHoltslagBovilleKzField | TM5CalcKzzField |
|---|---|---|---|
| Where it runs | preprocessing; writes :dkg for cubed-sphere binaries (runtime kind = "tm5_dkg") | runtime, layer-centre | runtime, interface |
| Entrainment | TM5 form only for | none | TM5 form, guarded only where non-finite |
| Source | port of TM5 cy3-4dvar bldiff (file header) | Beljaars–Viterbo with PBL scaling; GEOS VDIFF local scheme | TM5 ct-unified live Calc_Kzz |
_beljaars_viterbo_kz, _prandtl_inverse and _shear_enhanced_kz are not repurposed. A leaf function of tm5_bldiff.jl may be shared only where constants, arithmetic order and mask semantics agree; it then moves to the earlier Diffusion module and the old wrapper stays bitwise unchanged.
13. Adjoint and window capture
For fixed
D depends on meteorological inputs, face fluxes and carrier air mass, and never on tracer mass. Even with air_mass_reset_mode = :none, prognostic air mass is advanced only by fixed meteorological fluxes. Thus D is forcing in every reset mode; derivatives through meteorology, friction velocity or K are outside the tracer-only adjoint.
cs_adjoint_inputs executes production's window refresh and freezes a copy of the six D panels once per met window. The captured field omits refresh scratch and geometry, and steps within a window share its operator. Replay uses the same DkgExchange forward solver. The capture keeps no layer thickness (diffusion_layer_thickness = nothing) because this solver never reads one. Under :none, capture advances carrier mass with production advection so the next window sees the same prognostic mass as the forward run. Tracers during capture are disposable. D is neither recomputed during replay nor stored in a tape slot. The tape pool, byte estimate and AutoTape policy are unaffected: forcing/operator objects are retained by reference outside the tape.
Frozen D requires
14. Tests and tolerances
| Stage | Criterion |
|---|---|
| Float64, | |
| Free | |
| Boundary-layer height | crossing indices exact away from thresholds; |
| inactive zeros exact; with injected | |
| Solve | backward residual |
| Float32 against Float64 CPU, synthetic fixture columns (well conditioned) | active K and D: |
| Float32 against Float64 CPU, real ERA5 windows | D per nonzero entry: median |
| CUDA Float32 against CPU Float32 | D per nonzero entry: p99 |
Cubed-sphere CPU coverage. test_tm5_pbl_cs.jl checks the shared column physics, chunk sizes, C48 versus 2.5° LL columns, rotation invariance in both panel conventions, uniform tracer, column conservation, packed/single solves and the direct-D transpose including an empty layer. Face fluxes from the production LineIntegralFaceFluxes recover analytic wind speeds with RMS errors (m s⁻¹) of 0.05658, 0.01420 and 0.003553 for solid-body flow on C12, C24 and C48; the deformation flow gives 0.14306, 0.03585 and 0.008957. Both decrease by about four per refinement.
Production DrivenSimulation and frozen-D adjoint replay agree bit for bit for both surface couplings and :preserve_tracer_mass/:none resets. With :none, capture advances carrier mass through production advection; that advance currently also transports all tracers, so capture cost scales with tracer count. A future mass-only advance must preserve the carrier bits. Full and Stride checkpoints agree. The new split and boundary/:none footprint cases give relative errors of
Edge inventory (synthetic). Neutral
pydyn fixtures. Local-only fixtures hold synthetic columns run through pydyn's pure functions (ustar, geopotential, _winds, bldiff, dkg, calc_kzz; owner decision Q9). They are generated and kept outside the repository, are not committed, and reproduce TM5's unguarded arithmetic, including the entrainment NaN. The parity loader and tests in test/core/test_tm5_calc_kzz.jl load fixtures from ATMOSTR_TM5_FIXTURES_DIR and skip with a clear message when the variable is unset or the required fixtures are absent. Matching the Calc_Kzz equations does not establish CFL, advection-moment or full-model parity with TM5, and an absent or skipped fixture is never reported as passed.
Float64 CPU comparison on the 16 local synthetic columns: maximum relative error in K_vh is 6.03e-14, in D 6.02e-14; maximum absolute errors are 7.06e-21 m²/s and 7.47e-14 kg/s, respectively. Heights, both PBL-height passes, friction velocity and Obukhov length match exactly on this fixture. All 32 Float32 PBL-height crossing indices agree with Float64. Two interfaces are built with exactly equal Float64 1.388e-4 maximum per nonzero entry and 2.553e-5 maximum column L1 relative error; Float64 arithmetic on the Float32-rounded inputs alone gives 1.390e-4 and 2.562e-5. Active K has maximum relative error 1.357e-4. Across all K interfaces, including those above the mixing cutoff, the maximum is 3.408e-3, at the top interface of one column (layer-mean pressures 211 and 54 Pa, 4.54e-6 per entry and 1.52e-6 in column L1; literal Float32 differences of 1.5e-4 and 4.0e-5. These measurements cover the finite TM5 values; non-finite entrainment checks use the documented guard. They are column parity, not full-model TM5 parity.
Float32 on real data. K is a function of the gradient Richardson number, whose numerator
with −144.27376 + 144.26372 = −0.010040283 K, an amplification of about 28,738. This form supplies Ri, the interface 1.1e-7 against 1.8e-5 K for 1.2e-4 against 1.5e-4 K for 0.3–0.5). The geopotential increment uses expm1 formulation uses Float32 exp and log, avoiding Base's Float64 fallback on AMDGPU. CUDA (libdevice), AMDGPU and Metal.jl provide Float32 log1p. Kahan's pressure additions contain no multiply that FMA contraction could fuse. Each change is a helper with a Float64 method that keeps TM5's literal expression, so Float64 results are bitwise unchanged.
Before the Kahan expm1 replacement, measured on 2021-12-01 (O24, windows at 00, 01, 02 and 12 UTC, identical window-start inputs), the Float32 D error relative to Float64 per nonzero entry has median 6.1e-6–6.3e-6, p99 5.3e-5–5.5e-5, p99.9 1.6e-4–1.8e-4 and maximum 1.1e-3–3.9e-3. The column L1 error has p99 8.9e-5–1.05e-4 and maximum 3.9e-4–3.4e-3. 0.25–0.31 % of entries exceed 1e-4 and at most 0.0051 % exceed 1e-3. No PBL-height crossing index or stability sign changes, and no interface needs the entrainment guard, as in Float64. Rounding only the Float64 inputs to Float32 gives median 4.3e-6–4.5e-6, p99 4.8e-5–5.2e-5 and maximum 1.1e-3–5.8e-3, with 0.22–0.27 % of entries above 1e-4. The Float32 column is up to approximately 10.2 % above this input-rounding floor in p99; the maximum is at most approximately 0.13 % above the floor. Replacing expm1 with Kahan's formulation changes p99 by at most 0.46 % across these four windows (up to 10.31 % above the floor); the maximum changes by at most 1.49 %, and remains at most approximately 0.13 % above the floor. Literal Float32 differences of 1.2e-5, p99 1.3e-4, maximum 1.0e-2 and 1.7–1.9 % of entries above 1e-4. The remaining Float32 arithmetic error (median 3.0e-6 against Float64 on the rounded inputs) comes mostly from the wind shear, because the recovered Float32 winds are differenced across interfaces (1.3e-6). Relative input noise of 1e-7 gives 3.3e-3–7.8e-2. In one 900 s diffusion solve, the Float32 D changes a surface plume's mixing ratio by at most 9.2e-5 of the column maximum (Float64 D from the rounded inputs: 8.8e-5; literal Float32: 3.2e-4).
CUDA. On an NVIDIA L40S, CUDA Float32 D differs from CPU Float32 by median 2.2e-7, p99 4.6e-6–4.8e-6 and at most 4.7e-5–1.8e-4 (O24, the four windows above) and 6.3e-5 (LL 72×37, 00 UTC; median 2.1e-7). With literal Float32 differences of 5e-5 and maxima 7.7e-4 and 1.3e-3. The remaining differences come from libdevice math and FMA contraction; the reformulation greatly reduces their amplification near the surface. Pressures agree bitwise on all these windows, so the compiled Kahan sum matches the CPU one, and the refresh kernel's PTX has no Float64 instruction. CUDA Float32 against CPU Float64 has a maximum of 3.9e-3 (O24). On LL 72×37 at 00 UTC it has a maximum of 1.3e-3 and a column L1 maximum of 5.4e-4 (literal Float32: 3.1e-3 and 1.9e-3). The compensated forms made the refresh kernel 4 % slower: 0.326 to 0.339 ms for O24 (3168 columns) and 3.53 to 3.67 ms for 422,400 columns of 34 layers (O24 columns tiled on a synthetic mesh). Three-window Float32 CUDA runs with live Calc_Kzz change the total air mass by -3.1e-9 (O24) and -1.9e-9 (LL 72×37); diffusion does not change air mass.
15. Owner decisions (2026-10-30)
Q5 Pressure, air mass and winds come from the runtime state; the binary adds only
, and the surface fields. Q6 The combined convection and diffusion matrix is deferred until pure diffusion parity passes; it must not require changes to the surface-flux operator.
Q7 On level sets other than tropo34a, the cutoff is the pressure equivalent of tropo34a level 26 (§8).
Q8 The ERA5 forecast surface roughness replaces the Olsson/Ganzeveld
srols; the difference is documented (§2).Q9 Local generation of pydyn fixtures from synthetic inputs is approved; the fixtures are not committed. A request for a live-
Calc_Kzzdump waits.Q10 The parity target is TM5's live
Calc_Kzz, not the NOAAdkgcache.Q12 Float32 on the GPU is acceptable for production; parity tests use Float64 on the CPU.
Column physics, binary inputs and live refresh on lat-lon, reduced-Gaussian and cubed-sphere grids are implemented, together with the frozen-diffusivity tracer adjoint. The combined convection and diffusion matrix stays deferred.
16. Implementation status
| Item | Status |
|---|---|
| This page; binary version-5 format gate | Implemented |
pydyn Calc_Kzz column 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 |
| B2: bldiff constants, column function, shared layer-count rule | Implemented |
B3: tm5_pbl section group, ERA5 surface readers, lat-lon and reduced-Gaussian writers | Implemented |
B4: TM5CalcKzzField, DkgExchange, lat-lon and reduced-Gaussian runtime, golden regression cases | Implemented |
| B5: cubed sphere, adjoint | Implemented; frozen per-window D, no met derivatives |
| B6: combined convection and diffusion matrix | Deferred (Q6) |
References
Beljaars, A. C. M., and Viterbo, P. (1998). Role of the boundary layer in a numerical weather prediction model. In Clear and Cloudy Boundary Layers, A. A. M. Holtslag and P. G. Duynkerke (eds.), Royal Netherlands Academy of Arts and Sciences, Amsterdam, 287–304.
Holtslag, A. A. M., and Boville, B. A. (1993). Local versus nonlocal boundary-layer diffusion in a global climate model. J. Climate 6, 1825–1842.
Jacobson, M. Z. Fundamentals of Atmospheric Modeling, sections 8.3 (friction velocity) and 8.4 (surface roughness lengths), cited in TM5 at
K:220–236.Krol, M., et al. (2005). The two-way nested global chemistry-transport zoom model TM5. Atmos. Chem. Phys. 5, 417–432.
Vogelezang, D. H. P., and Holtslag, A. A. M. (1996). Evaluation and model impacts of alternative boundary-layer height formulations. Bound.-Layer Meteorol. 81, 245–269.