PISM, A Parallel Ice Sheet Model  stable v2.0.5 committed by Constantine Khrulev on 2022-10-14 09:56:26 -0800
GivenClimate.cc
Go to the documentation of this file.
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021 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 "GivenClimate.hh"
20 
21 #include "pism/util/Time.hh"
22 #include "pism/util/IceGrid.hh"
23 #include "pism/coupler/util/options.hh"
24 
25 namespace pism {
26 namespace surface {
27 
28 Given::Given(IceGrid::ConstPtr grid, std::shared_ptr<atmosphere::AtmosphereModel> input)
29  : SurfaceModel(grid)
30 {
31  (void) input;
32 
33  ForcingOptions opt(*m_grid->ctx(), "surface.given");
34 
35  {
36  unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
37 
38  File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);
39 
41  file,
42  "ice_surface_temp",
43  "", // no standard name
44  buffer_size,
45  opt.periodic,
46  LINEAR);
47 
49  file,
50  "climatic_mass_balance",
51  "land_ice_surface_specific_mass_balance_flux",
52  buffer_size,
53  opt.periodic);
54  }
55 
56  m_temperature->set_attrs("climate_forcing",
57  "temperature of the ice at the ice surface but below firn processes",
58  "Kelvin", "Kelvin", "", 0);
59  m_temperature->metadata()["valid_range"] = {0.0, 323.15}; // [0C, 50C]
60 
61  const double smb_max = m_config->get_number("surface.given.smb_max", "kg m-2 second-1");
62 
63  m_mass_flux->set_attrs("climate_forcing",
64  "surface mass balance (accumulation/ablation) rate",
65  "kg m-2 s-1", "kg m-2 year-1",
66  "land_ice_surface_specific_mass_balance_flux", 0);
67 
68  m_mass_flux->metadata()["valid_range"] = {-smb_max, smb_max};
69 }
70 
71 void Given::init_impl(const Geometry &geometry) {
72 
73  m_log->message(2,
74  "* Initializing the surface model reading temperature at the top of the ice\n"
75  " and ice surface mass flux from a file...\n");
76 
77  ForcingOptions opt(*m_grid->ctx(), "surface.given");
78 
79  m_temperature->init(opt.filename, opt.periodic);
80  m_mass_flux->init(opt.filename, opt.periodic);
81 
82  // read time-independent data right away:
83  if (m_temperature->buffer_size() == 1 && m_mass_flux->buffer_size() == 1) {
84  update(geometry, m_grid->ctx()->time()->current(), 0); // dt is irrelevant
85  }
86 }
87 
88 void Given::update_impl(const Geometry &geometry, double t, double dt) {
89  (void) geometry;
90 
91  m_mass_flux->update(t, dt);
92  m_temperature->update(t, dt);
93 
94  m_mass_flux->average(t, dt);
95  m_temperature->average(t, dt);
96 
100 
101 }
102 
104  return *m_mass_flux;
105 }
106 
108  return *m_temperature;
109 }
110 
112  return *m_accumulation;
113 }
114 
116  return *m_melt;
117 }
118 
120  return *m_runoff;
121 }
122 
123 void Given::define_model_state_impl(const File &output) const {
124  m_mass_flux->define(output);
125  m_temperature->define(output);
126 }
127 
128 void Given::write_model_state_impl(const File &output) const {
129  m_mass_flux->write(output);
130  m_temperature->write(output);
131 }
132 
133 } // end of namespace surface
134 } // end of namespace pism
const Config::ConstPtr m_config
configuration database used by this component
Definition: Component.hh:138
const Logger::ConstPtr m_log
logger (for easy access)
Definition: Component.hh:142
const IceGrid::ConstPtr m_grid
grid used by this component
Definition: Component.hh:136
High-level PISM I/O class.
Definition: File.hh:51
std::shared_ptr< const IceGrid > ConstPtr
Definition: IceGrid.hh:233
static std::shared_ptr< IceModelVec2T > ForcingField(IceGrid::ConstPtr grid, const File &file, const std::string &short_name, const std::string &standard_name, int max_buffer_size, bool periodic, InterpolationType interpolation_type=PIECEWISE_CONSTANT)
std::shared_ptr< IceModelVec2T > m_mass_flux
Definition: GivenClimate.hh:46
const IceModelVec2S & runoff_impl() const
Given(IceGrid::ConstPtr g, std::shared_ptr< atmosphere::AtmosphereModel > input)
Definition: GivenClimate.cc:28
const IceModelVec2S & accumulation_impl() const
std::shared_ptr< IceModelVec2T > m_temperature
Definition: GivenClimate.hh:47
void update_impl(const Geometry &geometry, double t, double dt)
Definition: GivenClimate.cc:88
void init_impl(const Geometry &geometry)
Definition: GivenClimate.cc:71
const IceModelVec2S & mass_flux_impl() const
void write_model_state_impl(const File &output) const
The default (empty implementation).
const IceModelVec2S & melt_impl() const
const IceModelVec2S & temperature_impl() const
void define_model_state_impl(const File &output) const
The default (empty implementation).
void update(const Geometry &geometry, double t, double dt)
IceModelVec2S::Ptr m_melt
IceModelVec2S::Ptr m_accumulation
void dummy_accumulation(const IceModelVec2S &smb, IceModelVec2S &result)
IceModelVec2S::Ptr m_runoff
void dummy_runoff(const IceModelVec2S &smb, IceModelVec2S &result)
void dummy_melt(const IceModelVec2S &smb, IceModelVec2S &result)
The interface of PISM's surface models.
Definition: SurfaceModel.hh:45
@ PISM_NETCDF3
Definition: IO_Flags.hh:41
@ PISM_READONLY
open an existing file for reading only
Definition: IO_Flags.hh:49
std::string filename
Definition: options.hh:33