PISM, A Parallel Ice Sheet Model  stable v2.0.6 committed by Constantine Khrulev on 2023-01-23 15:14:38 -0900
Anomaly.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 "Anomaly.hh"
20 #include "pism/util/IceGrid.hh"
21 #include "pism/util/io/io_helpers.hh"
22 #include "pism/coupler/util/options.hh"
23 
24 namespace pism {
25 namespace surface {
26 
27 Anomaly::Anomaly(IceGrid::ConstPtr g, std::shared_ptr<SurfaceModel> in)
28  : SurfaceModel(g, in) {
29 
30  ForcingOptions opt(*m_grid->ctx(), "surface.anomaly");
31 
32  {
33  unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
34 
35  File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);
36 
38  file,
39  "ice_surface_temp_anomaly",
40  "", // no standard name
41  buffer_size,
42  opt.periodic,
43  LINEAR);
44 
46  file,
47  "climatic_mass_balance_anomaly",
48  "", // no standard name
49  buffer_size,
50  opt.periodic);
51  }
52 
53  m_ice_surface_temp_anomaly->set_attrs("climate_forcing",
54  "anomaly of the temperature of the ice at the ice surface"
55  " but below firn processes",
56  "Kelvin", "Kelvin", "", 0);
57  m_climatic_mass_balance_anomaly->set_attrs("climate_forcing",
58  "anomaly of the surface mass balance (accumulation/ablation) rate",
59  "kg m-2 s-1", "kg m-2 year-1", "", 0);
60 
63 
67 }
68 
69 void Anomaly::init_impl(const Geometry &geometry) {
70 
71  if (m_input_model) {
72  m_input_model->init(geometry);
73  }
74 
75  m_log->message(2,
76  "* Initializing the '-surface ...,anomaly' modifier...\n");
77 
78  ForcingOptions opt(*m_grid->ctx(), "surface.anomaly");
79 
80  m_log->message(2,
81  " reading anomalies from %s ...\n", opt.filename.c_str());
82 
85 }
86 
87 void Anomaly::update_impl(const Geometry &geometry, double t, double dt) {
88  m_input_model->update(geometry, t, dt);
89 
90  m_climatic_mass_balance_anomaly->update(t, dt);
91  m_ice_surface_temp_anomaly->update(t, dt);
92 
93  m_climatic_mass_balance_anomaly->average(t, dt);
94  m_ice_surface_temp_anomaly->average(t, dt);
95 
96  m_input_model->mass_flux().add(1.0, *m_climatic_mass_balance_anomaly,
97  *m_mass_flux);
98  m_input_model->temperature().add(1.0, *m_ice_surface_temp_anomaly,
99  *m_temperature);
100 
104 }
105 
107  return *m_mass_flux;
108 }
109 
111  return *m_temperature;
112 }
113 
115  return *m_accumulation;
116 }
117 
119  return *m_melt;
120 }
121 
123  return *m_runoff;
124 }
125 
126 } // end of namespace surface
127 } // 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)
virtual void update_impl(const Geometry &geometry, double t, double dt)
Definition: Anomaly.cc:87
IceModelVec2S::Ptr m_mass_flux
Definition: Anomaly.hh:45
const IceModelVec2S & accumulation_impl() const
Definition: Anomaly.cc:114
std::shared_ptr< IceModelVec2T > m_ice_surface_temp_anomaly
Definition: Anomaly.hh:49
const IceModelVec2S & runoff_impl() const
Definition: Anomaly.cc:122
virtual void init_impl(const Geometry &geometry)
Definition: Anomaly.cc:69
Anomaly(IceGrid::ConstPtr g, std::shared_ptr< SurfaceModel > in)
Definition: Anomaly.cc:27
const IceModelVec2S & mass_flux_impl() const
Definition: Anomaly.cc:106
IceModelVec2S::Ptr m_temperature
Definition: Anomaly.hh:46
const IceModelVec2S & temperature_impl() const
Definition: Anomaly.cc:110
std::shared_ptr< IceModelVec2T > m_climatic_mass_balance_anomaly
Definition: Anomaly.hh:48
const IceModelVec2S & melt_impl() const
Definition: Anomaly.cc:118
static IceModelVec2S::Ptr allocate_mass_flux(IceGrid::ConstPtr grid)
Definition: SurfaceModel.cc:76
IceModelVec2S::Ptr m_melt
static IceModelVec2S::Ptr allocate_melt(IceGrid::ConstPtr grid)
IceModelVec2S::Ptr m_accumulation
static IceModelVec2S::Ptr allocate_temperature(IceGrid::ConstPtr grid)
Definition: SurfaceModel.cc:93
std::shared_ptr< SurfaceModel > m_input_model
void dummy_accumulation(const IceModelVec2S &smb, IceModelVec2S &result)
static IceModelVec2S::Ptr allocate_accumulation(IceGrid::ConstPtr grid)
static IceModelVec2S::Ptr allocate_runoff(IceGrid::ConstPtr grid)
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
static const double g
Definition: exactTestP.cc:39
@ 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