21#include "pism/util/NetCDFConfig.hh"
23#include "pism/util/io/IO_Flags.hh"
24#include "pism/util/error_handling.hh"
25#include "pism/util/io/File.hh"
26#include "pism/util/io/OutputWriter.hh"
27#include "pism/util/io/io_helpers.hh"
33 m_data(name, system) {
47 if (doubles.find(name) != doubles.end()) {
52 "numeric parameter '%s' was not set. (Parameters read from '%s'.)",
60 if (doubles.find(name) != doubles.end()) {
65 "numeric parameter '%s' was not set. (Parameters read from '%s'.)",
75 result[d.first] = d.second;
86 const std::vector<double> &values) {
94 if (strings.find(name) != strings.end()) {
99 "string parameter '%s' was not set. (Read from '%s'.)\n", name.c_str(),
102 return std::string();
109 for (
const auto& s : strings) {
110 std::string name = s.first;
111 std::string value = s.second;
113 auto k = strings.find(name +
"_type");
114 if (
k != strings.end() and
k->second ==
"flag") {
119 result[name] = value;
131 return value ==
"false" or value ==
"off" or value ==
"no";
135 return value ==
"true" or value ==
"on" or value ==
"yes";
140 auto j = strings.find(name);
141 if (j != strings.end()) {
143 const std::string &value = j->second;
154 "Please make sure that it is set to one of 'true', 'yes', 'on', 'false', 'no', 'off'.",
155 name.c_str(), value.c_str());
168 std::string name = b.first;
169 std::string value = b.second;
174 result[name] =
false;
182 m_data[name] = value ?
"true" :
"false";
std::map< std::string, std::string > Strings
std::map< std::string, std::vector< double > > Doubles
std::map< std::string, bool > Flags
A class for storing and accessing PISM configuration flags and parameters.
High-level PISM I/O class.
bool get_flag_impl(const std::string &name) const
void set_numbers_impl(const std::string &name, const std::vector< double > &values)
bool is_set_impl(const std::string &name) const
Doubles all_doubles_impl() const
void set_number_impl(const std::string &name, double value)
void set_flag_impl(const std::string &name, bool value)
Set a value of a flag flag.
void read_impl(const File &file)
Read flag flags and double parameters from a NetCDF file.
std::string get_string_impl(const std::string &name) const
double get_number_impl(const std::string &name) const
NetCDFConfig(const std::string &name, units::System::Ptr unit_system)
void set_string_impl(const std::string &name, const std::string &value)
Strings all_strings_impl() const
Flags all_flags_impl() const
std::vector< double > get_numbers_impl(const std::string &name) const
std::string m_config_filename
the name of the file this config database was initialized from
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
std::shared_ptr< System > Ptr
#define PISM_ERROR_LOCATION
VariableMetadata read_attributes(const File &file, const std::string &variable_name, std::shared_ptr< units::System > unit_system)
static bool string_is_false(const std::string &value)
static bool string_is_true(const std::string &value)