21 #include "pism/util/Component.hh"
22 #include "pism/util/Profiling.hh"
23 #include "pism/util/io/File.hh"
24 #include "pism/util/Grid.hh"
25 #include "pism/util/pism_utilities.hh"
26 #include "pism/util/VariableMetadata.hh"
27 #include "pism/util/ConfigInterface.hh"
28 #include "pism/util/MaxTimestep.hh"
29 #include "pism/util/Time.hh"
30 #include "pism/util/Context.hh"
45 unsigned int record = 0;
47 std::string input_filename = config->get_string(
"input.file");
49 bool bootstrap = config->get_flag(
"input.bootstrap") and (not input_filename.empty());
50 bool restart = (not config->get_flag(
"input.bootstrap")) and (not input_filename.empty());
55 }
else if (bootstrap) {
64 if (not input_filename.empty()) {
68 unsigned int last_record = input_file.
nrecords();
69 if (last_record > 0) {
83 m_config(
g->ctx()->config()),
84 m_sys(
g->ctx()->unit_system()),
85 m_log(
g->ctx()->log()) {
110 return *
m_grid->ctx()->time();
114 return m_grid->ctx()->profiling();
162 auto regrid_file =
m_config->get_string(
"input.regrid.file");
165 if (regrid_file.empty()) {
171 if (((not regrid_vars.empty()) and
member(m[
"short_name"], regrid_vars)) or
175 " %s: regridding '%s' from file '%s' ...\n",
177 m.
get_string(
"short_name").c_str(), regrid_file.c_str());
const Time & time() const
std::shared_ptr< const Grid > grid() const
const Config::ConstPtr m_config
configuration database used by this component
const Logger::ConstPtr m_log
logger (for easy access)
virtual TSDiagnosticList ts_diagnostics_impl() const
RegriddingFlag
This flag determines whether a variable is read from the -regrid_file file even if it is not listed a...
@ REGRID_WITHOUT_REGRID_VARS
TSDiagnosticList ts_diagnostics() const
virtual void write_model_state_impl(const File &output) const
The default (empty implementation).
const std::shared_ptr< const Grid > m_grid
grid used by this component
void regrid(const std::string &module_name, array::Array &variable, RegriddingFlag flag=NO_REGRID_WITHOUT_REGRID_VARS)
virtual void define_model_state_impl(const File &output) const
The default (empty implementation).
Component(std::shared_ptr< const Grid > grid)
virtual DiagnosticList diagnostics_impl() const
void define_model_state(const File &output) const
Define model state variables in an output file.
void write_model_state(const File &output) const
Write model state variables to an output file.
DiagnosticList diagnostics() const
const Profiling & profiling() const
virtual MaxTimestep max_timestep_impl(double t) const
MaxTimestep max_timestep(double t) const
Reports the maximum time-step the model can take at time t.
std::shared_ptr< const Config > ConstPtr
unsigned int nrecords() const
Get the number of records. Uses the length of an unlimited dimension.
High-level PISM I/O class.
Combines the max. time step with the flag indicating if a restriction is active. Makes is possible to...
void regrid(const std::string &filename, io::Default default_value)
SpatialVariableMetadata & metadata(unsigned int N=0)
Returns a reference to the SpatialVariableMetadata object containing metadata for the compoment N.
Abstract class for reading, writing, allocating, and accessing a DA-based PETSc Vec (2D and 3D fields...
@ PISM_READONLY
open an existing file for reading only
InputOptions process_input_options(MPI_Comm com, Config::ConstPtr config)
std::map< std::string, TSDiagnostic::Ptr > TSDiagnosticList
std::map< std::string, Diagnostic::Ptr > DiagnosticList
std::set< std::string > set_split(const std::string &input, char separator)
Transform a separator-separated list (a string) into a set of strings.
bool member(const std::string &string, const std::set< std::string > &set)