14#include <pybind11/pybind11.h>
15#include <spdlog/spdlog.h>
16#include <tclap/CmdLine.h>
50 _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
53 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
58#include <spdlog/sinks/null_sink.h>
59#include <spdlog/sinks/stdout_color_sinks.h>
65 auto const end_time = std::chrono::system_clock::now();
68 ERR(
"Simulation aborted on {:s}. Received signal: {:d}.", time_str, signum);
76 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
78 MPI_Comm_size(MPI_COMM_WORLD, &world_size);
84 spdlog::set_pattern(fmt::format(
"[{}] %^%l:%$ %v", mpi_rank));
100 spdlog::stdout_color_st(
"ogs");
105 auto const start_time = std::chrono::system_clock::now();
107 INFO(
"OGS started on {:s} with MPI. MPI processes: {:d}.", time_str,
114 auto const start_time = std::chrono::system_clock::now();
116 INFO(
"OGS started on {:s} in serial mode.", time_str);
122int main(
int argc,
char* argv[])
145 "This is OpenGeoSys-6 version {:s}. Log version: {:d}, Log level: "
150 std::optional<ApplicationsLib::TestDefinition> test_definition{
152 auto ogs_status = EXIT_SUCCESS;
161 bool solver_succeeded =
false;
171 solver_succeeded =
simulation.executeSimulation();
173 test_definition =
simulation.getTestDefinition();
175 catch (pybind11::error_already_set
const& e)
177 OGS_FATAL(
"Python exception thrown: {}", e.what());
179 if (solver_succeeded)
181 INFO(
"[time] Simulation completed. It took {:g} s.",
186 INFO(
"[time] Simulation failed. It took {:g} s.",
190 ogs_status = solver_succeeded ? EXIT_SUCCESS : EXIT_FAILURE;
192 catch (std::exception& e)
195 ogs_status = EXIT_FAILURE;
198 if (ogs_status == EXIT_FAILURE)
200 auto const end_time = std::chrono::system_clock::now();
202 ERR(
"OGS terminated with error on {:s}.", time_str);
206 if (!test_definition)
208 auto const end_time = std::chrono::system_clock::now();
210 DBUG(
"No test definition was found. No tests will be executed.");
211 INFO(
"OGS completed on {:s}.", time_str);
216 INFO(
"##########################################");
217 INFO(
"# Running tests #");
218 INFO(
"##########################################");
220 auto status = test_definition->runTests();
221 auto const end_time = std::chrono::system_clock::now();
225 INFO(
"OGS completed on {:s}.", time_str);
229 ERR(
"OGS terminated on {:s}. One of the tests failed.", time_str);
CommandLineArguments parseCommandLineArguments(int argc, char *argv[], bool const exit_on_exception)
Declaration of CommandLineArgumentParser.
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the RunTime class.
Declaration of class Simulation.
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
void initOGSLogger(std::string const &log_level)
std::string formatDate(std::chrono::time_point< std::chrono::system_clock > const &time)
std::shared_ptr< spdlog::logger > console
bool createOutputDirectory(std::string const &dir)
GITINFOLIB_EXPORT const std::string ogs_version
int main(int argc, char *argv[])
void signalHandler(int signum)
void enableFloatingPointExceptions()
void initializeLogger(bool const all_ranks_log)
std::unique_ptr< Simulation > simulation
bool reference_path_is_set
std::string reference_path
std::vector< std::string > xml_patch_file_names