tGivenClimate.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
---
tGivenClimate.cc (4848B)
---
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 "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 unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
38 bool periodic = opt.period > 0;
39
40 File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);
41
42 m_temperature = IceModelVec2T::ForcingField(m_grid,
43 file,
44 "ice_surface_temp",
45 "", // no standard name
46 buffer_size,
47 evaluations_per_year,
48 periodic,
49 LINEAR);
50
51 m_mass_flux = IceModelVec2T::ForcingField(m_grid,
52 file,
53 "climatic_mass_balance",
54 "land_ice_surface_specific_mass_balance_flux",
55 buffer_size,
56 evaluations_per_year,
57 periodic);
58 }
59
60 m_temperature->set_attrs("climate_forcing",
61 "temperature of the ice at the ice surface but below firn processes",
62 "Kelvin", "Kelvin", "", 0);
63 m_temperature->metadata().set_numbers("valid_range", {0.0, 323.15}); // [0C, 50C]
64
65 const double smb_max = m_config->get_number("surface.given.smb_max", "kg m-2 second-1");
66
67 m_mass_flux->set_attrs("climate_forcing",
68 "surface mass balance (accumulation/ablation) rate",
69 "kg m-2 s-1", "kg m-2 year-1",
70 "land_ice_surface_specific_mass_balance_flux", 0);
71
72 m_mass_flux->metadata().set_numbers("valid_range", {-smb_max, smb_max});
73 }
74
75 Given::~Given() {
76 // empty
77 }
78
79 void Given::init_impl(const Geometry &geometry) {
80
81 m_log->message(2,
82 "* Initializing the surface model reading temperature at the top of the ice\n"
83 " and ice surface mass flux from a file...\n");
84
85 ForcingOptions opt(*m_grid->ctx(), "surface.given");
86
87 m_temperature->init(opt.filename, opt.period, opt.reference_time);
88 m_mass_flux->init(opt.filename, opt.period, opt.reference_time);
89
90 // read time-independent data right away:
91 if (m_temperature->n_records() == 1 && m_mass_flux->n_records() == 1) {
92 update(geometry, m_grid->ctx()->time()->current(), 0); // dt is irrelevant
93 }
94 }
95
96 void Given::update_impl(const Geometry &geometry, double t, double dt) {
97 (void) geometry;
98
99 m_mass_flux->update(t, dt);
100 m_temperature->update(t, dt);
101
102 m_mass_flux->average(t, dt);
103 m_temperature->average(t, dt);
104
105 dummy_accumulation(*m_mass_flux, *m_accumulation);
106 dummy_melt(*m_mass_flux, *m_melt);
107 dummy_runoff(*m_mass_flux, *m_runoff);
108
109 }
110
111 const IceModelVec2S &Given::mass_flux_impl() const {
112 return *m_mass_flux;
113 }
114
115 const IceModelVec2S &Given::temperature_impl() const {
116 return *m_temperature;
117 }
118
119 const IceModelVec2S &Given::accumulation_impl() const {
120 return *m_accumulation;
121 }
122
123 const IceModelVec2S &Given::melt_impl() const {
124 return *m_melt;
125 }
126
127 const IceModelVec2S &Given::runoff_impl() const {
128 return *m_runoff;
129 }
130
131 void Given::define_model_state_impl(const File &output) const {
132 m_mass_flux->define(output);
133 m_temperature->define(output);
134 }
135
136 void Given::write_model_state_impl(const File &output) const {
137 m_mass_flux->write(output);
138 m_temperature->write(output);
139 }
140
141 } // end of namespace surface
142 } // end of namespace pism