MetDrivers API
For narrative coverage of the transport-binary format and the replay-gate contract, see Binary format.
AtmosTransport.MetDrivers Module
MetDriversMeteorological data adapters for the basis-explicit transport architecture.
Provides:
abstract driver types with capability traits;
topology-generic transport-binary readers; and
replay continuity and decoded forcing windows.
AtmosTransport.MetDrivers.AbstractMassFluxMetDriver Type
AbstractMassFluxMetDriver <: AbstractMetDriverReads pre-computed mass fluxes (am, bm, cm, m).
sourceAtmosTransport.MetDrivers.AbstractMetDriver Type
AbstractMetDriverSupertype for all meteorological data drivers.
Required methods
total_windows(driver) -> Int
window_dt(driver) -> FT (seconds per met window)
steps_per_window(driver) -> Int
steps_per_window(driver, win_index) -> Int
steps_per_window_schedule(driver) -> Vector{Int}
load_transport_window(driver, win_index)
driver_grid(driver)
air_mass_basis(driver)
surface_pressure_basis(driver)Custom drivers that do not override surface_pressure_basis retain the historical interpretation that their window surface_pressure is total (moist-air) pressure. Drivers carrying dry pressure must return DrySurfacePressure() explicitly.
AtmosTransport.MetDrivers.ConvectionForcing Type
ConvectionForcing{CM, DT, TM, CB}Container for one window (or one substep) of convective mass-flux forcing. Four optional payload slots:
cmfmc— cloud updraft mass flux at level interfaces. Supported layouts are structured(Nx, Ny, Nz+1), face-indexed(ncell, Nz+1), and cubed-sphere panel tuplesNTuple{6, <:AbstractArray{FT, 3}}with per-panel shape(Nc, Nc, Nz+1). GCHP /CMFMCConvectionconsumer.dtrain— detraining mass flux at layer centers. Supported layouts matchcmfmc, with layer-center shape(Nx, Ny, Nz),(ncell, Nz), orNTuple{6}of(Nc, Nc, Nz). Whennothing,CMFMCConvectionfalls through to Tiedtke-style single-flux transport.tm5_fields :: Union{Nothing, NamedTuple{(:entu, :detu, :entd, :detd)}}— four-field entrainment/detrainment arrays at layer centers(Nx, Ny, Nz). TM5 /TM5Convectionconsumer.cloud_base— convective cloud-base layer (top-down index stored as a float), 2-D like the surface fields (NTuple{6}of(Nc, Nc)on the cube), ornothing. GEOS-Chem takes it from DQRCU;CMFMCConvectionotherwise derives it from the lowest non-zero CMFMC edge. Requirescmfmc.
Invariants (enforced by the inner constructor)
DTRAIN requires CMFMC.
dtrain !== nothing ⇒ cmfmc !== nothing. DTRAIN without CMFMC is meaningless (DTRAIN detrains from the updraft mass flux; no mass flux, nothing to detrain).Dual capability is allowed. A binary may carry both CMFMC and TM5 payloads simultaneously; the sim selects which capability to consume based on the installed operator. The invariant here only enforces the load-bearing constraint above.
Capability is INVARIANT for the lifetime of a
DrivenSimulation.copy_convection_forcing!enforces strict tuple match betweendstandsrcso a mid-run capability toggle raises an error — catches both "stale values" (dst has a field src doesn't) and "missing destination" (src has a field dst doesn't).
Default construction
ConvectionForcing() produces an all-nothing placeholder. This is the initial value of TransportModel.convection_forcing; DrivenSimulation allocates real buffers at construction via allocate_convection_forcing_like.
See also
copy_convection_forcing!— per-window refresh copy.allocate_convection_forcing_like— sim-construction allocation.
AtmosTransport.MetDrivers.PBLSurfaceForcing Type
PBLSurfaceForcing(pblh, ustar, hflux, t2m[, eflux])Container for raw surface fields used by the PBL diffusion closure.
Fields are topology-shaped 2D arrays:
structured:
(Nx, Ny)face-indexed:
(ncell,)when such a path is addedcubed sphere:
NTuple{6, <:AbstractMatrix}with one(Nc, Nc)panel
Units follow the canonical runtime contract:
pblh- boundary-layer height [m]ustar- friction velocity [m s^-1]hflux- upward sensible heat flux [W m^-2]t2m- 2 m air temperature [K]eflux- upward latent heat flux [W m^-2], ornothing(only GEOS-Chem's non-local VDIFF scheme needs it)
AtmosTransport.MetDrivers.ReplayScratch Type
ReplayScratch(dims)Per-cell work arrays of the replay check, of shape dims (the air-mass shape): div, the net horizontal outflow of each cell, and mag, the sum of the magnitudes of its horizontal face fluxes. Allocate one per grid and reuse it across windows.
AtmosTransport.MetDrivers.air_mass_basis Function
Return the binary's declared air-mass basis (:dry or :moist).
AtmosTransport.MetDrivers.allocate_convection_forcing_like Method
allocate_convection_forcing_like(src::ConvectionForcing, backend_hint) -> ConvectionForcingBuild a destination ConvectionForcing whose array fields are similar(src_field) — same shape, same element type, same backend (inferred from backend_hint, typically model.state.air_mass). Capability (which fields are non-nothing) exactly matches src.
Used by DrivenSimulation construction to seed model.convection_forcing from the first loaded window. After this step, copy_convection_forcing! reuses the same buffers across all subsequent substeps.
The all-nothing placeholder ConvectionForcing() produces another all-nothing placeholder when run through this helper.
AtmosTransport.MetDrivers.copy_convection_forcing! Method
copy_convection_forcing!(dst::ConvectionForcing, src::ConvectionForcing) -> dstCopy src's arrays into dst's preallocated buffers in place. Preserves === identity of the destination's arrays — this is what makes the per-window refresh zero-allocation after the sim-construction allocation step.
Enforces strict capability match first: both sides must have identical _cap(...) tuples. Otherwise throws ArgumentError. This catches both directions of mismatch (dst has a field src lacks, or vice versa) — both are silent correctness hazards.
Used by DrivenSimulation._refresh_forcing! to populate sim.model.convection_forcing from sim.window.convection at the first substep of each window.
AtmosTransport.MetDrivers.current_time Method
current_time(meteo) -> Float64Simulation time [s] at the start of the next step. Threaded through operator apply! methods:
apply!(state, meteo, grid, op, dt; workspace)Every operator that consumes time (ExponentialDecay rates, ImplicitVerticalDiffusion Kz refresh, future emission-rate StepwiseFields, etc.) reads current_time(meteo) once per call and passes the resulting scalar to each update_field!(f, t).
Canonical usage
Production:
meteo = sim::DrivenSimulation; returnssim.time(Float64), set from the window and step counters after eachstep!(sim). Seesrc/Models/Runner/driven_stepping.jl.Unit tests without a sim:
meteo = nothing; returns0.0.
AtmosTransport.MetDrivers.driver_grid Function
Return the grid reconstructed and owned by the runtime driver.
sourceAtmosTransport.MetDrivers.flux_application_seconds Method
flux_application_seconds(dt_seconds, steps, fk::Symbol) -> Float64Seconds spanned by ONE stored flux amount — the normalization interval for converting stored am/bm/cm mass amounts [kg] to rates or winds. Per-substep storage: one palindrome application = dt / (2 * steps). Full-window storage: the full met window = dt. Every diagnostic that divides a stored flux by a time interval must use this (not a hand-rolled dt/(2*steps)), or it is wrong by 2 * steps on full-window binaries.
AtmosTransport.MetDrivers.flux_interpolation_mode Method
How should flux forcing vary within a met window?
sourceAtmosTransport.MetDrivers.flux_storage_substep_scale Method
flux_storage_substep_scale(::Type{FT}, steps, fk::Symbol) -> FTMultiplier converting STORED flux amounts to per-palindrome-application amounts (what the transport kernels consume): 1 for per-substep storage, 1/(2*steps) for full-window storage. Transport-style script consumers that feed raw window fluxes into kernels must scale by this (the runtime's DrivenSimulation does so automatically at every forcing refresh).
AtmosTransport.MetDrivers.load_transport_window Function
load_transport_window(driver, win)Load one typed forcing window from the transport binary.
sourceAtmosTransport.MetDrivers.recompute_cm_from_dm_target! Method
recompute_cm_from_dm_target!(layout, div_h, cm, m, dm_target, flux_args...;
residual_weight = layer_mass_residual_weight)Shared explicit-dm continuity closure. The topology-specific code only builds div_h; the vertical integration and residual redistribution are common:
and the column residual R = C_{N_z+1} is folded back as C_{k+1} ← C_{k+1} − R Σ_{j≤k} w_j / Σ_j w_j with w_k = residual_weight(m_k, k) (the layer mass by default). Preprocessing passes its column-balance weights, so the residual of a hybrid_mass balance reaches only hybrid layers, as in the cubed-sphere diagnose_cs_cm!.
AtmosTransport.MetDrivers.supports_convection Method
Does this driver provide convective mass flux / detrainment for convection?
sourceAtmosTransport.MetDrivers.supports_diffusion Method
Does this driver provide diffusivity fields for boundary-layer diffusion?
sourceAtmosTransport.MetDrivers.supports_moisture Method
Does this driver provide specific humidity for dry-mass correction?
sourceAtmosTransport.MetDrivers.supports_native_vertical_flux Method
Does this driver provide native vertical mass fluxes (vs diagnosing from continuity)?
sourceAtmosTransport.MetDrivers.surface_pressure_basis Method
Surface-pressure meaning supplied by a meteorological driver.
The compatibility fallback is total pressure, matching the pre-existing custom-driver contract. A driver that supplies dry pressure must override this method and return DrySurfacePressure().
AtmosTransport.MetDrivers.uses_binary_substep_contract Method
Does this driver provide a verified per-window timestep contract?
sourceAtmosTransport.MetDrivers.verify_window_continuity Method
verify_window_continuity(scratch, m_cur, cm, m_next, steps_per_window)
verify_window_continuity(layout, scratch, m_cur, cm, m_next, steps_per_window, flux_args...)Replay one window's stored mass fluxes against the stored air-mass endpoints, cell by cell. With n = steps_per_window, each cell's budget residual is
r = m_cur − 2n (div_h + cm[k+1] − cm[k]) − m_next(div_h the net horizontal outflow of one flux application) and its scale is
s = |m_cur| + |m_next| + 2n (Σ_faces |F_h| + |cm[k]| + |cm[k+1]|),the summed magnitudes of the budget's terms, which bounds the rounding error of the sum. The result's max_rel_err is the largest |r| / s of any cell, with max_abs_err = |r| and worst_idx at that cell. A non-finite residual counts as Inf, so NaN or Inf in the stored data fails every tolerance. Compare max_rel_err with replay_tolerance(FT).
The first form assumes scratch.div and scratch.mag (a ReplayScratch) are already populated; the second builds them through the topology-specific layout.
This certifies that the stored fluxes carry m_cur to m_next under the runtime's palindrome continuity. It does not test the winds themselves: preprocessing diagnoses cm from the same horizontal fluxes and endpoints just before the check; see What the replay gate certifies.
AtmosTransport.MetDrivers.verify_window_continuity_cs Method
verify_window_continuity_cs(m_cur, am, bm, cm, m_next, steps_per_window;
scratch = ReplayScratch(size(m_cur[1])))Cubed-sphere convenience wrapper for the shared replay kernel. The caller must provide panel-local arrays with synchronized boundary mirrors so each panel's structured divergence matches the closed-sphere flux field. Callers that check many windows should allocate one panel-sized scratch and pass it to every call; all panels reuse it.
AtmosTransport.MetDrivers.verify_window_continuity_rg Method
verify_window_continuity_rg(m_cur, hflux, cm, m_next, face_left, face_right,
steps_per_window; scratch = ReplayScratch(size(m_cur)))Face-indexed convenience wrapper for the shared replay kernel. Pass a reused scratch to avoid allocating per window.
AtmosTransport.MetDrivers.BinaryFormat Module
Transport-binary metadata (format versions 4 and 5), payload layout, writers, windows, reports.
sourceAtmosTransport.MetDrivers.BinaryFormat.COLUMN_CLOSURE_RULE Constant
Rule of the recorded column closure (header column_closure_rule): per-cell τ_c = max(COLUMN_CLOSURE_TOL_KG, 8 ε_FT Σ_{f∂c} Σ_k |F_{f,k}|) over the cell's incident faces.
AtmosTransport.MetDrivers.BinaryFormat.FLUX_CERTIFICATE_KEY_PREFIXES Constant
Header-key prefixes of the write-time certificate (flux and OMEGA fidelity, balance correction, column closure). The certificate is one block: writers patch all of it at close, and a caller that supplies a certificate through extra_header (e.g. the TM5 convection attachment copying its source's) replaces the writer's default block as a whole.
AtmosTransport.MetDrivers.BinaryFormat.FLUX_CONSTRUCTION_FORMAT_VERSION Constant
Transport-binary format version of a header that records the flux-construction identity (flux_construction and its keys, see AbstractFluxConstructionHeader). Version 5 is version 4 plus these keys: payload layout, timing and sampling are unchanged.
AtmosTransport.MetDrivers.BinaryFormat.FLUX_FIDELITY_SAMPLE_SEED Constant
Deterministic flux-certificate sample seed; part of the binary contract.
sourceAtmosTransport.MetDrivers.BinaryFormat.FLUX_FIDELITY_SCHEMA Constant
Version of the flux-certificate key block (header flux_fidelity_schema). Schema 2 carries the flux-weighted balance_correction_*_relative metrics and the two-sided OMEGA slope bound; schema 1 headers came only from unreleased development builds and are rejected.
AtmosTransport.MetDrivers.BinaryFormat.TM5_PBL_FIELD_NAMES Constant
Optional v5 live Calc_Kzz input group; fractional lsm and ECMWF downward-positive heat fluxes.
sourceAtmosTransport.MetDrivers.BinaryFormat.TM5_PBL_PAYLOAD_SECTIONS Constant
All-or-nothing v5 payload sections for live TM5 Calc_Kzz.
sourceAtmosTransport.MetDrivers.BinaryFormat.TRANSPORT_BINARY_FORMAT_VERSION Constant
Transport-binary format version of a header that records no version-5 item. Every writer emits it unless it is given a flux-construction identity, so all existing outputs stay version 4.
sourceAtmosTransport.MetDrivers.BinaryFormat.TRANSPORT_BINARY_FORMAT_VERSIONS Constant
Every transport-binary format_version this runtime reads.
AtmosTransport.MetDrivers.BinaryFormat.AbstractColumnClosureHeader Type
Column closure of a cubed-sphere transport binary, decoded from its column_closure_* header keys: ColumnClosureHeader when the writer column-balanced its fluxes and recorded the closure, NoColumnClosureHeader when the keys are absent (no cubed-sphere column balance ran, or the binary predates the record).
AtmosTransport.MetDrivers.BinaryFormat.AbstractFluxConstructionHeader Type
AbstractFluxConstructionHeaderFlux-construction identity of a transport binary: the method the preprocessor used to build the horizontal mass fluxes. A version-5 header records it in the key flux_construction (spelled by flux_construction_tag) plus the keys of the construction; a version-4 header records none and parses as NoFluxConstructionHeader. Writers take it as the typed flux_construction keyword and write version 5 exactly when it is recorded. See docs/src/concepts/binary_format.md.
AtmosTransport.MetDrivers.BinaryFormat.AbstractTransportBinaryGeometry Type
AbstractTransportBinaryGeometryGeometry metadata embedded in a transport binary (format versions 4 and 5). Concrete geometry types carry only the fields meaningful for their topology; reader and grid construction code dispatches on this type instead of branching on string tags.
sourceAtmosTransport.MetDrivers.BinaryFormat.ColumnClosureHeader Type
Recorded column closure (docs/src/concepts/binary_format.md): the rule of the per-cell tolerance τ_c, the windows covered, and the maxima over windows of the projected column residual |r_c^⊥| [kg], its ratio to τ_c, the residual folded into cm [kg] and its ratio to its tolerance. Both ratios are at most 1 in a binary that loads.
AtmosTransport.MetDrivers.BinaryFormat.CubedSphereBinaryGeometry Type
Geometry metadata for a six-panel cubed-sphere binary.
sourceAtmosTransport.MetDrivers.BinaryFormat.CubedSphereFluxDeltas Type
CubedSphereFluxDeltasReplay delta for panel-native cubed-sphere air mass. Canonical cubed-sphere forcing keeps face fluxes constant within a meteorological window.
sourceAtmosTransport.MetDrivers.BinaryFormat.FaceIndexedFluxDeltas Type
Replay deltas for face-indexed horizontal flux, vertical flux, and air mass.
sourceAtmosTransport.MetDrivers.BinaryFormat.FluxFidelityHeader Type
Typed horizontal-flux certificate decoded from the flat binary header.
status and kind are nominal types. A FidelityPassed certificate is always WindRederivedFidelity and carries every numeric metric (finite); NativePassthroughFidelity (GEOS native fluxes) is FidelityNotApplicable and carries only the balance-correction metrics; NoFluxFidelityKind has no samples. time_sampling is the windows' common effective sampling or "mixed", in which case time_sampling_by_window lists every window's. The balance-correction metrics measure the column-balance correction Δ = F_balanced − F of the sampled pre-balance amounts F, flux-weighted: balance_correction_rms_relative = RMS(Δ)/RMS(F) over all samples, and the largest per-level value with its level (balance_correction_max_level, 1 = top).
AtmosTransport.MetDrivers.BinaryFormat.LatLonBinaryGeometry Type
Geometry metadata for a regular longitude-latitude binary.
sourceAtmosTransport.MetDrivers.BinaryFormat.NoFluxConstructionHeader Type
Version-4 header: the flux construction is not recorded.
sourceAtmosTransport.MetDrivers.BinaryFormat.OmegaFidelityHeader Type
Typed source-OMEGA certificate decoded from the flat binary header. A FidelityPassed certificate has samples, finite metrics, passed == true and satisfies its own gates: nrmse < nrmse_limit, correlation > correlation_min, slope_min < slope < slope_max.
AtmosTransport.MetDrivers.BinaryFormat.PointSampledSpectralFluxesHeader Type
flux_construction = "point_sampled_spectral": ERA5 spectral winds synthesized at the target truncation and sampled on lat-lon or reduced-Gaussian faces and centres, times the face pressure thickness. Also covers cubed-sphere construction via a lat-lon staging grid, with vector or line-integral face fluxes distinguished by the version-4 CS face metadata. The identity itself has no further keys.
AtmosTransport.MetDrivers.BinaryFormat.ReducedGaussianBinaryGeometry Type
Geometry metadata for a face-indexed reduced-Gaussian binary.
sourceAtmosTransport.MetDrivers.BinaryFormat.RegriddedTransportBinaryHeader Type
A transport binary remapped onto a new mesh. Keeps only the source construction string, not its construction-specific keys (such as tm5_spectral revision and truncation). Inspect the source binary for that metadata.
sourceAtmosTransport.MetDrivers.BinaryFormat.StreamingTransportBinaryWriter Type
StreamingTransportBinaryWriter{FT}Handle for incrementally writing transport-binary windows to disk without holding all windows in memory. Created by open_streaming_transport_binary, each window is written via write_streaming_window!, and the file is finalised by close_streaming_transport_binary!.
Memory footprint: one elems_per_window-length pack buffer (Vector{FT}) plus the open IOStream. All other per-window data is owned by the caller.
The windows go to staging_path, a staging file next to path from AtomicFiles.open_atomic_staging (O_EXCL, mode 0o666 & ~umask). Closing a complete stream renames it onto path; an incomplete or failed stream is removed and a previous path is left untouched.
AtmosTransport.MetDrivers.BinaryFormat.StructuredFluxDeltas Type
Replay deltas for directional lat-lon face fluxes and cell air mass.
sourceAtmosTransport.MetDrivers.BinaryFormat.TM5SpectralFluxesHeader Type
TM5SpectralFluxesHeader(revision, spectral_truncation_used,
quadrature_refinement_steps, vod2uv_radius_m)flux_construction = "tm5_spectral": TM5-style spectral mass fluxes, integrated over the target cell faces from the retained spectrum (docs/src/preprocessing/tm5_spectral_fluxes.md). Header keys:
flux_construction_revision: revision of the construction (≥ 1);spectral_truncation_used: triangular truncation T of the spectrum the fluxes were integrated from (≥ 1);quadrature_refinement_steps:nstepof TM5'sShRefinementrule (≥ 1);vod2uv_radius_m: sphere radius of the vorticity/divergence-to-wind conversion [m] (finite, positive). The radius of the target mesh stays inplanet_radius_m.
AtmosTransport.MetDrivers.BinaryFormat.TransportBinaryContract Type
TransportBinaryContract(; source_flux_sampling, air_mass_sampling,
flux_sampling, flux_kind, delta_semantics,
humidity_sampling,
poisson_balance_target_scale,
poisson_balance_target_semantics)Self-describing transport-binary timing/basis contract. All eight fields are required — no defaults — so a writer cannot produce an ambiguous binary. Readers call validate_transport_contract! on the parsed header to decide whether the file is trustworthy.
Canonical usage: construct via canonical_window_constant_contract for window-constant, per-substep mass fluxes.
Symbol fields are validated against the _TRANSPORT_ALLOWED_* tuples at construction time. Combinations are also checked:
delta_semantics === :forward_window_endpoint_differencerequires the payload to carrydm(ordm + dhflux); the writer is responsible for honoring this.humidity_sampling === :window_endpointsrequiresqv_start+qv_endin the payload;:nonerequires neither.
AtmosTransport.MetDrivers.BinaryFormat.TransportBinaryHeader Type
TransportBinaryHeader{G<:AbstractTransportBinaryGeometry}Validated metadata for the current transport-binary format. geometry selects the horizontal topology through dispatch, while the remaining fields describe the common timing, vertical coordinate, mass basis, and payload contract.
planet_radius_m is the radius of the sphere on which the preprocessor computed cell areas, and so the air masses from pressure thickness (m = Δp A / g); the runtime builds its mesh with it. Binaries written before the key existed read as EARTH_RADIUS, the radius the runtime used for them.
A_ifc and B_ifc define interface pressure as p_half[k] = A_ifc[k] + B_ifc[k] * surface_pressure, with k = 1 at the top of atmosphere. flux_kind distinguishes mass per transport substep from a full-window mass amount.
flux_fidelity, omega_fidelity and column_closure are the write-time certificate and column-closure record, checked for consistency when the header is parsed. flux_construction is the flux-construction identity of a version-5 header and NoFluxConstructionHeader() for version 4.
AtmosTransport.MetDrivers.BinaryFormat.TransportWindow Type
TransportWindowA decoded forcing interval (format versions 4 and 5). The concrete flux and delta types encode the horizontal topology, while optional fields describe physical capabilities: humidity endpoints, convection, PBL surface forcing, GCHP VDIFF state, precomputed TM5 interface diffusion exchange dkg [kg s⁻¹], and the optional v5 live-Calc_Kzz input group tm5_pbl. A window owns no prognostic tracer state.
AtmosTransport.MetDrivers.BinaryFormat.abandon_streaming_transport_binary! Method
abandon_streaming_transport_binary!(writer) -> NothingClose the writer's IO and remove its staging file without publishing; the final path is untouched. Used when a caller's own check fails between the last window and close_streaming_transport_binary!.
AtmosTransport.MetDrivers.BinaryFormat.binary_capabilities Function
binary_capabilities(reader) -> NamedTupleSummarise what operators this binary can drive. Geometry-specific advection requirements are selected through the reader's geometry type. Fields:
advection :: Bool— all geometry-required advection sections present (m, am, bm, cmon LL/CS;m, hflux, cmon RG).replay_gate :: Bool— any flux-delta section (dam/dbm/dcm/dm/dhflux) present.tm5_convection :: Bool— entu/detu/entd/detd all present.tm5_convection_mass_basis :: Union{Nothing, AbstractMassBasis}— typed basis of the TM5 sections (DryBasis()/MoistBasis());nothingwithout TM5 sections or when the binary predates the record (moist fluxes, seeTM5_CONVECTION_MASS_BASIS_KEY).tm5_convection_provenance :: Vector{Pair{String, String}}— the recorded source of the TM5 sections (TM5_CONVECTION_SOURCE_KEY,TM5_EC2TM_CONVENTION_KEY,convection_attachment), empty when none is recorded or the binary has no TM5 sections.cmfmc_convection :: Bool— cmfmc present (CS only; LL/RG returns false).pbl_diffusion :: Bool— complete runnable PBL forcing (CS only).gchp_vdiff :: Bool— complete runnable GCHP VDIFF forcing (CS only).gchp_nonlocal_vdiff :: Bool— GCHP VDIFF forcing plus latent heat fluxpbl_eflux, as GEOS-Chem's non-local PBL scheme needs (CS only).cmfmc_cloud_base :: Bool— convective cloud base present.surface_pressure :: Bool— ps present.humidity :: Bool— qv_start/qv_end present.mass_basis :: Symbol—:dryor:moist.surface_pressure_basis :: AbstractSurfacePressureBasis— typed meaning of the storedpspayload.grid_type :: Symbol—:latlon/:reduced_gaussian/:cubed_sphere.format_version :: Int— header format version (4 or 5).flux_construction :: AbstractFluxConstructionHeader— recorded flux-construction identity;NoFluxConstructionHeader()for version 4.nlevel,steps_per_window— header values.variable_step_schedule :: Bool— per-window substep counts differ.flux_kind :: Symbol— stored mass-flux normalization contract.preprocessor_contract,vertical_Nz_output,adaptive_substeps— raw header values,nothingwhen absent.dry_mass_target_ps_pa,dry_mass_target_source,dry_mass_pinned— the pinned header target or carried window-1 mass, its provenance, and pin state (nothingfor legacy files whose state is not recorded).payload_sections :: Vector{Symbol}— raw set for debugging.
AtmosTransport.MetDrivers.BinaryFormat.binary_dry_mass_target Function
binary_dry_mass_target(reader) -> NamedTupleReturn the binary's global-mean dry-mass target in pascals and its provenance. Pinned current binaries record mass_fix_enabled=true together with mass_fix_target_ps_dry_pa in the header. Historical binaries may instead use the source-specific global_mass_pin_enabled or geos_global_mass_pin_enabled flag and omit the pressure target; those files fall back to their carried window-1 dry mass with pinned=true. Unpinned and keyless legacy dry-basis binaries use the same zero-copy fallback, sum(m_k) g / (4 pi R_header^2), on the radius recorded by the binary.
For moist-basis payloads the fallback computes sum(m_k * (1-qv_k)) g / (4 pi R_header^2) from qv_start. Without endpoint humidity the dry target is physically unclassifiable and ps_dry_pa=nothing; total-air mass is never reported as dry-air mass.
AtmosTransport.MetDrivers.BinaryFormat.canonical_window_constant_contract Method
canonical_window_constant_contract(; steps_per_window,
humidity_sampling = :none,
source_flux_sampling = :window_start_endpoint,
include_flux_delta = true) -> TransportBinaryContractBuild the canonical contract for window-constant, per-substep mass amounts. The Poisson target scale is 1 / (2 * steps_per_window) — matching the TM5 r1112 horizontal-sweep count of 2 * steps_per_window per window.
include_flux_delta = true implies delta_semantics = :forward_window_endpoint_difference (the writer must include dm in the payload); false implies :none.
AtmosTransport.MetDrivers.BinaryFormat.close_streaming_transport_binary! Method
close_streaming_transport_binary!(writer) -> StringFlush and close the streaming transport binary. Returns the file path. An incomplete stream is closed and rejected without publishing a final header.
sourceAtmosTransport.MetDrivers.BinaryFormat.fidelity_tag Method
On-disk spelling of a typed fidelity status or flux kind.
sourceAtmosTransport.MetDrivers.BinaryFormat.flux_construction_tag Method
On-disk spelling (flux_construction value) of a flux-construction identity.
AtmosTransport.MetDrivers.BinaryFormat.inspect_binary Function
inspect_binary(path; io = stdout) -> NamedTupleOpen the binary at path, print a capability-augmented report to io, and return the binary_capabilities NamedTuple for programmatic consumption (tests, CLI capability-intersection, folder-level validation).
Files whose format_version is not in TRANSPORT_BINARY_FORMAT_VERSIONS are rejected here just like runtime drivers; inspect the raw JSON header with external tools if a stale file must be audited.
AtmosTransport.MetDrivers.BinaryFormat.open_streaming_cs_transport_binary Method
open_streaming_cs_transport_binary(path, Nc, npanel, nlevel, nwindow, vc;
kwargs...) -> StreamingTransportBinaryWriterOpen a canonical cubed-sphere binary for streaming window writes (format version 4, or 5 when the typed flux_construction keyword records a flux-construction identity). vc is a HybridSigmaPressure vertical coordinate; the payload is per-panel structured arrays with StructuredDirectional topology. The header records the panel convention ("gnomonic" or "geos_native"), the geometry law and planet_radius (the radius of the mesh on which the air masses were computed), so readers reconstruct the same mesh. Each subsequent window must match the registered panel shapes and payload sections exactly. The typed surface_pressure_basis keyword is required and independently declares whether the stored ps panels are total or dry pressure.
AtmosTransport.MetDrivers.BinaryFormat.open_streaming_transport_binary Method
open_streaming_transport_binary(path, grid::AtmosGrid{<:ReducedGaussianMesh},
nwindow, sample_window; kwargs...)Open a transport binary file for streaming (per-window) writes on a reduced-Gaussian grid.
sample_window is a NamedTuple with the same keys as the windows that will be written (e.g. (m=..., hflux=..., cm=..., ps=...)). Its arrays must have the correct sizes but their values are ignored — it is only used to determine payload_sections and to validate dimensions. The typed surface_pressure_basis keyword is required; it is not inferred from the air-mass basis. The optional typed flux_construction keyword records a flux-construction identity and makes the file format version 5.
Returns a StreamingTransportBinaryWriter.
AtmosTransport.MetDrivers.BinaryFormat.parse_column_closure_header Method
parse_column_closure_header(hdr, nwindow) -> AbstractColumnClosureHeaderDecode and check the column-closure record. Absent keys mean the closure was not recorded (NoColumnClosureHeader). A record must be complete, name the known rule, cover nwindow windows and hold finite, non-negative values with both residual/tolerance ratios at most 1; otherwise the stored fluxes cannot be trusted to close the column mass budget and the binary must be regenerated.
AtmosTransport.MetDrivers.BinaryFormat.parse_flux_construction_header Method
parse_flux_construction_header(header, format_version) -> AbstractFluxConstructionHeaderDecode and check the flux-construction identity of a String-keyed header. A version-4 header must carry none of the version-5 keys and returns NoFluxConstructionHeader. A version-5 header must carry flux_construction with a known value, every key of that construction with a valid value, and no key of another construction.
AtmosTransport.MetDrivers.BinaryFormat.parse_flux_fidelity_header Method
parse_flux_fidelity_header(hdr, nwindow, nlevel) -> FluxFidelityHeaderDecode and check the horizontal-flux certificate: the status/kind pair must be one a writer emits, a sampled certificate must cover nwindow windows and nlevel levels (sample_count == windows × samples_per_window × nlevel) with finite metrics, and a non-passed certificate needs a reason. Binaries written before the certificate existed read as FidelityUnavailable (legacy_header_missing).
AtmosTransport.MetDrivers.BinaryFormat.parse_omega_fidelity_header Method
parse_omega_fidelity_header(hdr) -> OmegaFidelityHeaderDecode and check the source-OMEGA certificate: a passed certificate has samples, finite metrics, omega_fidelity_passed = true and satisfies its recorded gates; a failed one has omega_fidelity_passed = false; a not-applicable or unavailable one has no samples or metrics.
AtmosTransport.MetDrivers.BinaryFormat.poisson_balance_target Method
poisson_balance_target(flux_kind, schedule; steps_per_window=maximum(schedule))Float64 Poisson target metadata for a validated positive step schedule. The scalar describes the declared maximum step count; by_window follows the schedule. This metadata conversion does not change physics accumulation types.
AtmosTransport.MetDrivers.BinaryFormat.section_elements Method
Number of stored elements in a section, including every cubed-sphere panel.
sourceAtmosTransport.MetDrivers.BinaryFormat.section_elements Method
Cubed-sphere section element count before constructing a complete header.
sourceAtmosTransport.MetDrivers.BinaryFormat.section_elements Method
Lat-lon section element count before constructing a complete binary header.
sourceAtmosTransport.MetDrivers.BinaryFormat.section_shape Method
Array dimensions of a payload section; cubed-sphere dimensions describe one panel.
sourceAtmosTransport.MetDrivers.BinaryFormat.validate_cs_writer_contract! Method
validate_cs_writer_contract!(header::AbstractDict)Write-time guard: assert every runtime-read cubed-sphere contract key (_CS_WRITER_CONTRACT_KEYS) is present before a binary is finalized — the writer-side mirror of [validate_transport_contract!]. The single choke point open_streaming_cs_transport_binary emits these keys with defaults, so this never fires in normal use; it exists to fail LOUDLY if a future refactor drops the default emission, rather than silently shipping a binary that makes the runtime run convection/chemistry per advection substep (the 2026-05-31 N320 regression: a new source path omitted runtime_substep_contract).
AtmosTransport.MetDrivers.BinaryFormat.validate_tm5_pbl_inputs Method
Validate complete live-Calc_Kzz input shapes, finite values, humidity, land fraction and land roughness.
sourceAtmosTransport.MetDrivers.BinaryFormat.validate_transport_contract! Method
validate_transport_contract!(header::AbstractDict)Assert that header declares the current transport-binary contract and that the timing metadata is self-consistent. format_version is a hard boundary: only TRANSPORT_BINARY_FORMAT_VERSIONS (4 and 5) are accepted. Older files are obsolete and must be regenerated rather than loaded through compatibility defaults; newer ones are rejected. The flux-construction identity is checked with parse_flux_construction_header: version-5 keys in a version-4 header are rejected, and a version-5 header must record a valid identity.
Shared between TransportBinaryDriver, TransportBinaryReader, and the scripts/diagnostics/inspect_transport_binary.jl tool so there is ONE validator every reader-facing tool calls.
AtmosTransport.MetDrivers.BinaryFormat.write_padded_header! Method
Write unchanged JSON and NUL padding at the current position in io.
AtmosTransport.MetDrivers.BinaryFormat.write_streaming_cs_window! Method
write_streaming_cs_window!(writer, window, Nc, npanel)Pack and write a single CS window to the streaming transport binary. window is a NamedTuple with NTuple-of-panels fields :m, :am, :bm, :cm, :ps.
AtmosTransport.MetDrivers.BinaryFormat.write_streaming_window! Method
write_streaming_window!(writer, window)Pack and write a single window to the streaming transport binary. Windows must be written in order (1, 2, …, nwindow).
sourceAtmosTransport.MetDrivers.BinaryFormat.write_transport_binary Method
write_transport_binary(path, grid, windows; kwargs...) -> pathWrite a canonical lat-lon or reduced-Gaussian transport binary from an AtmosGrid and an ordered vector of forcing windows. Window payloads must match the grid topology and declared mass basis. The typed surface_pressure_basis keyword is required and records whether window.ps is total or dry pressure; it is deliberately independent of mass_basis. The file is format version 4 unless the typed flux_construction keyword records a flux-construction identity (AbstractFluxConstructionHeader); then it is version 5 with the same payload. The file is written through AtomicFiles.atomic_publish: it replaces path only after the header and all payloads succeed, with mode 0o666 & ~umask. A lat-lon mesh must have uniform latitude faces: the header records only the latitude interval, so a mesh built from non-uniform faces (Δφ = NaN) is refused with an ArgumentError.
AtmosTransport.MetDrivers.BinaryReaders Module
Memory-mapped transport readers and LL/RG/CS runtime drivers.
sourceAtmosTransport.MetDrivers.BinaryReaders.AbstractRawWindowStaging Type
AbstractRawWindowStagingBuffers holding one raw window payload of a cubed-sphere transport binary for a device run: read_window_payload! fills staging.host, and unpack_window_payload! fills a device window from it. Built by raw_window_staging; the concrete type follows the backend's Architectures.host_memory_model (RawWindowStaging or MappedWindowStaging).
AtmosTransport.MetDrivers.BinaryReaders.MappedWindowStaging Type
MappedWindowStaging(host, device)Raw window staging for unified memory: device holds one window payload and host is an Array over the same memory (Architectures.host_mapped_vector), so the reads fill device memory and unpack_window_payload! unpacks each section straight from its offset in the payload, with no upload.
Rationale: on Metal, each host-to-device copyto! synchronizes the queue, copies through a temporary shared buffer and waits for the blit. On an M5 Pro a C90 window load (read, unpack, synchronize) took a median 65 ms with section uploads and 23 ms reading into a shared-storage buffer.
AtmosTransport.MetDrivers.BinaryReaders.RawWindowStaging Type
RawWindowStaging(host, device)Raw window staging for discrete device memory: a page-locked host buffer holding one window payload and a device buffer holding its largest payload section; unpack_window_payload! uploads the window section by section (asynchronous copies from page-locked memory on CUDA).
AtmosTransport.MetDrivers.BinaryReaders.TransportBinaryDriver Type
TransportBinaryDriverMeteorological driver backed by a validated transport binary (format version 4 or 5). Geometry dispatch reconstructs the appropriate grid and loads structured, face-indexed, or panel-native windows through the same public interface.
sourceAtmosTransport.MetDrivers.BinaryReaders.TransportBinaryDriver Method
TransportBinaryDriver(reader; arch=CPU(), Hp=1,
validate_windows=true, validate_replay=false)
TransportBinaryDriver(path; FT=Float64, arch=CPU(), Hp=1,
validate_windows=true, validate_replay=false)Open a version-4 or version-5 binary and construct its runtime grid. Hp is the horizontal halo width for cubed-sphere grids and is ignored by other geometries. Optional validation checks vertical-flux magnitude for LL/RG and replay continuity for all geometries. The path constructor closes its internally opened reader if construction fails; callers retain ownership of a reader passed directly.
AtmosTransport.MetDrivers.BinaryReaders.TransportBinaryReader Type
TransportBinaryReader{FT, DiskFT, G}Memory-mapped reader for the current transport-binary format.
FT is the element type produced by window loaders, DiskFT is the mmap element type, and G is the concrete geometry metadata type. Payloads remain in their native topology: structured arrays for lat-lon, face-indexed arrays for reduced Gaussian, and six panel arrays for cubed sphere.
read_split decides how many concurrent preads a raw window read (read_window_payload!) uses; the reader picks it from the file system when it opens the file (window_read_split).
AtmosTransport.MetDrivers.BinaryReaders.binary_mass_basis Method
Return the transport binary header mass basis as :dry or :moist.
AtmosTransport.MetDrivers.BinaryReaders.has_dkg Method
Whether the binary carries the exact precomputed Dkg payload.
sourceAtmosTransport.MetDrivers.BinaryReaders.has_dtrain Method
Whether the binary carries the explicit DTRAIN payload (reader or capability summary).
sourceAtmosTransport.MetDrivers.BinaryReaders.has_qv_endpoints Method
Return true when both specific-humidity endpoint sections are present.
AtmosTransport.MetDrivers.BinaryReaders.has_tm5_convection Method
has_tm5_convection(r::TransportBinaryReader) -> Booltrue if the binary carries all four TM5 convection sections (entu, detu, entd, detd) — the contract enforced by the preprocessor when tm5_convection = true. Used by the TransportBinaryDriver to decide whether to populate ConvectionForcing.tm5_fields on loaded windows.
AtmosTransport.MetDrivers.BinaryReaders.infer_surface_pressure_basis Method
Infer legacy ps basis from stored column masses using Float64 column sums.
The reader calls this once when a binary lacks surface_pressure_basis.
AtmosTransport.MetDrivers.BinaryReaders.load_flux_delta_window! Method
load_flux_delta_window!(reader, win; buffers...) -> NamedTuple | nothingLoad forward endpoint deltas for air mass and the topology's face fluxes. Returns nothing when the binary carries no delta sections.
AtmosTransport.MetDrivers.BinaryReaders.load_qv_pair_window! Method
load_qv_pair_window!(reader, win; qv_start=nothing, qv_end=nothing)Load the specific-humidity fields at the start and end of window win. Returns (; qv_start, qv_end) or nothing when humidity endpoints are absent. Caller-provided arrays are filled in place.
AtmosTransport.MetDrivers.BinaryReaders.load_surface_window! Method
load_surface_window!(reader, win) -> PBLSurfaceForcing | nothingLoad the raw PBL surface payload for one CS window. This is a convenience wrapper over load_window!; callers that already need the advection fields should use load_window!(reader, win).surface to avoid a second payload read.
AtmosTransport.MetDrivers.BinaryReaders.load_surface_window! Method
load_surface_window!(reader, win; pblh=..., ustar=..., hflux=..., t2m=...) -> PBLSurfaceForcing | nothingLoad raw PBL surface fields for window win. Returns nothing when the binary lacks surface sections. A binary carrying only a subset of pblh, ustar, pbl_hflux, and t2m is rejected because the runtime PBL closure needs the complete raw surface payload. The on-disk heat-flux section is pbl_hflux; callers still receive it as PBLSurfaceForcing.hflux.
AtmosTransport.MetDrivers.BinaryReaders.load_tm5_convection_window! Method
load_tm5_convection_window!(reader, win; entu=..., detu=..., entd=..., detd=...) -> NamedTuple | nothingLoad the four TM5 convection layer-center fields for window win. Returns (; entu, detu, entd, detd) when the binary carries all four sections, or nothing when no TM5 data is present. Allocates only if the caller doesn't provide pre-allocated buffers.
All fields share the same shape as m: (Nx, Ny, Nz) for structured or (ncells, Nz) for face-indexed binaries. Orientation is as written by the preprocessor (AtmosTransport: k=1=TOA, k=Nz=surface); no runtime reorientation happens here — the kernel reads them directly.
Invariant: if ANY of the four sections is present in the header, ALL four must be present. This mirrors the ConvectionForcing.tm5_fields NamedTuple contract — partial payload is not a valid convection forcing.
AtmosTransport.MetDrivers.BinaryReaders.load_transport_window! Method
load_transport_window!(window, driver, win) -> windowRefill an existing host-resident cubed-sphere window (from load_transport_window on the same binary, or on one with the same layout, same_window_layout) with window win, without allocating new field arrays. Equal to load_transport_window(driver, win) provided the halos of window's padded fields still hold the zeros of that first load: only interiors are written.
AtmosTransport.MetDrivers.BinaryReaders.load_vdiff_qv_window! Method
load_vdiff_qv_window!(dest, reader, win) -> destCopy the GCHP VDIFF specific humidity :vdiff_qv of window win (the window-start humidity, interior panels (Nc, Nc, Nz), k = 1 at the top) into the host panels dest without loading the rest of the window. Observation sampling reads it as the humidity at the end of the previous window.
AtmosTransport.MetDrivers.BinaryReaders.load_window! Method
load_window!(reader, win) -> NamedTupleLoad window win from a cubed-sphere transport binary. Returns NTuples of per-panel arrays plus optional cmfmc / dtrain payloads when they are present in the binary.
AtmosTransport.MetDrivers.BinaryReaders.load_window! Method
load_window!(reader, win; buffers...) -> (air_mass, surface_pressure, fluxes)Load the required transport state for one lat-lon or reduced-Gaussian window. Optional buffer keywords reuse caller-owned storage; omitted buffers are allocated with the reader's output element type.
sourceAtmosTransport.MetDrivers.BinaryReaders.mesh_convention Method
mesh_convention(reader) -> AbstractCubedSpherePanelConventionReturn the panel-numbering convention declared in the binary header.
Returns GnomonicPanelConvention() for ERA5-CS binaries and GEOSNativePanelConvention() for GEOS-FP/IT binaries tagged with panel_convention="geos_native". Callers should pass the result directly to CubedSphereMesh(; convention=mesh_convention(reader)) to guarantee that the halo exchange uses the correct edge-to-edge connectivity table.
AtmosTransport.MetDrivers.BinaryReaders.mesh_definition Method
mesh_definition(reader) -> CubedSphereDefinitionReturn the full cubed-sphere geometry definition declared in the binary header. Binaries record cs_coordinate_law, cs_center_law, panel_convention, and longitude_offset_deg explicitly.
AtmosTransport.MetDrivers.BinaryReaders.raw_window_staging Method
raw_window_staging(driver, reference_array) -> AbstractRawWindowStaging or nothingRaw window staging buffers for driver on the backend of reference_array (a device array or six-panel tuple): MappedWindowStaging where the backend has UnifiedHostMemory, RawWindowStaging otherwise. Returns nothing for drivers without raw window payloads and for binaries whose on-disk element type is not the run's (those convert while loading on the host).
AtmosTransport.MetDrivers.BinaryReaders.read_window_payload! Method
read_window_payload!(staging::AbstractRawWindowStaging, driver, win) -> stagingRead window win of driver's binary into staging.host: on Unix as concurrent preads on libuv's thread pool (@threadcall, no Julia thread is blocked), as many as the reader's read_split gives for the window (window_read_chunks: four on local file systems; on NFS four for a window already in the page cache, else one); on other platforms with one read!.
AtmosTransport.MetDrivers.BinaryReaders.release_payload! Method
release_payload!(driver)On Linux, advise the kernel that pages faulted from the driver's read-only mmap may be reclaimed. Later access safely faults them back from disk. This bounds page-cache pressure in multi-file runs; it is a no-op on other platforms.
sourceAtmosTransport.MetDrivers.BinaryReaders.section_view Method
section_view(reader, win, section)Return a zero-copy view of one payload section in window win. This is the section-level reader primitive for metadata probes that do not need a complete transport window (and must not allocate all of its flux and physics arrays).
AtmosTransport.MetDrivers.BinaryReaders.tm5_convection_mass_basis Method
tm5_convection_mass_basis(r::TransportBinaryReader) -> Union{AbstractMassBasis, Nothing}Typed air-mass basis of the TM5 convection sections (DryBasis() or MoistBasis()) parsed from the header key TM5_CONVECTION_MASS_BASIS_KEY; nothing when the binary has no TM5 sections or does not record the basis (written before the key existed, with moist fluxes).
AtmosTransport.MetDrivers.BinaryReaders.unpack_window_payload! Method
unpack_window_payload!(window, driver, staging::AbstractRawWindowStaging) -> windowUnpack each payload section of staging (filled by read_window_payload!) that window stores into the device window (one Fused launch of six RawPanelUnpacks per section). A RawWindowStaging first uploads the section from staging.host to staging.device; a MappedWindowStaging unpacks it in place from staging.device. Transfers and kernels are queued in order on the current task's device queue (a section upload waits for the previous unpack); synchronize before using window on another task or refilling staging.host.
Native ERA5 GRIB geometry readers are documented under Preprocessing; runtime binary formats and drivers are owned by the two submodules listed above.