PISM, A Parallel Ice Sheet Model 2.3.0-79cae578d committed by Constantine Khrulev on 2026-03-22
Loading...
Searching...
No Matches
ElevationChange.cc
Go to the documentation of this file.
1// Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2025 PISM Authors
2//
3// This file is part of PISM.
4//
5// PISM is free software; you can redistribute it and/or modify it under the
6// terms of the GNU General Public License as published by the Free Software
7// Foundation; either version 3 of the License, or (at your option) any later
8// version.
9//
10// PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13// details.
14//
15// You should have received a copy of the GNU General Public License
16// along with PISM; if not, write to the Free Software
17// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19#include "pism/coupler/surface/ElevationChange.hh"
20#include "pism/coupler/util/options.hh"
21#include "pism/coupler/util/lapse_rates.hh"
22#include "pism/geometry/Geometry.hh"
23#include "pism/util/array/Forcing.hh"
24#include "pism/util/Logger.hh"
25#include "pism/util/io/IO_Flags.hh"
26
27namespace pism {
28namespace surface {
29
30ElevationChange::ElevationChange(std::shared_ptr<const Grid> g, std::shared_ptr<SurfaceModel> in)
31 : SurfaceModel(g, in) {
32
33 {
34 m_smb_lapse_rate = m_config->get_number("surface.elevation_change.smb.lapse_rate",
35 "(m / s) / m");
36 // convert from [m s-1 / m] to [kg m-2 s-1 / m]
37 m_smb_lapse_rate *= m_config->get_number("constants.ice.density");
38
39 m_smb_exp_factor = m_config->get_number("surface.elevation_change.smb.exp_factor");
40 }
41
42 {
43 auto method = m_config->get_string("surface.elevation_change.smb.method");
44 m_smb_method = method == "scale" ? SCALE : SHIFT;
45 }
46
47 m_temp_lapse_rate = m_config->get_number("surface.elevation_change.temperature_lapse_rate",
48 "K / m");
49
50 {
51 ForcingOptions opt(*m_grid->ctx(), "surface.elevation_change");
52
53 unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
54
56
57 m_reference_surface = std::make_shared<array::Forcing>(m_grid, file, "usurf",
58 "", // no standard name
59 buffer_size, opt.periodic, LINEAR);
60 m_reference_surface->metadata(0)
61 .long_name("ice surface elevation")
62 .units("m")
63 .standard_name("surface_altitude");
64 }
65
71}
72
73void ElevationChange::init_impl(const Geometry &geometry) {
74 using units::convert;
75
76 m_input_model->init(geometry);
77
78 m_log->message(2,
79 " [using temperature and mass balance lapse corrections]\n");
80
81 m_log->message(2,
82 " ice upper-surface temperature lapse rate: %3.3f K per km\n",
83 convert(m_sys, m_temp_lapse_rate, "K / m", "K / km"));
84
85 if (m_smb_method == SHIFT) {
86 double ice_density = m_config->get_number("constants.ice.density");
87 m_log->message(2,
88 " ice-equivalent surface mass balance lapse rate: %3.3f m year-1 per km\n",
89 convert(m_sys, m_smb_lapse_rate, "kg / (m2 second)", "kg / (m2 year)") / ice_density);
90 } else {
91 m_log->message(2,
92 " surface mass balance scaling factor with temperature: %3.3f kelvin^-1\n",
94 }
95
96 ForcingOptions opt(*m_grid->ctx(), "surface.elevation_change");
98}
99
100void ElevationChange::update_impl(const Geometry &geometry, double t, double dt) {
101
102 m_input_model->update(geometry, t, dt);
103
104 m_reference_surface->update(t, dt);
105 m_reference_surface->interp(t + 0.5*dt);
106
107 const array::Scalar &surface = geometry.ice_surface_elevation;
108
109 m_temperature->copy_from(m_input_model->temperature());
112
113 m_mass_flux->copy_from(m_input_model->mass_flux());
114
115 switch (m_smb_method) {
116 case SCALE:
117 {
118 array::AccessScope list{&surface, m_reference_surface.get(), m_mass_flux.get()};
119
120 for (auto p : m_grid->points()) {
121 const int i = p.i(), j = p.j();
122
123 double dT = -m_temp_lapse_rate * (surface(i, j) - (*m_reference_surface)(i, j));
124
125 (*m_mass_flux)(i, j) *= exp(m_smb_exp_factor * dT);
126 }
127 }
128 break;
129 default:
130 case SHIFT:
131 {
134 }
135 break;
136 }
137
138 // This modifier changes m_mass_flux, so we need to compute accumulation, melt, and
139 // runoff.
143
144}
145
149
153
157
159 return *m_melt;
160}
161
163 return *m_runoff;
164}
165
166
167} // end of namespace surface
168} // end of namespace pism
const units::System::Ptr m_sys
unit system used by this component
Definition Component.hh:162
std::shared_ptr< const Config > m_config
configuration database used by this component
Definition Component.hh:160
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition Component.hh:158
std::shared_ptr< const Logger > m_log
logger (for easy access)
Definition Component.hh:164
High-level PISM I/O class.
Definition File.hh:57
array::Scalar2 ice_surface_elevation
Definition Geometry.hh:57
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition Array.hh:66
void copy_from(const Array2D< T > &source)
Definition Array2D.hh:101
virtual void init_impl(const Geometry &geometry)
virtual void update_impl(const Geometry &geometry, double t, double dt)
std::shared_ptr< array::Scalar > m_mass_flux
const array::Scalar & melt_impl() const
const array::Scalar & accumulation_impl() const
std::shared_ptr< array::Forcing > m_reference_surface
std::shared_ptr< array::Scalar > m_temperature
const array::Scalar & temperature_impl() const
const array::Scalar & runoff_impl() const
ElevationChange(std::shared_ptr< const Grid > g, std::shared_ptr< SurfaceModel > in)
const array::Scalar & mass_flux_impl() const
static std::shared_ptr< array::Scalar > allocate_runoff(std::shared_ptr< const Grid > grid)
static std::shared_ptr< array::Scalar > allocate_mass_flux(std::shared_ptr< const Grid > grid)
void dummy_accumulation(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< array::Scalar > m_melt
static std::shared_ptr< array::Scalar > allocate_temperature(std::shared_ptr< const Grid > grid)
static std::shared_ptr< array::Scalar > allocate_accumulation(std::shared_ptr< const Grid > grid)
static std::shared_ptr< array::Scalar > allocate_melt(std::shared_ptr< const Grid > grid)
std::shared_ptr< array::Scalar > m_runoff
void dummy_melt(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< SurfaceModel > m_input_model
std::shared_ptr< array::Scalar > m_accumulation
void dummy_runoff(const array::Scalar &smb, array::Scalar &result)
The interface of PISM's surface models.
@ PISM_NETCDF3
Definition IO_Flags.hh:58
@ PISM_READONLY
open an existing file for reading only
Definition IO_Flags.hh:69
double convert(System::Ptr system, double input, const std::string &spec1, const std::string &spec2)
Convert a quantity from unit1 to unit2.
Definition Units.cc:70
static const double g
Definition exactTestP.cc:36
void lapse_rate_correction(const array::Scalar &surface, const array::Scalar &reference_surface, double lapse_rate, array::Scalar &result)
std::string filename
Definition options.hh:33