Regridding
- FireWindHinterpWRFFire
model
wildland_fire
fire_behavior
The horizontal atmosphere-to-fire mapping of NCAR fire_behavior (share/interp_mod.F90 Interp_horizontal_bilinear, reached through io/coupling_mod.F90 Interp_horizontal and io/wrfdata_mod.F90 Interp_var2grid at hinterp_opt = 2, the default): the mid-flame winds that Calc_fire_wind produces PER ATMOSPHERE COLUMN are interpolated bilinearly onto the fire mesh, with nearest-neighbour extrapolation outside the atmosphere extent. The interpolation is done in SOURCE-INDEX space: the axes are the atmosphere grid's own index axes 1..GX_SRC and 1..GY_SRC (uniform integers, built from the index sets so the component follows its metaparameters), and every bit of projection curvature lives in the per-cell target coordinates i_real and j_real. It is written with lib/table_interp.esm, i.e. the semantics of the EarthSciAST closed function interp.bilinear (esm-spec section 9.2) spelled out: bracket each source coordinate by counting the axis entries at or below it (i_bracket, j_bracket, shared by u and v), clamp it to its axis, gather the four corners with interp_bilinear_bracketed, and blend in section 9.2's pinned order. interp.bilinear itself cannot be called here, because section 9.2 admits only literal const arrays as its table and axes (interp_table_not_const / interp_axis_not_const; decided 2026-10-16, the question EarthSciAST #443 raised), while the table here is the time-evolving wind field u_src_eff / v_src_eff (it must be, for the coupling hook below) and the axes are built from the index sets. The clamp matches Fortran: clamping the COORDINATE to the axis range yields exactly the edge value for a bilinear interpolant, which is what Fortran's clamp of the base index and the fractional offset does. WHY NOT A REGRIDDING RULE, so nobody re-derives one: a hand-rolled EarthSciDiscretizations entry (regridding/cartesian_bilinear_regrid, method:bilinear, with _base/_offset/_apply stage templates) was written first and withdrawn, because it is the same function as interp.bilinear (measured: the two agree to within 1e-15 at every one of the 6400 fire cells for both wind components, and both give the identical full-field residuals against the Fortran, uf 1.084e-7 and vf 4.353e-7, and the edge value exactly at the two clamped corners), and the bracketed lib/table_interp.esm form is bit-identical to interp.bilinear in turn; a rule would only have added a conformance fixture for a duplicate of an engine primitive. WHY IT HAD TO EXIST. FireWindWRFFire is verified at rel 1e-5 but could not be MOUNTED in couplings/wildlandfire_behavior.esm, because its output lives on the atmosphere grid and the fire cell the coupled document is built on needs a fire-mesh value. The two are not the same number and no index mapping makes them so: the 80 x 80 fire mesh of test7 carries 5593 distinct uf values against 361 atmosphere columns, and the nearest column to fire cell (18, 64) differs from it by 2.2e-3 m/s, about 200 times that component's tolerance. This component is the missing link. THE FRACTIONAL COORDINATES ARE GEOMETRY, NOT A REFINEMENT RATIO, and that is the substantive finding here. The fire mesh is built by subdividing the atmosphere grid, so one expects the fractional source coordinate of fire cell i to be affine, i_real = (i - 1/2)/sr + 1/2. It is not: the mapping is proj%Calc_ij, the inverse Lambert conformal projection applied to each fire cell's latitude and longitude, and the projection's curvature over this small domain already breaks affineness. MEASURED on test7 step 20: with the dumped i_real/j_real the bilinear reproduces the Fortran to 1.08e-7 absolute, 1.2e-7 relative; with the best least-squares AFFINE fit to those same coordinates it is 1.07e-3, and with the textbook sr map 1.19e-3 -- both about 120 times the rel 1e-5 this component is held to. So i_real and j_real are consumer-supplied geometry, exactly as the column components take heights and pressures rather than deriving them, and sr_x/sr_y appear nowhere. A consumer that wants them from first principles composes EarthSciDiscretizations reprojection/lambert_conformal with the fire mesh's latitudes and longitudes; they are time-invariant, so in practice they are read once from geo_em. Reference: fire_behavior test7 standalone at step 20, real32, rel 1e-5, from the `hinterp` dump hook added in fork ctessum-claude/fire_behavior@22d426e. COUPLING HOOKS: `i_coupled`/`j_coupled` with `u_src_in`/`v_src_in` replace ONE atmosphere column's wind with a coupling target, so a mounted FireWindWRFFire can drive it (0 disables, so a standalone run is unchanged); and `uf_cell`/`vf_cell` expose the interpolated wind at fire cell (`i_cell`, `j_cell`) as scalars, which is what a per-cell consumer such as ROSWRFFire needs.