URI: 
       tDelta_SL_2D.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
       ---
       tDelta_SL_2D.cc (2795B)
       ---
            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 "Delta_SL_2D.hh"
           20 
           21 #include "pism/util/IceGrid.hh"
           22 #include "pism/coupler/util/options.hh"
           23 
           24 namespace pism {
           25 namespace ocean {
           26 namespace sea_level {
           27 
           28 Delta_SL_2D::Delta_SL_2D(IceGrid::ConstPtr grid, std::shared_ptr<SeaLevel> in)
           29   : SeaLevel(grid, in) {
           30 
           31   ForcingOptions opt(*m_grid->ctx(), "ocean.delta_sl_2d");
           32 
           33   {
           34     unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
           35     unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
           36     bool periodic = opt.period > 0;
           37 
           38     File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);
           39 
           40     m_forcing = IceModelVec2T::ForcingField(m_grid,
           41                                             file,
           42                                             "delta_SL",
           43                                             "", // no standard name
           44                                             buffer_size,
           45                                             evaluations_per_year,
           46                                             periodic,
           47                                             LINEAR);
           48     m_forcing->set_attrs("climate_forcing",
           49                          "two-dimensional sea level offsets",
           50                          "meters", "meters", "", 0);
           51   }
           52 }
           53 
           54 Delta_SL_2D::~Delta_SL_2D() {
           55   // empty
           56 }
           57 
           58 void Delta_SL_2D::init_impl(const Geometry &geometry) {
           59 
           60   m_input_model->init(geometry);
           61 
           62   ForcingOptions opt(*m_grid->ctx(), "ocean.delta_sl_2d");
           63 
           64   m_log->message(2, "* Initializing 2D sea level forcing...\n");
           65   m_log->message(2, "    reading anomalies from %s ...\n", opt.filename.c_str());
           66 
           67   m_forcing->init(opt.filename, opt.period, opt.reference_time);
           68 }
           69 
           70 void Delta_SL_2D::update_impl(const Geometry &geometry, double t, double dt) {
           71   m_input_model->update(geometry, t, dt);
           72 
           73   m_forcing->update(t, dt);
           74   m_forcing->average(t, dt);
           75 
           76   m_input_model->elevation().add(1.0, *m_forcing, m_sea_level);
           77 }
           78 
           79 } // end of namespace sea_level
           80 } // end of namespace ocean
           81 } // end of namespace pism