URI:
       ticeModelVec3Custom.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
       ---
       ticeModelVec3Custom.cc (2356B)
       ---
            1 /* Copyright (C) 2013, 2014, 2015, 2016, 2017, 2019, 2020 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 <cassert>
           21 
           22 #include "iceModelVec3Custom.hh"
           23 #include "ConfigInterface.hh"
           24 #include "IceGrid.hh"
           25 #include "error_handling.hh"
           26 
           27 namespace pism {
           28 
           29 /**
           30  * Allocate storage and set metadata.
           31  *
           32  * @param grid grid to use
           33  * @param name name of the NetCDF variable
           34  * @param z_name name of the NetCDF dimension and variable corresponding to the third dimension
           35  * @param z_levels "vertical" levels (values of z)
           36  * @param z_attrs attributes of the "z" coordinate variable
           37  *
           38  * @return 0 on success
           39  */
           40 IceModelVec3Custom::IceModelVec3Custom(IceGrid::ConstPtr grid,
           41                                        const std::string &name,
           42                                        const std::string &z_name,
           43                                        const std::vector<double> &z_levels,
           44                                        const std::map<std::string, std::string> &z_attrs) {
           45   m_grid = grid;
           46   m_name = name;
           47   m_has_ghosts = false;
           48   m_zlevels = z_levels;
           49   m_da_stencil_width = 1;
           50   m_dof = 1;
           51 
           52   m_da = m_grid->get_dm(this->m_zlevels.size(), this->m_da_stencil_width);
           53 
           54   PetscErrorCode ierr = DMCreateGlobalVector(*m_da, m_v.rawptr());
           55   PISM_CHK(ierr, "DMCreateGlobalVector");
           56 
           57   m_metadata.push_back(SpatialVariableMetadata(m_grid->ctx()->unit_system(),
           58                                                m_name, m_zlevels));
           59   m_metadata[0].get_z().set_name(z_name);
           60 
           61   for (auto z_attr : z_attrs) {
           62     m_metadata[0].get_z().set_string(z_attr.first, z_attr.second);
           63   }
           64 }
           65 
           66 IceModelVec3Custom::~IceModelVec3Custom() {
           67   // empty
           68 }
           69 
           70 } // end of namespace pism