
Fine-grained control of the GLM-AED &outflow configuration
Source: R/set_glm_outflow_config.R
set_glm_outflow_config.RdRewrites the &outflow block of a GLM nml file with per-outlet withdrawal
settings and block-level options, validated against GLM's own rules
(see src/glm_init.c in the GLM source). set_glm_outflows() is the thin
writer build_aeme() uses and only distinguishes fixed vs floating outlets;
this function additionally exposes adaptive (temperature-targeting) outlets,
submerged (type 6) outlets, per-outlet critical-withdrawal thresholds,
target-withdrawal-temperature forcing, bed seepage and weir geometry.
Usage
set_glm_outflow_config(
path_glm,
outlets = NULL,
surface_elev = NULL,
seepage = NULL,
seepage_rate = NULL,
withdr_temp_file = NULL,
adaptive = NULL,
crest_width = NULL,
crest_factor = NULL,
thick_limit = NULL,
single_layer_draw = NULL,
extra = NULL,
bathy = NULL,
dims_lake = NULL,
validate = TRUE,
glm_file = find_glm_nml(path_glm, must_exist = FALSE)
)Arguments
- path_glm
GLM-AED directory. Used to locate the nml when
glm_fileis not given and to resolve relativefilepaths for existence checks.- outlets
data.frame, one row per outlet. Recognised columns (all optional except where noted):
nameoutlet label, used only in messages.
typeGLM
outlet_type:1fixed,2floating,3adaptive/target-temperature,4-5other withdrawal modes,6submerged. Default2.floatlogical
flt_off_sw. Defaulttype == 2. GLM forces a floating outlet totype = 2.elevoutlet elevation (m, hypsography datum) - see Outlet elevation convention. Required for every outlet unless the existing block already has an
outl_elvsentry for it.bsn_len,bsn_widbasin length / width at the outlet (m). Computed from the hypsography when omitted.
factoroutflow_factor, per-outlet flow multiplier. Default1.fileoutflow_fl, path to the outlet's flow-forcing CSV, relative topath_glm. Carried over from the existing block when omitted and the outlet count is unchanged.target_temptarget_temp(degC) fortype == 3.critoutlet_crit, per-outlet critical threshold (Hcrit).subm_elevsubm_elev_outflowfortype == 6: a fixed submerged elevation as height above the bed (m),0 <= subm_elev <= max depth.elev_idxelev_idx_outflowfortype == 6: a dynamic layer index that overridessubm_elev. UseNA/-1for none.
- surface_elev
current lake surface elevation (m, hypsography datum), used to convert a floating outlet's
elevto a depth below the surface. Default:min(H) + lake_depthread from the nml.- seepage, seepage_rate
enable constant bed seepage and set its rate (m/day).
NULLleaves the current value.- withdr_temp_file
withdrTemp_fl: a single target-withdrawal- temperature forcing CSV (relative topath_glm) shared by the adaptive outlets.NULLleaves the current value;NAremoves it.- adaptive
named list of block-level adaptive-withdrawal controls, any of
crit_val,crit_dep,crit_days,crit_above,crit_varname,crit_idx,min_lake_temp,fac_range_upper,fac_range_lower,mix_withdraw,coupl_oxy_sw. Only supplied names are written.- crest_width, crest_factor
weir / overflow geometry for the surface outlet.
NULLleaves the current value.- thick_limit
outflow_thick_limit: minimum layer thickness (m) an outlet will draw from.NULLleaves the current value.- single_layer_draw
logical
single_layer_draw: force each outlet to draw from the single layer at its elevation.NULLleaves the current value.- extra
named list of any further raw
&outflowkeys to set verbatim (e.g.time_fmt,timezone). Applied last, so it overrides the above.- bathy
data.frame with
elev/areacolumns (the hypsograph), used to size outlets and to validate elevations. Default: theH/Aarrays in the nml's&morphometryblock.- dims_lake
length-2 numeric
c(basin_length, basin_width)at the crest. Default: the nml'sbsn_len/bsn_wid.- validate
check every value against GLM's ranges before writing and abort on any violation. Default
TRUE.- glm_file
path to the GLM nml. Default: discovered under
path_glm.
Details
Only the nml is updated - no outflow forcing CSVs are created or modified.
Point each outlet's file at a CSV you have already written (for example
with set_glm_outflows() or build_aeme()). Keys already present in the
&outflow block that you do not set here are left untouched.
Outlet elevation convention
elev is always given as an absolute elevation on the hypsography /
&morphometry H datum. For a fixed outlet it is written straight to
outl_elvs (GLM requires base_elev <= elev <= crest_elev). For a floating
offtake GLM instead wants a depth below the moving surface, so elev is
converted with surface_elev - elev and must satisfy
0 <= surface_elev - elev <= (crest_elev - base_elev).
Examples
if (FALSE) { # \dontrun{
# A floating offtake 2 m below the surface plus a fixed bottom gate,
# with bed seepage switched on.
set_glm_outflow_config(
path_glm,
outlets = data.frame(
name = c("spillway", "bottom_gate"),
type = c(2L, 1L),
elev = c(surface_elev - 2, base_elev + 0.5),
file = c("bcs/outflow_spillway.csv", "bcs/outflow_bottom_gate.csv")
),
seepage = TRUE, seepage_rate = 0.001
)
# An adaptive outlet targeting 12 degC.
set_glm_outflow_config(
path_glm,
outlets = data.frame(type = 3L, elev = surface_elev - 5,
target_temp = 12,
file = "bcs/outflow_wbal.csv"),
adaptive = list(min_lake_temp = 4, fac_range_upper = 1.2,
fac_range_lower = 0.8)
)
} # }