4#include <pybind11/pybind11.h>
5#include <spdlog/spdlog.h>
6#include <tclap/CmdLine.h>
41 _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
44 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
49#include <spdlog/sinks/null_sink.h>
50#include <spdlog/sinks/stdout_color_sinks.h>
56 auto const end_time = std::chrono::system_clock::now();
59 ERR(
"Simulation aborted on {:s}. Received signal: {:d}.", time_str, signum);
75 spdlog::set_pattern(fmt::format(
"[{}] %^%l:%$ %v", mpi_rank));
91 spdlog::stdout_color_st(
"ogs");
96 auto const start_time = std::chrono::system_clock::now();
98 INFO(
"OGS started on {:s} with MPI. MPI processes: {:d}.", time_str,
105 auto const start_time = std::chrono::system_clock::now();
107 INFO(
"OGS started on {:s} in serial mode.", time_str);
113int main(
int argc,
char* argv[])
136 "This is OpenGeoSys-6 version {:s}. Log version: {:d}, Log level: "
141 std::optional<ApplicationsLib::TestDefinition> test_definition{
143 auto ogs_status = EXIT_SUCCESS;
152 bool solver_succeeded =
false;
166 catch (pybind11::error_already_set
const& e)
168 OGS_FATAL(
"Python exception thrown: {}", e.what());
170 if (solver_succeeded)
172 INFO(
"[time] Simulation completed. It took {:g} s.",
177 INFO(
"[time] Simulation failed. It took {:g} s.",
181 ogs_status = solver_succeeded ? EXIT_SUCCESS : EXIT_FAILURE;
183 catch (std::exception& e)
186 ogs_status = EXIT_FAILURE;
195 catch (std::exception& e)
198 ogs_status = EXIT_FAILURE;
201 if (ogs_status == EXIT_FAILURE)
203 auto const end_time = std::chrono::system_clock::now();
205 ERR(
"OGS terminated with error on {:s}.", time_str);
CommandLineArguments parseCommandLineArguments(int argc, char *argv[], bool const exit_on_exception)
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void signalHandler(int signum)
static void assertNoSwallowedErrors()
Asserts that there have not been any errors reported in the destructor.
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
OGS_EXPORT_SYMBOL bool executeSimulation()
OGS_EXPORT_SYMBOL std::optional< ApplicationsLib::TestDefinition > getTestDefinition() const
static OGS_EXPORT_SYMBOL int runTestDefinitions(std::optional< ApplicationsLib::TestDefinition > &test_definition)
OGS_EXPORT_SYMBOL void initializeDataStructures(std::string const &project, std::vector< std::string > const &xml_patch_file_names, bool reference_path_is_set, std::string const &reference_path, bool nonfatal, std::string const &outdir, std::string const &mesh_dir, std::string const &script_dir, bool write_prj)
OGS_EXPORT_SYMBOL void outputLastTimeStep() const
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)
bool reference_path_is_set
std::string reference_path
std::vector< std::string > xml_patch_file_names