netxsimdg
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
7#include <iostream>
8
13#include "include/Model.hpp"
15
16int main(int argc, char* argv[])
17{
18 // Pass the command line to Configurator to handle
20 // Extract any config files defined on the command line
21 Nextsim::CommandLineParser cmdLine(argc, argv);
22 // Pass the config file names to Configurator
23 Nextsim::Configurator::addFiles(cmdLine.getConfigFileNames());
24 try {
25 // Get the configuration stored in the restart file
28 Nextsim::Configurator::getAdditionalConfiguration(Nextsim::Model::restartOptionName);
29 } catch (const std::exception& e) {
30 // Do nothing. If there is no additional configuration to be parse, ignore it.
31 }
32 // Parse the configuration to load those that are explicitly configured
34
35 if (!cmdLine.configHelp().empty()) {
36 Nextsim::Model::HelpMap map;
37 Nextsim::Model::getHelpRecursive(map, true);
38 Nextsim::ConfigurationHelpPrinter::setOutput(
39 Nextsim::ConfigurationHelpPrinter::Output::ANSI);
40 Nextsim::ConfigurationHelpPrinter::print(std::cout, map, cmdLine.configHelp());
41 } else {
42 // Construct the Model
43 Nextsim::Model model;
44 // Apply the model configuration
45 model.configure();
46 // Run the Model
47 model.run();
48 }
49
50 return 0;
51}
static void addFiles(const C &container)
Adds several config files to the configuration sources.
static void setAdditionalConfiguration(AdditionalConfiguration *pAC)
Sets the source of any additional configuration data, such as a netCDF restart file.
static void getAdditionalConfiguration(const std::string &source)
Gets the additional configuration according to the supplied implementation.
static void setCommandLine(int argc, char *argv[])
Sets the command line data to be parsed.
static void parseConfigurator()
Parse the configuration for all of the modules defined in ModuleLoader.
A class that encapsulates the whole of the model.
Definition Model.hpp:24
void configure() override
The configuration function.
Definition Model.cpp:59
void run()
Run the model.
Definition Model.cpp:132