Flood Coupling
Rain that falls on the land surface runs off, ponds and floods. ERF provides the atmosphere side of a flood model: where the flood grid sits and what the flood is handed each step. The flood itself, the model that routes the water over the land, is a flood engine that plugs into this coupling. The coupling is one way: the engine reads the atmosphere and writes nothing back.
The layout copies the fire coupling (Fire-Atmosphere Coupling) under its own
names, so that a flood engine does not depend on the fire code. Each engine
lives in its own repository, which holds ERF as a git submodule pinned to an
ERF release or commit and builds against it; ERF needs no change to add an
engine. ERF itself carries one small example engine and its tests; ERF’s CI
does not build the flood coupling, so build with ERF_ENABLE_FLOOD=ON to run
them.
Building with the flood coupling
The coupling layer is compiled with the CMake option ERF_ENABLE_FLOOD=ON
(USE_FLOOD = TRUE with GNU make); it is off by default. It adds nothing to
the state. The compile definition is ERF_USE_FLOOD.
erf.flood.enable = true needs an engine compiled into the executable;
without one the run stops at start-up and says how to add one. A build
without the flood coupling stops on erf.flood.enable = true as well.
An engine is built into ERF in one of two ways, as for a fire engine.
ERF as a library. The engine’s repository has its own CMake project, which adds the ERF submodule, compiles the engine into its own executable and sets that executable up with
erf_setup_executable(see ERF as a library). The engine’sERF_REGISTER_FLOOD_ENGINEline runs from that executable, so ERF is given no engine directory.Engine directory. ERF’s own build is given the engine directory:
ERF_FLOOD_ENGINE_DIRSwith CMake (a list; each directory holds anERFFloodEngine.cmakethat defineserf_flood_engine_add(target), and optionallyerf_flood_engine_add_unit_tests(target)), orFLOOD_HOMEwith GNU make (each directory holds aMake.package).
cmake -DERF_ENABLE_FLOOD=ON \
-DERF_FLOOD_ENGINE_DIRS=/path/to/my_flood_engine ..
make USE_FLOOD=TRUE FLOOD_HOME=/path/to/my_flood_engine
Tests/FloodEngineExample is a complete engine directory that builds both
ways; its README.md describes the example run.
Adding a flood engine
An engine derives from FloodEngine (Source/FloodCoupling/ERF_FloodEngine.H)
and registers itself under the name the deck gives in erf.flood.engine:
#include <ERF_FloodEngineRegistry.H>
class MyFloodEngine : public FloodEngine { /* ... */ };
ERF_REGISTER_FLOOD_ENGINE(MyFloodEngine, "my_engine")
Source/FloodCoupling/ERF_FloodEngineTemplate.H lists every method with
what it must do, and compiles as an engine that does nothing. The required
methods are name, verify_prerequisites, initialize and
advance. The others have defaults: start_run,
wants_surface_precip (true), write_checkpoint (nothing is
saved), read_checkpoint (a restart from a checkpoint with flood state
stops, naming the engine), write_plotfile (no plotfile),
plot_var_names and plot_var (no fields in the ERF plotfile).
The flood grid
The flood grid is a 2D grid that refines the horizontal cells of one
atmospheric level, erf.flood.anchor_level (the finest level at start-up by
default), by erf.flood.grid_ratio (\(C\), default 1). Flood cell
\((i, j)\) lies in atmospheric cell
\((\lfloor i/C \rfloor + i_0, \lfloor j/C \rfloor + j_0)\), where
\((i_0, j_0)\) is the lower corner of the region the level’s boxes cover
(zero on level 0). The grid keeps the level’s box decomposition and MPI owners,
so the maps between the two grids need no communication. The helpers in
ERF_FloodGrid.H copy an atmospheric surface field to every flood cell under
it and average flood cells back to their column. These helpers, the engine
registry, the common inputs and the start-up checks below are thin wrappers over a layer the
flood and the fire couplings share (Source/SurfaceCoupling), which is
compiled into any build with either coupling.
The level must satisfy, checked at start-up with a message that names the input to change:
every box spans the level’s full height (the default
amr.no_box_split_dir = 2gives this on level 0; on a refined level the refinement box must reach the domain top);the boxes cover one rectangle;
above level 0, the level keeps its boxes for the whole run (
erf.regrid_intat most 0, or the block’s own<block>.regrid_intunder MultiBlock; the default is -1), since the flood grid is built once.
A refinement level over part of the flood grid is allowed: the flood then reads the precipitation and wind of its own level, and a note is printed.
What the engine is handed
Each step of the flood grid’s level, after the dycore and the microphysics,
advance receives a FloodForcing:
Member |
Contents |
|---|---|
|
Start and length of the step [s] |
|
Face velocities of the level after the step [m/s] |
|
Cell-center heights of the terrain-following mesh [m] |
|
The step’s surface precipitation [kg m-2, equal to mm of water]
on the \(k = 0\) slab of each box: component 0 liquid, component 1
frozen (see below for what each scheme counts as frozen). |
The precipitation is the change of the microphysics surface accumulators over the step,
where \(A\) is the accumulation of ERF’s own surface precipitation diagnostics, read on the flood grid’s level after the step. The sum of \(P^n\) over the steps of a run is therefore the change of \(A\) over the run, to round-off. One part can be a difference of two accumulations and slightly negative from round-off: the liquid part for Morrison (the total less the frozen species) and the frozen part for WSM6 and WDM6 (the total less the rain). An engine that bounds it should carry the negative part over to the next step rather than drop it, so that its total still equals \(A\).
When a finer level covers part of the flood grid’s level, ERF averages the finer level’s accumulators down onto it once the finer level has caught up (and, with super-droplet microphysics in two-way mode, also at each plotfile and regrid). The flood takes that correction, of either sign, in its next step, so under the finer level it lags the averaged accumulation by one correction; the run total is unchanged.
Warning
In a single-precision build the accumulators are single precision. As \(A\) grows over a long or wet run, each step’s \(P^n\) is a shrinking fraction of it and keeps fewer digits; at 0.1 mm/h on 0.5 s steps over 100 mm already accumulated, about 10 % of the rain is lost to round-off. Use a double-precision build for long flood runs.
The two components follow ERF’s surface precipitation diagnostics. Kessler
and the super-droplet model hand rain only. SAM hands rain as liquid and snow
plus graupel as frozen; it hands no total, so the cloud ice that its 3D
precip_accum counts is in neither part. Morrison, WSM6 and WDM6 keep a
total next to their species accumulators. WSM6 and WDM6 add rain, snow, graupel and the cloud-ice fallout
to their total, so their liquid part is the rain and their frozen part is the
total less the rain, which counts the cloud ice as frozen. Morrison adds the
cloud-water and cloud-ice fallout to its total in one sum; its frozen part is
snow and graupel, and the rest of its total, both cloud fallouts included, is
counted as liquid.
An engine that reads the precipitation needs a moisture model that accumulates
it (Kessler, SAM, Morrison, WSM6, WDM6 with precipitation); with any other the
run stops at start-up.
Checkpoints and restarts
The coupling writes a small marker Level_<lev>/FloodGrid to the checkpoint
with the flood grid’s level, \(C\) and the columns it covers; the engine
writes its own state next to it. On a restart the marker must match the run’s
flood grid, or the run stops naming erf.flood.anchor_level and
erf.flood.grid_ratio. A checkpoint without a marker (from a run without
the flood) starts the engine from its initial state and prints a note, so a
flood can start from an atmosphere spun up without it. The precipitation the
flood last read is saved next to the marker (FloodPrecipRef, or
FloodPrecipRefIce for WSM6 and WDM6, whose split counts the cloud ice as
frozen), so a pending correction from a finer level is kept and a restart
reproduces a straight run; without a marker the reference is taken from the
restored accumulators. A WSM6 or WDM6 checkpoint written before that split
holds only FloodPrecipRef, with the cloud ice counted as liquid; the run
prints a note and takes the reference from the restored accumulators, so a
pending finer-level correction in that checkpoint is not carried over. A restart that regrids level 0 is refused.
Output
The engine’s own plotfile is written with the prefix erf.flood.plot_file
on the schedule erf.flood.plot_int / erf.flood.plot_per. With
neither given, the engine writes its plotfile at every 3D plotfile
(erf.plot_int_1 / erf.plot_per_1); an engine whose plotfile is large
may want its own, sparser schedule. As for the fire, no flood plotfile is added at the end of
a run that stops between two plot times. A field the engine names in plot_var_names (each
must start with flood_) can also be listed in erf.plot_vars_1; it is
written on the \(k = 0\) cells of the flood grid’s level as the mean over
the flood cells of each column, and zero elsewhere.