ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_SEBSoilInit.H File Reference

The first soil water of the two-stream force-restore balance from the soil moisture profile of the initial file (SMOIS of a wrfinput file, with the layer thicknesses DZS), with erf.radiation.seb_init_soil_moisture_from_file. More...

#include <limits>
#include <AMReX_INT.H>
#include <AMReX_MultiFab.H>
#include <AMReX_REAL.H>
#include <AMReX_Vector.H>
#include <AMReX_iMultiFab.H>
Include dependency graph for ERF_SEBSoilInit.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SEBSoilInitReport
 What seb_init_soil_moisture_from_file did on the boxes of this rank. More...
 

Functions

bool seb_soil_layer_weights (const amrex::Vector< amrex::Real > &thickness, amrex::Real depth, amrex::Vector< amrex::Real > &weights)
 The weights w_n of the mean over the top depth [m] of soil layers with thicknesses thickness [m], top layer first. More...
 
SEBSoilInitReport seb_init_soil_moisture_from_file (amrex::MultiFab &q, const amrex::MultiFab &file_moisture, const amrex::Vector< amrex::Real > &weights, const amrex::iMultiFab *land_mask, amrex::Real q_lo, amrex::Real q_hi)
 Write sum_n weights[n] file_moisture(n) into the land columns of q, valid columns only. More...
 

Variables

constexpr amrex::Real seb_soil_depth_rel_tol = amrex::Real(1.0e-5)
 Relative shortfall of the file's soil depth that seb_soil_layer_weights accepts: the thicknesses are single-precision in the file, so layers that reach exactly the depth asked for can sum to a little less in double precision. More...
 
constexpr amrex::Real seb_soil_value_rel_tol
 Relative distance outside [q_lo, q_hi] at which seb_init_soil_moisture_from_file still takes a mean, and then stores the bound: the file's water contents are single-precision, so a soil that the file holds exactly at a bound (saturated at the porosity 0.439, say) reads back up to 6e-8 of the value away from the bound in double precision. The 1e-6 is for that rounding of the file, not for the working precision: it is 4.5e9 double epsilons but only 8 single ones, so a single-precision build takes ten of its own epsilons (1.2e-6) instead. More...
 

Detailed Description

The first soil water of the two-stream force-restore balance from the soil moisture profile of the initial file (SMOIS of a wrfinput file, with the layer thicknesses DZS), with erf.radiation.seb_init_soil_moisture_from_file.

The balance holds two water contents per column [m^3/m^3]: q_s, the mean of the top d_1 = erf.radiation.seb_moisture_layer_depth_m of soil, and q_deep, the mean of the soil column d_2 = erf.radiation.seb_deep_layer_depth_m deep, which contains the top layer. The file gives the water content of N layers, the top one first, with thicknesses dz_n. The mean over the depth d is

q(d) = sum_n w_n SMOIS_n,   w_n = overlap([z_{n-1}, z_n], [0, d]) / sum of overlaps,

with z_0 = 0 and z_n = z_{n-1} + dz_n. The mean lies between the smallest and the largest layer value, so it adds no water content the file does not hold; the copy holds the rounded sum to that interval, so a uniform profile gives exactly its value.

Without the input every column starts at erf.radiation.seb_q_sfc_default and seb_q_deep_default. With it a land column starts at the file's means. A water column keeps the defaults: the balance does not run there.

Function Documentation

◆ seb_init_soil_moisture_from_file()

SEBSoilInitReport seb_init_soil_moisture_from_file ( amrex::MultiFab &  q,
const amrex::MultiFab &  file_moisture,
const amrex::Vector< amrex::Real > &  weights,
const amrex::iMultiFab *  land_mask,
amrex::Real  q_lo,
amrex::Real  q_hi 
)

Write sum_n weights[n] file_moisture(n) into the land columns of q, valid columns only.

A column whose mean is not finite or lies outside [q_lo, q_hi] by more than the relative seb_soil_value_rel_tol is refused: it is left as it was and counted. A mean inside that allowance is stored as the bound.

Parameters
[in,out]qa water content of the balance on one level (one component)
[in]file_moisturethe file's soil moisture on the same grids, one component per layer, top layer first
[in]weightsone weight per layer (seb_soil_layer_weights)
[in]land_maskERF::lmask_lev of the level (0 is water); nullptr means all land
[in]q_lolowest usable value
[in]q_hihighest usable value
Returns
the counts and range of this rank. The caller sums them over the ranks, stops when a column was refused, and fills the ghost columns of q.

◆ seb_soil_layer_weights()

bool seb_soil_layer_weights ( const amrex::Vector< amrex::Real > &  thickness,
amrex::Real  depth,
amrex::Vector< amrex::Real > &  weights 
)

The weights w_n of the mean over the top depth [m] of soil layers with thicknesses thickness [m], top layer first.

Parameters
[in]thicknesslayer thicknesses, each finite and > 0
[in]depthaveraging depth, finite and > 0
[out]weightsone weight per layer, >= 0, summing to 1; layers below the depth get 0 (to round-off of the layer bottoms). Left empty when the function returns false.
Returns
false when there is no layer, a thickness or the depth is not finite and positive, or the layers together are shallower than depth (1 - seb_soil_depth_rel_tol): the mean would then need water content the file does not hold.

Variable Documentation

◆ seb_soil_depth_rel_tol

constexpr amrex::Real seb_soil_depth_rel_tol = amrex::Real(1.0e-5)
constexpr

Relative shortfall of the file's soil depth that seb_soil_layer_weights accepts: the thicknesses are single-precision in the file, so layers that reach exactly the depth asked for can sum to a little less in double precision.

Referenced by seb_soil_layer_weights().

◆ seb_soil_value_rel_tol

constexpr amrex::Real seb_soil_value_rel_tol
constexpr
Initial value:
=
(amrex::Real(1.0e-6) > amrex::Real(10.0) * std::numeric_limits<amrex::Real>::epsilon())
? amrex::Real(1.0e-6)
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12

Relative distance outside [q_lo, q_hi] at which seb_init_soil_moisture_from_file still takes a mean, and then stores the bound: the file's water contents are single-precision, so a soil that the file holds exactly at a bound (saturated at the porosity 0.439, say) reads back up to 6e-8 of the value away from the bound in double precision. The 1e-6 is for that rounding of the file, not for the working precision: it is 4.5e9 double epsilons but only 8 single ones, so a single-precision build takes ten of its own epsilons (1.2e-6) instead.

Referenced by seb_init_soil_moisture_from_file().