23#include "pism/icemodel/IceModel.hh"
25#include "pism/util/Grid.hh"
26#include "pism/util/Time.hh"
27#include "pism/util/pism_utilities.hh"
28#include "pism/util/pism_signal.h"
29#include "pism/util/io/SynchronousOutputWriter.hh"
30#include "pism/util/io/io_helpers.hh"
52 "\ncaught signal SIGTERM: EXITING EARLY and saving with original filename.\n");
63 auto file_name =
pism::printf(
"pism-%s.nc", date_without_spaces.c_str());
65 "\ncaught signal SIGUSR1: Writing intermediate file `%s' and flushing time series.\n\n",
69 std::shared_ptr<OutputWriter> writer =
71 writer->initialize({},
true);
95 "\ncaught signal SIGUSR2: Flushing time series.\n\n");
virtual int process_signals()
Catch signals -USR1, -USR2 and -TERM.
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
void write_run_stats(const OutputFile &file) const
std::shared_ptr< Context > m_ctx
Execution context.
std::shared_ptr< Logger > m_log
Logger.
std::shared_ptr< Grid > grid() const
Return the grid used by this model.
std::set< VariableMetadata > m_output_file_contents
Set of variables that will be written to the output file.
std::shared_ptr< Time > m_time
Time manager.
void write_state_diagnostics(const OutputFile &file, const std::set< std::string > &variable_names) const
void write_diagnostics(const OutputFile &file, const std::set< std::string > &variable_names) const
Writes variables listed in variable_names to file.
void scalar_diagnostics_flush_buffers()
Flush scalar time-series.
std::shared_ptr< Context > ctx() const
Return the context this model is running in.
std::string m_output_history
virtual void write_state(const OutputFile &file) const
virtual void append_history(const std::string &string)
Get time and user/host name and add it to the given string.
std::set< std::string > m_output_vars
const std::shared_ptr< Grid > m_grid
Computational grid.
void append_time(double time_seconds) const
void write_config(const Config &config, const std::string &variable_name, const OutputFile &file)
std::string printf(const char *format,...)
std::string username_prefix(MPI_Comm com)
Creates a string with the user name, hostname and the time-stamp (for history strings).
std::string replace_character(const std::string &input, char from, char to)
volatile sig_atomic_t pism_signal