PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
ConstantPIK.cc
Go to the documentation of this file.
1 // Copyright (C) 2008-2019, 2023 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/ConstantPIK.hh"
20 #include "pism/util/io/File.hh"
21 #include "pism/util/Vars.hh"
22 #include "pism/util/Grid.hh"
23 #include "pism/util/pism_utilities.hh"
24 #include "pism/util/MaxTimestep.hh"
25 #include "pism/geometry/Geometry.hh"
26 
27 namespace pism {
28 namespace surface {
29 
30 ///// Constant-in-time surface model for accumulation,
31 ///// ice surface temperature parameterized as in PISM-PIK dependent on latitude and surface elevation
32 
33 
34 PIK::PIK(std::shared_ptr<const Grid> grid, std::shared_ptr<atmosphere::AtmosphereModel> atmosphere)
35  : SurfaceModel(grid) {
36  (void) atmosphere;
37 
40 }
41 
42 void PIK::init_impl(const Geometry &geometry) {
43  (void) geometry;
44 
45  m_log->message(2,
46  "* Initializing the constant-in-time surface processes model PIK.\n"
47  " It reads surface mass balance directly from the file and holds it constant.\n"
48  " Ice upper-surface temperature is parameterized as in Martin et al. 2011, equation (1).\n"
49  " Any choice of atmosphere coupler (option '-atmosphere') is ignored.\n");
50 
52 
53  // read snow precipitation rate from file
54  m_log->message(2,
55  " reading surface mass balance rate 'climatic_mass_balance' from %s ... \n",
56  opts.filename.c_str());
57  if (opts.type == INIT_BOOTSTRAP) {
58  m_mass_flux->regrid(opts.filename, io::Default::Nil()); // fails if not found!
59  } else {
60  m_mass_flux->read(opts.filename, opts.record); // fails if not found!
61  }
62 
63  // parameterizing the ice surface temperature 'ice_surface_temp'
64  m_log->message(2,
65  " parameterizing the ice surface temperature 'ice_surface_temp' ... \n");
66 }
67 
69  (void) t;
70  return MaxTimestep("surface PIK");
71 }
72 
73 void PIK::update_impl(const Geometry &geometry, double t, double dt) {
74  (void) t;
75  (void) dt;
76 
77  const array::Scalar
78  &surface_elevation = geometry.ice_surface_elevation,
79  &latitude = geometry.latitude;
80 
81  array::AccessScope list{ m_temperature.get(), &surface_elevation, &latitude };
82 
83  for (auto p = m_grid->points(); p; p.next()) {
84  const int i = p.i(), j = p.j();
85  (*m_temperature)(i, j) = 273.15 + 30 - 0.0075 * surface_elevation(i, j) - 0.68775 * latitude(i, j) * (-1.0);
86  }
87 
91 
92 }
93 
95  return *m_mass_flux;
96 }
97 
99  return *m_temperature;
100 }
101 
103  return *m_accumulation;
104 }
105 
107  return *m_melt;
108 }
109 
111  return *m_runoff;
112 }
113 
114 void PIK::define_model_state_impl(const File &output) const {
115  m_mass_flux->define(output, io::PISM_DOUBLE);
117 }
118 
119 void PIK::write_model_state_impl(const File &output) const {
120  m_mass_flux->write(output);
122 }
123 
124 } // end of namespace surface
125 } // end of namespace pism
std::shared_ptr< const Grid > grid() const
Definition: Component.cc:105
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:158
const Logger::ConstPtr m_log
logger (for easy access)
Definition: Component.hh:162
const std::shared_ptr< const Grid > m_grid
grid used by this component
Definition: Component.hh:156
High-level PISM I/O class.
Definition: File.hh:56
array::Scalar2 ice_surface_elevation
Definition: Geometry.hh:57
array::Scalar latitude
Definition: Geometry.hh:41
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
Definition: Array.hh:65
static Default Nil()
Definition: IO_Flags.hh:97
MaxTimestep max_timestep_impl(double t) const
Definition: ConstantPIK.cc:68
std::shared_ptr< array::Scalar > m_temperature
Definition: ConstantPIK.hh:55
const array::Scalar & mass_flux_impl() const
Definition: ConstantPIK.cc:94
const array::Scalar & runoff_impl() const
Definition: ConstantPIK.cc:110
const array::Scalar & temperature_impl() const
Definition: ConstantPIK.cc:98
const array::Scalar & accumulation_impl() const
Definition: ConstantPIK.cc:102
PIK(std::shared_ptr< const Grid > g, std::shared_ptr< atmosphere::AtmosphereModel > atmosphere)
Definition: ConstantPIK.cc:34
void write_model_state_impl(const File &output) const
The default (empty implementation).
Definition: ConstantPIK.cc:119
void define_model_state_impl(const File &output) const
The default (empty implementation).
Definition: ConstantPIK.cc:114
const array::Scalar & melt_impl() const
Definition: ConstantPIK.cc:106
void update_impl(const Geometry &geometry, double t, double dt)
Definition: ConstantPIK.cc:73
std::shared_ptr< array::Scalar > m_mass_flux
Definition: ConstantPIK.hh:54
void init_impl(const Geometry &geometry)
Definition: ConstantPIK.cc:42
static std::shared_ptr< array::Scalar > allocate_mass_flux(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:73
void dummy_accumulation(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< array::Scalar > m_melt
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
static std::shared_ptr< array::Scalar > allocate_temperature(std::shared_ptr< const Grid > grid)
Definition: SurfaceModel.cc:92
std::shared_ptr< array::Scalar > m_runoff
void dummy_melt(const array::Scalar &smb, array::Scalar &result)
std::shared_ptr< array::Scalar > m_accumulation
void dummy_runoff(const array::Scalar &smb, array::Scalar &result)
The interface of PISM's surface models.
Definition: SurfaceModel.hh:42
@ PISM_DOUBLE
Definition: IO_Flags.hh:52
InputOptions process_input_options(MPI_Comm com, Config::ConstPtr config)
Definition: Component.cc:43
@ INIT_BOOTSTRAP
Definition: Component.hh:56
InitializationType type
initialization type
Definition: Component.hh:61
std::string filename
name of the input file (if applicable)
Definition: Component.hh:63
unsigned int record
index of the record to re-start from
Definition: Component.hh:65