diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a96c63e4c075d732ba05fb0658c892a1e076ac..dacf1f739ef0d9d1f80ef86462cd6516a6dc2670 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 74686b26721e16bd69f65c9710859b15d2e1de9c..b894b71143be6a8d2fe5a14df3a8f3ae71259270 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 62fc6e0a898e09af9665faaf2379d2b19fea24a9..c20e219ee95f393c6ac87c611b965d33d37d0109 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