25const std::string Model::restartOptionName =
"model.init_file";
28const std::map<int, std::string> Configured<Model>::keyMap = {
29 { Model::RESTARTFILE_KEY, Model::restartOptionName },
30 { Model::STARTTIME_KEY,
"model.start" },
31 { Model::STOPTIME_KEY,
"model.stop" },
32 { Model::RUNLENGTH_KEY,
"model.run_length" },
33 { Model::TIMESTEP_KEY,
"model.time_step" },
34 { Model::MISSINGVALUE_KEY,
"model.missing_value" },
41 finalFileName =
"restart.nc";
54 }
catch (std::exception& e) {
85 pData.
setData(initialState.data);
88ConfigMap Model::getConfig()
const
91 {
keyMap.at(STARTTIME_KEY), startTimeStr },
92 {
keyMap.at(STOPTIME_KEY), stopTimeStr },
93 {
keyMap.at(RUNLENGTH_KEY), durationStr },
94 {
keyMap.at(TIMESTEP_KEY), stepStr },
95 {
keyMap.at(MISSINGVALUE_KEY), MissingData::value },
101Model::HelpMap& Model::getHelpText(HelpMap& map,
bool getAll)
104 {
keyMap.at(STARTTIME_KEY), ConfigType::STRING, {},
"",
"",
105 "Model start time, formatted as an ISO8601 date. "
106 "Non-calendretical runs can start from year 0 or 1. " },
107 {
keyMap.at(STOPTIME_KEY), ConfigType::STRING, {},
"",
"",
108 "Model stop time, formatted as an ISO8601 data. "
109 " Will be overridden if a model run length is set. " },
110 {
keyMap.at(RUNLENGTH_KEY), ConfigType::STRING, {},
"",
"",
111 "Model run length, formatted as an ISO8601 duration (P prefix). "
112 "Overrides the stop time if set. " },
113 {
keyMap.at(TIMESTEP_KEY), ConfigType::STRING, {},
"",
"",
114 "Model physics timestep, formatted a ISO8601 duration (P prefix). " },
115 {
keyMap.at(RESTARTFILE_KEY), ConfigType::STRING, {},
"",
"",
116 "The file path to the restart file to use for the run." },
117 {
keyMap.at(MISSINGVALUE_KEY), ConfigType::NUMERIC, {
"-∞",
"∞" },
"-2³⁰⁰",
"",
118 "Missing data indicator used for input and output." },
124Model::HelpMap& Model::getHelpRecursive(HelpMap& map,
bool getAll)
126 getHelpText(map, getAll);
127 PrognosticData::getHelpRecursive(map, getAll);
128 Module::getHelpRecursive<IDiagnosticOutput>(map, getAll);
134void Model::writeRestartFile()
137 Logged::notice(std::string(
" Writing state-based restart file: ") + finalFileName +
'\n');
139 ConfigMap modelConfig = getConfig();
void setMetadata(ModelMetadata &metadata) override
Sets the metadata object that will be used within the timesteps.
void setData(PrognosticData &pDat) override
Sets the data object that will be used within the timesteps.
void init() override
Initializes the model, based on some environment stored in the implementing class.
void setInitFile(const std::string &filePath)
Sets the path to the initial file for later reference.
void run()
Run the Iterant over the specified time period.
TimePoint parseAndSet(const std::string &startTimeStr, const std::string &stopTimeStr, const std::string &durationStr, const std::string &stepStr)
Parses the four strings and sets the time parameters from them.
void setIterant(Iterant *iterant)
Sets the iterant to be iterated using a pointer.
static void configure()
Static function that configures the logger.
static void notice(const std::string &message)
Logs a message at level::NOTICE, intended for messages that would appear during normal execution.
void configure() override
The configuration function.
ModelMetadata & metadata()
Gets the model metadata instance.
ModelState getStateRecursive(const OutputSpec &os) const override
Returns the state of the ModelComponent and any ModelComponents it depends on.
void setData(const ModelState::DataMap &ms) override
Set the initial data of the component from the passed ModelState.
void configure() override
The configuration function.
ModelState getState() const override
Returns a ModelState from this component.
static void fileFromState(const ModelState &state, const ModelMetadata &meta, const std::string &filePath, bool isRestart=false)
Takes a ModelState and a template file name to write the state out to a target file path.
static ModelState stateFromFile(const std::string &filePath)
Returns the ModelState of the named restart file.