20 #ifndef _PISMCONFIGINTERFACE_H_
21 #define _PISMCONFIGINTERFACE_H_
31 #include "pism/util/Units.hh"
55 typedef std::shared_ptr<Config>
Ptr;
56 typedef std::shared_ptr<const Config>
ConstPtr;
82 void write(MPI_Comm com,
const std::string &
filename,
bool append =
true)
const;
88 bool is_set(
const std::string &name)
const;
91 typedef std::map<std::string, std::vector<double> >
Doubles;
98 std::vector<double>
get_numbers(
const std::string &name,
const std::string &
units,
102 void set_numbers(
const std::string &name,
const std::vector<double> &values,
106 typedef std::map<std::string, std::string>
Strings;
113 typedef std::map<std::string, bool>
Flags;
116 std::set<std::string>
keys()
const;
121 std::string
doc(
const std::string ¶meter)
const;
122 std::string
units(
const std::string ¶meter)
const;
123 std::string
type(
const std::string ¶meter)
const;
124 std::string
option(
const std::string ¶meter)
const;
125 std::string
choices(
const std::string ¶meter)
const;
139 const std::vector<double> &values) = 0;
158 double get_number(
const std::string &name)
const;
159 double get_number(
const std::string &name,
const std::string &units)
const;
161 std::string
get_string(
const std::string &name)
const;
163 bool get_flag(
const std::string& name)
const;
182 const std::string &option,
const std::string ¶meter);
186 const std::string &option,
const std::string ¶meter);
190 const std::string &option,
const std::string ¶meter);
194 const std::string &option,
const std::string ¶meter,
195 const std::string &choices);
void reset_prefix(const std::string &prefix)
bool get_flag(const std::string &name) const
std::string get_string(const std::string &name) const
double get_number(const std::string &name) const
Config::ConstPtr m_config
ConfigWithPrefix(Config::ConstPtr c, const std::string &prefix)
virtual bool is_set_impl(const std::string &name) const =0
std::map< std::string, std::string > Strings
const std::set< std::string > & parameters_used() const
std::shared_ptr< Config > Ptr
bool is_set(const std::string &name) const
std::string choices(const std::string ¶meter) const
virtual Strings all_strings_impl() const =0
std::set< std::string > keys() const
std::map< std::string, std::vector< double > > Doubles
void set_string(const std::string &name, const std::string &value, ConfigSettingFlag flag=CONFIG_FORCE)
double get_number(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
virtual void set_numbers_impl(const std::string &name, const std::vector< double > &values)=0
std::vector< double > get_numbers(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
virtual void read_impl(const File &nc)=0
std::shared_ptr< const Config > ConstPtr
virtual Flags all_flags_impl() const =0
const std::set< std::string > & parameters_set_by_user() const
virtual void set_flag_impl(const std::string &name, bool value)=0
void read(MPI_Comm com, const std::string &filename)
virtual void set_string_impl(const std::string &name, const std::string &value)=0
std::string units(const std::string ¶meter) const
virtual std::vector< double > get_numbers_impl(const std::string &name) const =0
void import_from(const Config &other)
Config(units::System::Ptr unit_system)
void set_flag(const std::string &name, bool value, ConfigSettingFlag flag=CONFIG_FORCE)
virtual std::string get_string_impl(const std::string &name) const =0
std::map< std::string, bool > Flags
std::string get_string(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
std::string type(const std::string ¶meter) const
virtual Doubles all_doubles_impl() const =0
virtual void set_number_impl(const std::string &name, double value)=0
void write(MPI_Comm com, const std::string &filename, bool append=true) const
bool get_flag(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
void set_number(const std::string &name, double value, ConfigSettingFlag flag=CONFIG_FORCE)
std::string option(const std::string ¶meter) const
std::string filename() const
Returns the name of the file used to initialize the database.
Strings all_strings() const
virtual void write_impl(const File &nc) const =0
void set_numbers(const std::string &name, const std::vector< double > &values, ConfigSettingFlag flag=CONFIG_FORCE)
Doubles all_doubles() const
std::string doc(const std::string ¶meter) const
UseFlag
Flag used by get_...() methods.
virtual double get_number_impl(const std::string &name) const =0
virtual bool get_flag_impl(const std::string &name) const =0
A class for storing and accessing PISM configuration flags and parameters.
High-level PISM I/O class.
std::shared_ptr< System > Ptr
Config::Ptr config_from_options(MPI_Comm com, const Logger &log, units::System::Ptr unit_system)
Create a configuration database using command-line options.
void set_number_from_option(units::System::Ptr unit_system, Config &config, const std::string &name, const std::string ¶meter)
Sets a configuration parameter from a command-line option.
void set_string_from_option(Config &config, const std::string &name, const std::string ¶meter)
Set one free-form string parameter using command-line options.
void set_config_from_options(units::System::Ptr unit_system, Config &config)
Set configuration parameters using command-line options.
void set_flag_from_option(Config &config, const std::string &option, const std::string ¶meter_name)
Get a flag from a command-line option.
ConfigSettingFlag
Flag used by set_...() methods.
void print_unused_parameters(const Logger &log, int verbosity_threshhold, const Config &config)
Report unused configuration parameters to stdout.
void set_parameter_from_options(units::System::Ptr unit_system, Config &config, const std::string &name)
Set one parameter using command-line options.
void set_keyword_from_option(Config &config, const std::string &name, const std::string ¶meter, const std::string &choices)
Set a keyword parameter from a command-line option.
void print_config(const Logger &log, int verbosity_threshhold, const Config &config)
Report configuration parameters to stdout.