20 #include "pism/util/Mask.hh"
21 #include "pism/util/Vars.hh"
22 #include "pism/util/error_handling.hh"
23 #include "pism/util/iceModelVec2T.hh"
24 #include "pism/util/io/File.hh"
25 #include "pism/util/pism_options.hh"
26 #include "pism/util/pism_utilities.hh"
27 #include "pism/util/IceModelVec2CellType.hh"
28 #include "pism/geometry/Geometry.hh"
33 namespace diagnostics {
41 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass"}};
44 set_attrs(
"rate of change of the total mass of subglacial water",
"",
45 "kg second-1",
"Gt year-1", 0);
46 m_vars[0][
"cell_methods"] =
"time: mean";
49 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
54 return model->mass_change();
66 m_vars = {{
m_sys,
"subglacial_water_input_rate_from_surface"}};
69 set_attrs(
"water input rate from the ice surface into the subglacial water system",
70 "",
"m second-1",
"m year-1", 0);
71 m_vars[0][
"cell_methods"] =
"time: mean";
74 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
79 return model->surface_input_rate();
91 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass_due_to_input"}};
94 set_attrs(
"subglacial water flux due to input",
"",
95 "kg second-1",
"Gt year-1", 0);
96 m_vars[0][
"cell_methods"] =
"time: mean";
99 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
104 return model->mass_change_due_to_input();
119 set_attrs(
"magnitude of the subglacial water flux",
"",
120 "m2 second-1",
"m2 year-1", 0);
121 m_vars[0][
"cell_methods"] =
"time: mean";
126 "m2 s-1",
"m2 s-1",
"", 0);
150 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass_at_grounded_margins"}};
153 set_attrs(
"subglacial water flux at grounded ice margins",
"",
154 "kg second-1",
"Gt year-1", 0);
155 m_vars[0][
"cell_methods"] =
"time: mean";
158 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
163 return model->mass_change_at_grounded_margin();
174 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass_at_grounding_line"}};
177 set_attrs(
"subglacial water flux at grounding lines",
"",
178 "kg second-1",
"Gt year-1", 0);
179 m_vars[0][
"cell_methods"] =
"time: mean";
182 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
187 return model->mass_change_at_grounding_line();
199 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass_due_to_conservation_error"}};
202 set_attrs(
"subglacial water flux due to conservation error (mass added to preserve non-negativity)",
"",
203 "kg second-1",
"Gt year-1", 0);
204 m_vars[0][
"cell_methods"] =
"time: mean";
207 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
212 return model->mass_change_due_to_conservation_error();
223 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass_at_domain_boundary"}};
226 set_attrs(
"subglacial water flux at domain boundary (in regional model configurations)",
"",
227 "kg second-1",
"Gt year-1", 0);
228 m_vars[0][
"cell_methods"] =
"time: mean";
231 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
236 return model->mass_change_at_domain_boundary();
248 m_vars = {{
m_sys,
"tendency_of_subglacial_water_mass_due_to_flow"}};
251 set_attrs(
"rate of change subglacial water mass due to lateral flow",
"",
252 "kg second-1",
"Gt year-1", 0);
253 m_vars[0][
"cell_methods"] =
"time: mean";
256 m_vars[0][
"comment"] =
"positive flux corresponds to water gain";
261 return model->mass_change_due_to_lateral_flow();
281 m_surface_input_rate(m_grid,
"water_input_rate_from_surface",
WITHOUT_GHOSTS),
282 m_basal_melt_rate(m_grid,
"water_input_rate_due_to_basal_melt",
WITHOUT_GHOSTS),
283 m_flow_change_incremental(m_grid,
"water_thickness_change_due_to_flow",
WITHOUT_GHOSTS),
284 m_conservation_error_change(m_grid,
"conservation_error_change",
WITHOUT_GHOSTS),
285 m_grounded_margin_change(m_grid,
"grounded_margin_change",
WITHOUT_GHOSTS),
286 m_grounding_line_change(m_grid,
"grounding_line_change",
WITHOUT_GHOSTS),
287 m_input_change(m_grid,
"water_mass_change_due_to_input",
WITHOUT_GHOSTS),
288 m_no_model_mask_change(m_grid,
"no_model_mask_change",
WITHOUT_GHOSTS),
290 m_flow_change(m_grid,
"water_mass_change_due_to_flow",
WITHOUT_GHOSTS) {
293 "hydrology model workspace for water input rate from the ice surface",
294 "m s-1",
"m s-1",
"", 0);
297 "hydrology model workspace for water input rate due to basal melt",
298 "m s-1",
"m s-1",
"", 0);
302 "effective thickness of subglacial water stored in till",
312 "thickness of transportable subglacial water layer",
316 m_Q.
set_attrs(
"diagnostic",
"advective subglacial water flux",
317 "m2 s-1",
"m2 day-1",
"", 0);
322 "total change in water mass over one time step",
326 "change in water mass over one time step due to the input "
327 "(basal melt and surface drainage)",
332 "change in water mass due to lateral flow (over one time step)",
336 "changes in subglacial water thickness at the grounded margin",
339 "changes in subglacial water thickness at the grounding line",
343 "changes in subglacial water thickness at the edge of the modeling domain"
344 " (regional models)",
348 "changes in subglacial water thickness required "
349 "to preserve non-negativity or "
350 "keep water thickness within bounds",
381 (void) ice_thickness;
383 double tillwat_default =
m_config->get_number(
"bootstrapping.defaults.tillwat");
422 const int i = p.i(), j = p.j();
431 const int i = p.i(), j = p.j();
439 water_density =
m_config->get_number(
"constants.fresh_water.density"),
440 kg_per_m = water_density *
m_grid->cell_area();
444 const int i = p.i(), j = p.j();
456 {
"subglacial_water_input_rate",
Diagnostic::Ptr(
new TotalInputRate(
this))},
457 {
"tendency_of_subglacial_water_mass_due_to_input",
Diagnostic::Ptr(
new WaterInputFlux(
this))},
458 {
"tendency_of_subglacial_water_mass_due_to_flow",
Diagnostic::Ptr(
new TendencyOfWaterMassDueToFlow(
this))},
459 {
"tendency_of_subglacial_water_mass_due_to_conservation_error",
Diagnostic::Ptr(
new ConservationErrorFlux(
this))},
460 {
"tendency_of_subglacial_water_mass",
Diagnostic::Ptr(
new TendencyOfWaterMass(
this))},
461 {
"tendency_of_subglacial_water_mass_at_grounded_margins",
Diagnostic::Ptr(
new GroundedMarginFlux(
this))},
462 {
"tendency_of_subglacial_water_mass_at_grounding_line",
Diagnostic::Ptr(
new GroundingLineFlux(
this))},
463 {
"tendency_of_subglacial_water_mass_at_domain_boundary",
Diagnostic::Ptr(
new DomainBoundaryFlux(
this))},
464 {
"subglacial_water_flux_mag",
Diagnostic::Ptr(
new SubglacialWaterFlux(
this))},
488 ice_density =
m_config->get_number(
"constants.ice.density"),
489 standard_gravity =
m_config->get_number(
"constants.standard_gravity");
494 const int i = p.i(), j = p.j();
496 result(i, j) = ice_density * standard_gravity * ice_thickness(i, j);
567 const int i = p.i(), j = p.j();
571 "Hydrology: negative %s of %.6f m at (i, j) = (%d, %d)",
572 name.c_str(), W(i, j), i, j);
575 if (W(i,j) > W_max) {
577 "Hydrology: %s of %.6f m exceeds the maximum value %.6f at (i, j) = (%d, %d)",
578 name.c_str(), W(i, j), W_max, i, j);
609 water_density =
m_config->get_number(
"constants.fresh_water.density");
612 const int i = p.i(), j = p.j();
614 if (mask.
icy(i, j)) {
615 result(i,j) = (*surface_input_rate)(i, j) / water_density;
638 ice_density =
m_config->get_number(
"constants.ice.density"),
639 water_density =
m_config->get_number(
"constants.fresh_water.density"),
640 C = ice_density / water_density;
643 const int i = p.i(), j = p.j();
645 if (mask.
icy(i, j)) {
646 result(i,j) =
C * basal_melt_rate(i, j);
675 double max_thickness,
676 double ocean_water_thickness,
683 bool include_floating =
m_config->get_flag(
"hydrology.routing.include_floating_ice");
686 &grounded_margin_change, &grounding_line_change, &conservation_error_change,
687 &no_model_mask_change};
690 fresh_water_density =
m_config->get_number(
"constants.fresh_water.density"),
691 kg_per_m =
m_grid->cell_area() * fresh_water_density;
694 const int i = p.i(), j = p.j();
696 if (water_thickness(i, j) < 0.0) {
697 conservation_error_change(i, j) += -water_thickness(i, j) * kg_per_m;
698 water_thickness(i, j) = 0.0;
701 if (max_thickness > 0.0 and water_thickness(i, j) > max_thickness) {
702 double excess = water_thickness(i, j) - max_thickness;
704 conservation_error_change(i, j) += -excess * kg_per_m;
705 water_thickness(i, j) = max_thickness;
709 double grounded_ice_free_max_thickness = 0.0;
710 double excess = water_thickness(i, j) - grounded_ice_free_max_thickness;
711 grounded_margin_change(i, j) += -excess * kg_per_m;
712 water_thickness(i, j) = grounded_ice_free_max_thickness;
728 (not include_floating and cell_type.
ocean(i, j))) {
730 double mismatch = water_thickness(i, j) - ocean_water_thickness;
732 grounding_line_change(i, j) += -mismatch * kg_per_m;
733 water_thickness(i, j) = ocean_water_thickness;
743 const int i = p.i(), j = p.j();
746 no_model_mask_change(i, j) += -water_thickness(i, j) * kg_per_m;
748 water_thickness(i, j) = 0.0;
Makes sure that we call begin_access() and end_access() for all accessed IceModelVecs.
IceGrid::ConstPtr grid() const
const Config::ConstPtr m_config
configuration database used by this component
virtual void regrid(const std::string &module_name, IceModelVec &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
const IceGrid::ConstPtr m_grid
grid used by this component
DiagnosticList diagnostics() const
A class defining a common interface for most PISM sub-models.
IceModelVec2S m_accumulator
static Ptr wrap(const T &input)
double m_fill_value
fill value (used often enough to justify storing it)
const units::System::Ptr m_sys
the unit system
double to_internal(double x) const
std::vector< SpatialVariableMetadata > m_vars
metadata corresponding to NetCDF variables
std::shared_ptr< Diagnostic > Ptr
IceGrid::ConstPtr m_grid
the grid
void set_attrs(const std::string &long_name, const std::string &standard_name, const std::string &units, const std::string &glaciological_units, unsigned int N=0)
A method for setting common variable attributes.
High-level PISM I/O class.
IceModelVec2CellType cell_type
IceModelVec2S ice_thickness
std::shared_ptr< const IceGrid > ConstPtr
bool ice_free_land(int i, int j) const
bool icy(int i, int j) const
bool ice_free_ocean(int i, int j) const
bool ocean(int i, int j) const
"Cell type" mask. Adds convenience methods to IceModelVec2Int.
A simple class "hiding" the fact that the mask is stored as floating-point scalars (instead of intege...
void add(double alpha, const IceModelVec2S &x)
void copy_from(const IceModelVec2S &source)
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
void set_attrs(const std::string &pism_intent, const std::string &long_name, const std::string &units, const std::string &glaciological_units, const std::string &standard_name, unsigned int component)
Sets NetCDF attributes of an IceModelVec object.
void regrid(const std::string &filename, RegriddingFlag flag, double default_value=0.0)
void set(double c)
Result: v[j] <- c for all j.
void read(const std::string &filename, unsigned int time)
IceGrid::ConstPtr grid() const
void define(const File &file, IO_Type default_type=PISM_DOUBLE) const
Define variables corresponding to an IceModelVec in a file opened using file.
void write(const std::string &filename) const
void failed()
Indicates a failure of a parallel section.
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
const IceModelVec2S & mass_change_due_to_conservation_error() const
void restart(const File &input_file, int record)
const IceModelVec2S & mass_change_at_grounded_margin() const
IceModelVec2S m_flow_change
IceModelVec2S m_total_change
Hydrology(IceGrid::ConstPtr g)
const IceModelVec2S & mass_change_at_domain_boundary() const
IceModelVec2S m_input_change
IceModelVec2S m_surface_input_rate
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
IceModelVec2S m_no_model_mask_change
IceModelVec2S m_basal_melt_rate
const IceModelVec2V & flux() const
IceModelVec2S m_W
effective thickness of transportable basal water
const IceModelVec2S & mass_change_at_grounding_line() const
virtual void initialization_message() const =0
void compute_basal_melt_rate(const IceModelVec2CellType &mask, const IceModelVec2S &basal_melt_rate, IceModelVec2S &result)
const IceModelVec2S & surface_input_rate() const
IceModelVec2S m_grounded_margin_change
void compute_surface_input_rate(const IceModelVec2CellType &mask, const IceModelVec2S *surface_input_rate, IceModelVec2S &result)
virtual void restart_impl(const File &input_file, int record)
virtual void init_impl(const IceModelVec2S &W_till, const IceModelVec2S &W, const IceModelVec2S &P)
void update(double t, double dt, const Inputs &inputs)
void bootstrap(const File &input_file, const IceModelVec2S &ice_thickness)
const IceModelVec2S & mass_change_due_to_input() const
IceModelVec2S m_Pover
overburden pressure
const IceModelVec2S & mass_change() const
IceModelVec2S m_Wtill
effective thickness of basal water stored in till
IceModelVec2S m_grounding_line_change
virtual void update_impl(double t, double dt, const Inputs &inputs)=0
IceModelVec2S m_conservation_error_change
virtual std::map< std::string, Diagnostic::Ptr > diagnostics_impl() const
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual void bootstrap_impl(const File &input_file, const IceModelVec2S &ice_thickness)
void compute_overburden_pressure(const IceModelVec2S &ice_thickness, IceModelVec2S &result) const
Update the overburden pressure from ice thickness.
const IceModelVec2S & subglacial_water_thickness() const
Return the effective thickness of the transportable basal water layer.
const IceModelVec2S & overburden_pressure() const
const IceModelVec2S & mass_change_due_to_lateral_flow() const
void init(const IceModelVec2S &W_till, const IceModelVec2S &W, const IceModelVec2S &P)
void enforce_bounds(const IceModelVec2CellType &cell_type, const IceModelVec2Int *no_model_mask, double max_thickness, double ocean_water_thickness, IceModelVec2S &water_thickness, IceModelVec2S &grounded_margin_change, IceModelVec2S &grounding_line_change, IceModelVec2S &conservation_error_change, IceModelVec2S &no_model_mask_change)
Correct the new water thickness based on boundary requirements.
const IceModelVec2S & till_water_thickness() const
Return the effective thickness of the water stored in till.
The PISM subglacial hydrology model interface.
const IceModelVec2S & model_input()
ConservationErrorFlux(const Hydrology *m)
Report subglacial water conservation error flux (mass added to preserve non-negativity).
const IceModelVec2S & model_input()
DomainBoundaryFlux(const Hydrology *m)
Report subglacial water flux at domain boundary (in regional model configurations).
const IceModelVec2S & model_input()
GroundedMarginFlux(const Hydrology *m)
Report water flux at the grounded margin.
GroundingLineFlux(const Hydrology *m)
const IceModelVec2S & model_input()
Report subglacial water flux at grounding lines.
SubglacialWaterFlux(const Hydrology *m)
IceModelVec2S m_flux_magnitude
void update_impl(double dt)
Report advective subglacial water flux.
const IceModelVec2S & model_input()
TendencyOfWaterMassDueToFlow(const Hydrology *m)
Report water flux at the grounded margin.
TendencyOfWaterMass(const Hydrology *m)
const IceModelVec2S & model_input()
#define PISM_ERROR_LOCATION
void check_bounds(const IceModelVec2S &W, double W_max)
void compute_magnitude(const IceModelVec2S &v_x, const IceModelVec2S &v_y, IceModelVec2S &result)
Sets an IceModelVec2 to the magnitude of a 2D vector field with components v_x and v_y.
std::map< std::string, Diagnostic::Ptr > DiagnosticList