20#include "pism/icemodel/IceModel.hh"
22#include "pism/util/io/io_helpers.hh"
23#include "pism/util/pism_utilities.hh"
32 const std::set<std::string> &input) {
33 std::set<std::string> result = input;
35 if (result.find(
"ismip6") != result.end()) {
36 result.erase(
"ismip6");
48 auto filename =
m_config->get_string(
"output.scalar.file");
50 auto times =
m_config->get_string(
"output.scalar.times");
51 bool times_set = not times.empty();
53 if (times_set xor not filename.empty()) {
55 "you need to specity both -scalar_file and -scalar_times"
56 " to save scalar diagnostic time-series.");
59 if (filename.empty()) {
69 e.
add_context(
"parsing the -scalar_times argument %s", times.c_str());
73 m_log->message(2,
" saving scalar time-series to '%s'\n", filename.c_str());
74 m_log->message(2,
" times requested: %s\n", times.c_str());
88 std::vector<std::string> missing;
102 if (not missing.empty()) {
104 "requested scalar diagnostics %s are not available",
105 join(missing,
",").c_str());
113 bool append =
m_config->get_flag(
"output.scalar.append");
120 double epsilon =
m_config->get_number(
"time_stepping.resolution"),
124 if (t + epsilon < m_scalar_times->front()) {
132 variables.insert(d.second->metadata());
135 bool with_time_bounds =
true;
151 if ((not
m_config->get_flag(
"time_stepping.hit_scalar_times")) or
156 double eps =
m_config->get_number(
"time_stepping.resolution");
159 "reporting (-scalar_times)");
std::string get_string(const std::string &name, UseFlag flag=REMEMBER_THIS_USE) const
A class for storing and accessing PISM configuration flags and parameters.
MaxTimestep scalar_diagnostics_max_timestep(double t)
Computes the maximum time-step we can take and still hit all -scalar_times.
void define_variables(const OutputFile &file, const std::set< VariableMetadata > &variables) const
std::shared_ptr< Config > m_config
Configuration flags and parameters.
void define_time(const OutputFile &file, bool with_bounds=false) const
std::shared_ptr< Logger > m_log
Logger.
std::set< std::string > m_scalar_vars
std::shared_ptr< std::vector< double > > m_scalar_times
requested times for scalar time-series
VariableMetadata m_output_global_attributes
stores global attributes saved in a PISM output file
std::shared_ptr< Time > m_time
Time manager.
void init_scalar_diagnostics()
Initializes the code writing scalar time-series.
std::map< std::string, TSDiagnostic::Ptr > m_available_scalar_diagnostics
Available scalar diagnostics.
std::shared_ptr< OutputWriter > m_output_writer
void scalar_diagnostics_flush_buffers()
Flush scalar time-series.
std::shared_ptr< OutputFile > m_scalar_file
file to write scalar time-series to
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void add_context(const std::string &message)
Add a message providing some context. This way we can (sort of) get a stack trace even though C++ exc...
static RuntimeError formatted(const ErrorLocation &location, const char format[],...) __attribute__((format(printf
build a RuntimeError with a formatted message
#define PISM_ERROR_LOCATION
void write_config(const Config &config, const std::string &variable_name, const OutputFile &file)
MaxTimestep reporting_max_timestep(const std::vector< double > ×, double t, double eps, const std::string &description)
static std::set< std::string > process_ts_shortcuts(const Config &config, const std::set< std::string > &input)
std::string set_join(const std::set< std::string > &input, const std::string &separator)
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
std::set< std::string > set_split(const std::string &input, char separator)
Transform a separator-separated list (a string) into a set of strings.
std::string join(const std::vector< std::string > &strings, const std::string &separator)
Concatenate strings, inserting separator between elements.
VariableMetadata config_metadata(const Config &config)