URI:
       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 (4243B)
       ---
            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/IceGrid.hh"
           22 #include "pism/util/Time.hh"
           23 
           24 #include "pism/coupler/util/options.hh"
           25 
           26 namespace pism {
           27 namespace ocean {
           28 
           29 Given::Given(IceGrid::ConstPtr g)
           30   : OceanModel(g, std::shared_ptr<OceanModel>()) {
           31 
           32   m_shelf_base_temperature = allocate_shelf_base_temperature(g);
           33   m_shelf_base_mass_flux   = allocate_shelf_base_mass_flux(g);
           34 
           35   ForcingOptions opt(*m_grid->ctx(), "ocean.given");
           36 
           37   {
           38     unsigned int buffer_size = m_config->get_number("input.forcing.buffer_size");
           39     unsigned int evaluations_per_year = m_config->get_number("input.forcing.evaluations_per_year");
           40     bool periodic = opt.period > 0;
           41 
           42     File file(m_grid->com, opt.filename, PISM_NETCDF3, PISM_READONLY);
           43 
           44     m_shelfbtemp = IceModelVec2T::ForcingField(m_grid,
           45                                                file,
           46                                                "shelfbtemp",
           47                                                "", // no standard name
           48                                                buffer_size,
           49                                                evaluations_per_year,
           50                                                periodic,
           51                                                LINEAR);
           52 
           53     m_shelfbmassflux = IceModelVec2T::ForcingField(m_grid,
           54                                                    file,
           55                                                    "shelfbmassflux",
           56                                                    "", // no standard name
           57                                                    buffer_size,
           58                                                    evaluations_per_year,
           59                                                    periodic);
           60   }
           61 
           62   m_shelfbtemp->set_attrs("climate_forcing",
           63                           "absolute temperature at ice shelf base",
           64                           "Kelvin", "Kelvin", "", 0);
           65   m_shelfbmassflux->set_attrs("climate_forcing",
           66                               "ice mass flux from ice shelf base (positive flux is loss from ice shelf)",
           67                               "kg m-2 s-1", "kg m-2 year-1", "", 0);
           68 }
           69 
           70 Given::~Given() {
           71   // empty
           72 }
           73 
           74 void Given::init_impl(const Geometry &geometry) {
           75 
           76   m_log->message(2,
           77              "* Initializing the ocean model reading base of the shelf temperature\n"
           78              "  and sub-shelf mass flux from a file...\n");
           79 
           80   ForcingOptions opt(*m_grid->ctx(), "ocean.given");
           81 
           82   m_shelfbtemp->init(opt.filename, opt.period, opt.reference_time);
           83   m_shelfbmassflux->init(opt.filename, opt.period, opt.reference_time);
           84 
           85   // read time-independent data right away:
           86   if (m_shelfbtemp->n_records() == 1 && m_shelfbmassflux->n_records() == 1) {
           87     update(geometry, m_grid->ctx()->time()->current(), 0); // dt is irrelevant
           88   }
           89 }
           90 
           91 void Given::update_impl(const Geometry &geometry, double t, double dt) {
           92   (void) geometry;
           93 
           94   m_shelfbmassflux->update(t, dt);
           95   m_shelfbtemp->update(t, dt);
           96 
           97   m_shelfbmassflux->average(t, dt);
           98   m_shelfbtemp->average(t, dt);
           99 
          100   m_shelf_base_temperature->copy_from(*m_shelfbtemp);
          101   m_shelf_base_mass_flux->copy_from(*m_shelfbmassflux);
          102 }
          103 
          104 MaxTimestep Given::max_timestep_impl(double t) const {
          105   (void) t;
          106 
          107   return MaxTimestep("ocean th");
          108 }
          109 
          110 const IceModelVec2S& Given::shelf_base_temperature_impl() const {
          111   return *m_shelf_base_temperature;
          112 }
          113 
          114 const IceModelVec2S& Given::shelf_base_mass_flux_impl() const {
          115   return *m_shelf_base_mass_flux;
          116 }
          117 
          118 } // end of namespace ocean
          119 } // end of namespace pism