PISM, A Parallel Ice Sheet Model  stable v2.1-1-g6902d5502 committed by Ed Bueler on 2023-12-20 08:38:27 -0800
GivenClimate.cc
Go to the documentation of this file.
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2021, 2022, 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/ocean/GivenClimate.hh"
20 
21 #include "pism/util/Grid.hh"
22 #include "pism/util/Time.hh"
23 
24 #include "pism/coupler/util/options.hh"
25 #include "pism/util/array/Forcing.hh"
26 
27 namespace pism {
28 namespace ocean {
29 
30 Given::Given(std::shared_ptr<const Grid> g)
31  : OceanModel(g, std::shared_ptr<OceanModel>()) {
32 
35 
36  ForcingOptions opt(*m_grid->ctx(), "ocean.given");
37 
38  {
39  unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
40 
42 
43  m_shelfbtemp = std::make_shared<array::Forcing>(m_grid,
44  file,
45  "shelfbtemp",
46  "", // no standard name
47  buffer_size,
48  opt.periodic,
49  LINEAR);
50 
51  m_shelfbmassflux = std::make_shared<array::Forcing>(m_grid,
52  file,
53  "shelfbmassflux",
54  "", // no standard name
55  buffer_size,
56  opt.periodic);
57  }
58 
59  m_shelfbtemp->metadata(0)
60  .long_name("absolute temperature at ice shelf base")
61  .units("Kelvin");
62 
63  m_shelfbmassflux->metadata(0)
64  .long_name("ice mass flux from ice shelf base (positive flux is loss from ice shelf)")
65  .units("kg m-2 s-1")
66  .output_units("kg m-2 year-1");
67 }
68 
69 void Given::init_impl(const Geometry &geometry) {
70 
71  m_log->message(2,
72  "* Initializing the ocean model reading base of the shelf temperature\n"
73  " and sub-shelf mass flux from a file...\n");
74 
75  ForcingOptions opt(*m_grid->ctx(), "ocean.given");
76 
77  m_shelfbtemp->init(opt.filename, opt.periodic);
78  m_shelfbmassflux->init(opt.filename, opt.periodic);
79 
80  // read time-independent data right away:
81  if (m_shelfbtemp->buffer_size() == 1 && m_shelfbmassflux->buffer_size() == 1) {
82  update(geometry, time().current(), 0); // dt is irrelevant
83  }
84 
85  const double
86  ice_density = m_config->get_number("constants.ice.density"),
87  water_density = m_config->get_number("constants.sea_water.density"),
88  g = m_config->get_number("constants.standard_gravity");
89 
90  compute_average_water_column_pressure(geometry, ice_density, water_density, g,
92 }
93 
94 void Given::update_impl(const Geometry &geometry, double t, double dt) {
95  (void) geometry;
96 
97  m_shelfbmassflux->update(t, dt);
98  m_shelfbtemp->update(t, dt);
99 
100  m_shelfbmassflux->average(t, dt);
101  m_shelfbtemp->average(t, dt);
102 
105 
106  const double
107  ice_density = m_config->get_number("constants.ice.density"),
108  water_density = m_config->get_number("constants.sea_water.density"),
109  g = m_config->get_number("constants.standard_gravity");
110 
111  compute_average_water_column_pressure(geometry, ice_density, water_density, g,
113 }
114 
116  (void) t;
117 
118  return MaxTimestep("ocean th");
119 }
120 
122  return *m_shelf_base_temperature;
123 }
124 
126  return *m_shelf_base_mass_flux;
127 }
128 
129 } // end of namespace ocean
130 } // end of namespace pism
const Time & time() const
Definition: Component.cc:109
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
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
Definition: MaxTimestep.hh:31
Given(std::shared_ptr< const Grid > g)
Definition: GivenClimate.cc:30
std::shared_ptr< array::Forcing > m_shelfbmassflux
Definition: GivenClimate.hh:42
std::shared_ptr< array::Scalar > m_shelf_base_temperature
Definition: GivenClimate.hh:44
std::shared_ptr< array::Scalar > m_shelf_base_mass_flux
Definition: GivenClimate.hh:45
void init_impl(const Geometry &geometry)
Definition: GivenClimate.cc:69
std::shared_ptr< array::Forcing > m_shelfbtemp
Definition: GivenClimate.hh:41
const array::Scalar & shelf_base_temperature_impl() const
MaxTimestep max_timestep_impl(double t) const
void update_impl(const Geometry &geometry, double t, double dt)
Definition: GivenClimate.cc:94
const array::Scalar & shelf_base_mass_flux_impl() const
std::shared_ptr< array::Scalar > m_water_column_pressure
Definition: OceanModel.hh:73
static std::shared_ptr< array::Scalar > allocate_shelf_base_temperature(std::shared_ptr< const Grid > g)
Definition: OceanModel.cc:31
static std::shared_ptr< array::Scalar > allocate_shelf_base_mass_flux(std::shared_ptr< const Grid > g)
Definition: OceanModel.cc:39
void update(const Geometry &geometry, double t, double dt)
Definition: OceanModel.cc:89
A very rudimentary PISM ocean model.
Definition: OceanModel.hh:33
@ PISM_NETCDF3
Definition: IO_Flags.hh:57
@ PISM_READONLY
open an existing file for reading only
Definition: IO_Flags.hh:72
bool ocean(int M)
An ocean cell (floating ice or ice-free).
Definition: Mask.hh:40
void compute_average_water_column_pressure(const Geometry &geometry, double ice_density, double water_density, double g, array::Scalar &result)
Definition: OceanModel.cc:217
static const double g
Definition: exactTestP.cc:36
std::string filename
Definition: options.hh:33