tAnomaly.cc - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tAnomaly.cc (5114B)
---
1 // Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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 unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
35 bool periodic = opt.period > 0;
36
37 File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);
38
39 m_ice_surface_temp_anomaly = IceModelVec2T::ForcingField(m_grid,
40 file,
41 "ice_surface_temp_anomaly",
42 "", // no standard name
43 buffer_size,
44 evaluations_per_year,
45 periodic,
46 LINEAR);
47
48 m_climatic_mass_balance_anomaly = IceModelVec2T::ForcingField(m_grid,
49 file,
50 "climatic_mass_balance_anomaly",
51 "", // no standard name
52 buffer_size,
53 evaluations_per_year,
54 periodic);
55 }
56
57 m_ice_surface_temp_anomaly->set_attrs("climate_forcing",
58 "anomaly of the temperature of the ice at the ice surface"
59 " but below firn processes",
60 "Kelvin", "Kelvin", "", 0);
61 m_climatic_mass_balance_anomaly->set_attrs("climate_forcing",
62 "anomaly of the surface mass balance (accumulation/ablation) rate",
63 "kg m-2 s-1", "kg m-2 year-1", "", 0);
64
65 m_mass_flux = allocate_mass_flux(g);
66 m_temperature = allocate_temperature(g);
67
68 m_accumulation = allocate_accumulation(g);
69 m_melt = allocate_melt(g);
70 m_runoff = allocate_runoff(g);
71 }
72
73 Anomaly::~Anomaly() {
74 // empty
75 }
76
77 void Anomaly::init_impl(const Geometry &geometry) {
78
79 if (m_input_model) {
80 m_input_model->init(geometry);
81 }
82
83 m_log->message(2,
84 "* Initializing the '-surface ...,anomaly' modifier...\n");
85
86 ForcingOptions opt(*m_grid->ctx(), "surface.anomaly");
87
88 m_log->message(2,
89 " reading anomalies from %s ...\n", opt.filename.c_str());
90
91 m_ice_surface_temp_anomaly->init(opt.filename, opt.period, opt.reference_time);
92 m_climatic_mass_balance_anomaly->init(opt.filename, opt.period, opt.reference_time);
93 }
94
95 void Anomaly::update_impl(const Geometry &geometry, double t, double dt) {
96 m_input_model->update(geometry, t, dt);
97
98 m_climatic_mass_balance_anomaly->update(t, dt);
99 m_ice_surface_temp_anomaly->update(t, dt);
100
101 m_climatic_mass_balance_anomaly->average(t, dt);
102 m_ice_surface_temp_anomaly->average(t, dt);
103
104 m_input_model->mass_flux().add(1.0, *m_climatic_mass_balance_anomaly,
105 *m_mass_flux);
106 m_input_model->temperature().add(1.0, *m_ice_surface_temp_anomaly,
107 *m_temperature);
108
109 dummy_accumulation(*m_mass_flux, *m_accumulation);
110 dummy_melt(*m_mass_flux, *m_melt);
111 dummy_runoff(*m_mass_flux, *m_runoff);
112 }
113
114 const IceModelVec2S &Anomaly::mass_flux_impl() const {
115 return *m_mass_flux;
116 }
117
118 const IceModelVec2S &Anomaly::temperature_impl() const {
119 return *m_temperature;
120 }
121
122 const IceModelVec2S &Anomaly::accumulation_impl() const {
123 return *m_accumulation;
124 }
125
126 const IceModelVec2S &Anomaly::melt_impl() const {
127 return *m_melt;
128 }
129
130 const IceModelVec2S &Anomaly::runoff_impl() const {
131 return *m_runoff;
132 }
133
134 } // end of namespace surface
135 } // end of namespace pism