4#include <pybind11/embed.h>
5#include <pybind11/pybind11.h>
6#include <spdlog/spdlog.h>
7#include <tclap/CmdLine.h>
43 _MM_SET_EXCEPTION_MASK(_MM_GET_EXCEPTION_MASK() & ~_MM_MASK_INVALID);
46 feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
51#include <spdlog/sinks/null_sink.h>
52#include <spdlog/sinks/stdout_color_sinks.h>
58 auto const end_time = std::chrono::system_clock::now();
61 ERR(
"Simulation aborted on {:s}. Received signal: {:d}.", time_str, signum);
77 spdlog::set_pattern(fmt::format(
"[{}] %^%l:%$ %v", mpi_rank));
93 spdlog::stdout_color_st(
"ogs");
98 auto const start_time = std::chrono::system_clock::now();
100 INFO(
"OGS started on {:s} with MPI. MPI processes: {:d}.", time_str,
107 auto const start_time = std::chrono::system_clock::now();
109 INFO(
"OGS started on {:s} in serial mode.", time_str);
115int main(
int argc,
char* argv[])
138 "This is OpenGeoSys-6 version {:s}. Log version: {:d}, Log level: "
143 std::optional<ApplicationsLib::TestDefinition> test_definition{
145 auto ogs_status = EXIT_SUCCESS;
149 pybind11::scoped_interpreter py_interpreter{
158 bool solver_succeeded =
false;
172 catch (pybind11::error_already_set
const& e)
174 OGS_FATAL(
"Python exception thrown: {}", e.what());
176 if (solver_succeeded)
178 INFO(
"[time] Simulation completed. It took {:g} s.",
183 INFO(
"[time] Simulation failed. It took {:g} s.",
187 ogs_status = solver_succeeded ? EXIT_SUCCESS : EXIT_FAILURE;
189 catch (std::exception& e)
192 ogs_status = EXIT_FAILURE;
201 catch (std::exception& e)
204 ogs_status = EXIT_FAILURE;
207 if (ogs_status == EXIT_FAILURE)
209 auto const end_time = std::chrono::system_clock::now();
211 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 setupEmbeddedPythonVenvPaths()
pybind11::scoped_interpreter setupEmbeddedPython()
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