URI:
       tConfig.hh - 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
       ---
       tConfig.hh (3040B)
       ---
            1 /* Copyright (C) 2014, 2015, 2016, 2017, 2018 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 #ifndef _PISMCONFIG_H_
           21 #define _PISMCONFIG_H_
           22 
           23 #include <string>
           24 #include <set>
           25 
           26 #include "ConfigInterface.hh"
           27 #include "VariableMetadata.hh"
           28 
           29 namespace pism {
           30 
           31 class Logger;
           32 
           33 //! A class for reading, writing and accessing PISM configuration flags and parameters.
           34 class NetCDFConfig : public Config {
           35 public:
           36   NetCDFConfig(MPI_Comm com, const std::string &name, units::System::Ptr unit_system);
           37   ~NetCDFConfig();
           38 
           39 protected:
           40   void read_impl(const File &nc);
           41   void write_impl(const File &nc) const;
           42 
           43   bool is_set_impl(const std::string &name) const;
           44 
           45   // doubles
           46   Doubles all_doubles_impl() const;
           47   double get_number_impl(const std::string &name) const;
           48   std::vector<double> get_numbers_impl(const std::string &name) const;
           49 
           50   void set_number_impl(const std::string &name, double value);
           51   void set_numbers_impl(const std::string &name,
           52                         const std::vector<double> &values);
           53   // strings
           54   Strings all_strings_impl() const;
           55   std::string get_string_impl(const std::string &name) const;
           56   void set_string_impl(const std::string &name, const std::string &value);
           57 
           58   // flags
           59   Flags all_flags_impl() const;
           60   bool get_flag_impl(const std::string& name) const;
           61   void set_flag_impl(const std::string& name, bool value);
           62 protected:
           63   MPI_Comm m_com;
           64   VariableMetadata m_data;
           65 private:
           66   //! @brief the name of the file this config database was initialized from
           67   std::string m_config_filename;
           68 };
           69 
           70 //! @brief Default PISM configuration database: uses NetCDF files; can be initialized from a file
           71 //! specified using a command-line option.
           72 class DefaultConfig : public NetCDFConfig {
           73 public:
           74   DefaultConfig(MPI_Comm com,
           75                 const std::string &variable_name,
           76                 const std::string &option,
           77                 units::System::Ptr unit_system);
           78   ~DefaultConfig();
           79 
           80   typedef std::shared_ptr<DefaultConfig> Ptr;
           81   typedef std::shared_ptr<const DefaultConfig> ConstPtr;
           82 
           83   //! Initialize (use default path if no option was set).
           84   void init_with_default(const Logger &log);
           85   //! Initialize (leave empty if no option was set).
           86   void init(const Logger &log);
           87 private:
           88   void init(const Logger &log, bool use_default_path);
           89   std::string m_option;
           90 };
           91 
           92 } // end of namespace pism
           93 
           94 #endif /* _PISMCONFIG_H_ */