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