tInitialization.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
---
tInitialization.cc (2922B)
---
1 /* Copyright (C) 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
20 #include "Initialization.hh"
21
22 #include "pism/coupler/util/init_step.hh"
23
24 namespace pism {
25 namespace ocean {
26 namespace sea_level {
27
28 InitializationHelper::InitializationHelper(IceGrid::ConstPtr grid,
29 std::shared_ptr<SeaLevel> in)
30 : SeaLevel(grid, in) {
31
32 m_sea_level.metadata().set_name("effective_sea_level_elevation");
33 m_sea_level.metadata().set_string("pism_intent", "model_state");
34 }
35
36 void InitializationHelper::update_impl(const Geometry &geometry, double t, double dt) {
37 SeaLevel::update_impl(geometry, t, dt);
38
39 m_sea_level.copy_from(m_input_model->elevation());
40 }
41
42 void InitializationHelper::init_impl(const Geometry &geometry) {
43 m_input_model->init(geometry);
44
45 InputOptions opts = process_input_options(m_grid->com, m_config);
46
47 if (opts.type == INIT_RESTART) {
48 m_log->message(2, "* Reading effective sea level forcing from '%s' for re-starting...\n",
49 opts.filename.c_str());
50
51 File file(m_grid->com, opts.filename, PISM_GUESS, PISM_READONLY);
52 const unsigned int time_length = file.nrecords();
53 const unsigned int last_record = time_length > 0 ? time_length - 1 : 0;
54
55 m_sea_level.read(file, last_record);
56
57 file.close();
58 } else {
59 m_log->message(2, "* Performing a 'fake' sea level forcing time-step for bootstrapping...\n");
60
61 init_step(this, geometry, *m_grid->ctx()->time());
62 }
63
64 // Support regridding. This is needed to ensure that initialization using "-i" is
65 // equivalent to "-i ... -bootstrap -regrid_file ..."
66 {
67 regrid("ocean model initialization helper", m_sea_level,
68 REGRID_WITHOUT_REGRID_VARS);
69 }
70 }
71
72 void InitializationHelper::define_model_state_impl(const File &output) const {
73 m_sea_level.define(output);
74
75 m_input_model->define_model_state(output);
76 }
77
78 void InitializationHelper::write_model_state_impl(const File &output) const {
79 m_sea_level.write(output);
80
81 m_input_model->write_model_state(output);
82 }
83
84 const IceModelVec2S& InitializationHelper::sea_level_elevation_impl() const {
85 return m_sea_level;
86 }
87
88 } // end of namespace sea_level
89 } // end of namespace ocean
90 } // end of namespace pism