From 4a088c44906e38e16ac84a6409715f2e7f562940 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Sun, 24 Apr 2016 12:37:54 +0200 Subject: [PATCH] [MaL] abort if no ODE solver can be created. And also in the tests prevent abort if no ODE solver can be created. --- MathLib/ODE/ODESolverBuilder.h | 12 +++++++++--- Tests/MathLib/TestODESolver.cpp | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MathLib/ODE/ODESolverBuilder.h b/MathLib/ODE/ODESolverBuilder.h index 2fc14a8f0d4..91d94bb4c53 100644 --- a/MathLib/ODE/ODESolverBuilder.h +++ b/MathLib/ODE/ODESolverBuilder.h @@ -10,6 +10,8 @@ #ifndef MATHLIB_ODE_ODESOLVERBUILDER_H #define MATHLIB_ODE_ODESOLVERBUILDER_H +#include <logog/include/logog.hpp> + #include "ODESolver.h" #include "ConcreteODESolver.h" @@ -38,9 +40,13 @@ std::unique_ptr<ODESolver<NumEquations>> createODESolver( #ifdef CVODE_FOUND return std::unique_ptr<ODESolver<NumEquations>>( new ConcreteODESolver<CVodeSolver, NumEquations>(config)); -#else - return nullptr; -#endif // CVODE_FOUND +#endif + (void)config; // Unused parameter warning if no library is available. + + ERR( + "No ODE solver could be created. Maybe it is because you did not build" + " OGS6 with support for any external ODE solver library."); + std::abort(); } //! @} diff --git a/Tests/MathLib/TestODESolver.cpp b/Tests/MathLib/TestODESolver.cpp index 93dc61420fd..3dec1c95b0a 100644 --- a/Tests/MathLib/TestODESolver.cpp +++ b/Tests/MathLib/TestODESolver.cpp @@ -66,6 +66,10 @@ template <unsigned NumEquations> std::unique_ptr<MathLib::ODESolver<NumEquations>> make_ode_solver( boost::property_tree::ptree const& conf) { + // Make sure testrunner does not crash if we haven't built with support for + // any external ODE solver lib. + if (!any_ode_solver_libs_available()) return nullptr; + BaseLib::ConfigTree config(conf, "", BaseLib::ConfigTree::onerror, BaseLib::ConfigTree::onwarning); return MathLib::createODESolver<NumEquations>(config); -- GitLab