From 166b7c6a23c676ada57a746d054f5a88ca69508b Mon Sep 17 00:00:00 2001 From: Stephan Schulz <stephan.schulz-x2q@rub.de> Date: Thu, 26 Nov 2020 09:14:37 +0100 Subject: [PATCH] -DCM_ALL_FORTRAN_ERROR_ABORT to directly abort on any errors (#25) --- CMakeLists.txt | 6 ++++++ README_new.md | 4 ++++ src/ALL_fortran.cpp | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a96c6..dacf1f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ option(CM_ALL_VORONOI "Voronoi-based loadbalancing scheme (requires Voro++)" OFF option(CM_ALL_FORTRAN "VTK output routine" OFF) option(CM_ALL_DEBUG "Enable debug information" OFF) option(CM_ALL_USE_F08 "Use some Fortran 2008 features (mpi_f08)" OFF) +option(CM_ALL_FORTRAN_ERROR_ABORT "Abort on any error when using the +Fortran interface" OFF) option(CM_ALL_TESTS "Enables test suite" OFF) option(CM_ALL_AUTO_DOC "Enables creation of auto-documentation") @@ -65,6 +67,10 @@ if (CM_ALL_DEBUG) add_compile_options("-DALL_DEBUG_ENABLED") endif(CM_ALL_DEBUG) +if(CM_ALL_FORTRAN_ERROR_ABORT) + add_compile_options("-DALL_FORTRAN_ERROR_ABORT") +endif() + if(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE) add_compile_options("-DALL_USE_F08") elseif(CM_ALL_USE_F08 AND NOT MPI_Fortran_HAVE_F08_MODULE) diff --git a/README_new.md b/README_new.md index 74686b2..b894b71 100644 --- a/README_new.md +++ b/README_new.md @@ -96,6 +96,10 @@ Optional requirements: - `-DCM_ALL_USE_F08=ON` (default: `OFF`): Enable usage of `mpi_f08` module for MPI. Requires Fortran 2008 capable compiler and compatible MPI installation. + - `-DCM_ALL_FORTRAN_ERROR_ABORT=ON` (default: `OFF): Abort + execution on any error when using the Fortran interface instead + of setting the error number and leaving error handling to the + user. - `-DCM_ALL_VORONOI=ON` (default: `OFF`): Enable Voronoi mesh method and subsequently compilation and linkage of Voro++. - `-DCM_ALL_TESTING=ON` (default: `OFF`): Turns on unit and feature diff --git a/src/ALL_fortran.cpp b/src/ALL_fortran.cpp index 62fc6e0..c20e219 100644 --- a/src/ALL_fortran.cpp +++ b/src/ALL_fortran.cpp @@ -41,11 +41,16 @@ static const char* ALL_errdesc; typedef ALL::ALL<double, double> ALL_t; +#ifdef ALL_FORTRAN_ERROR_ABORT +#define ALL_try +#define ALL_catch +#else #define ALL_try try { #define ALL_catch } catch (ALL::CustomException &e) { \ ALL_errno = e.get_error_id(); \ ALL_errdesc = e.what(); \ } +#endif /* This interface is unstable and subject to change! It is only used for the -- GitLab