diff --git a/cmake/modules/FindSuperLU.cmake b/cmake/modules/FindSuperLU.cmake index df205773a496339838387330237f7c1f3dcbe228..5211ec822a64087c35fec5d5b96ee826f98f7495 100644 --- a/cmake/modules/FindSuperLU.cmake +++ b/cmake/modules/FindSuperLU.cmake @@ -50,7 +50,7 @@ find_path(SUPERLU_INCLUDE_DIR # look for library, only at positions given by the user find_library(SUPERLU_LIBRARY - NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu" + NAMES "superlu_5.2" "superlu_5.1.1" "superlu_5.1" "superlu_5.0" "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu" PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT} PATH_SUFFIXES "lib" "lib32" "lib64" NO_DEFAULT_PATH @@ -58,7 +58,7 @@ find_library(SUPERLU_LIBRARY # look for library files, including default paths find_library(SUPERLU_LIBRARY - NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu" + NAMES "superlu_5.2" "superlu_5.1.1" "superlu_5.1" "superlu_5.0" "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu" PATH_SUFFIXES "lib" "lib32" "lib64" ) @@ -90,15 +90,30 @@ int main(void) return SLU_DOUBLE; }" SUPERLU_MIN_VERSION_4_3) + +CHECK_C_SOURCE_COMPILES(" +typedef int int_t; +#include <supermatrix.h> +#include <slu_util.h> +int main(void) +{ + GlobalLU_t glu; + return 0; +}" +SUPERLU_MIN_VERSION_5) + cmake_pop_check_state() -if(SUPERLU_MIN_VERSION_4_3) +if(SUPERLU_MIN_VERSION_5) + set(SUPERLU_WITH_VERSION "SuperLU >= 5.0" CACHE STRING + "Human readable string containing SuperLU version information.") +elseif(SUPERLU_MIN_VERSION_4_3) set(SUPERLU_WITH_VERSION "SuperLU >= 4.3" CACHE STRING "Human readable string containing SuperLU version information.") else() set(SUPERLU_WITH_VERSION "SuperLU <= 4.2 and >= 4.0" CACHE STRING "Human readable string containing SuperLU version information.") -endif(SUPERLU_MIN_VERSION_4_3) +endif() # behave like a CMake module is supposed to behave include(FindPackageHandleStandardArgs) diff --git a/config.h.cmake b/config.h.cmake index e1542aff40cb4505edbbf5cc2627f4e015468971..29df279aef014766ec7c054c86890174a025f50a 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -40,6 +40,9 @@ /* define to 1 if SuperLU header slu_ddefs.h contains SLU_DOUBLE */ #cmakedefine SUPERLU_MIN_VERSION_4_3 @SUPERLU_MIN_VERSION_4_3@ +/* define to 1 if SuperLU dgssvx takes a GlobalLU_t parameter */ +#cmakedefine SUPERLU_MIN_VERSION_5 @SUPERLU_MIN_VERSION_5@ + /* Define to the version of dune-istl */ #define DUNE_ISTL_VERSION "${DUNE_ISTL_VERSION}" diff --git a/dune/istl/superlu.hh b/dune/istl/superlu.hh index a018f8b060f0b0286685ed209267f66f5de34c1e..94e06729102801b6462e449752ef5bcc664330ac 100644 --- a/dune/istl/superlu.hh +++ b/dune/istl/superlu.hh @@ -105,9 +105,16 @@ namespace Dune float *rpg, float *rcond, float *ferr, float *berr, mem_usage_t *memusage, SuperLUStat_t *stat, int *info) { +#if SUPERLU_MIN_VERSION_5 + GlobalLU_t gLU; + sgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, + L, U, work, lwork, B, X, rpg, rcond, ferr, berr, + &gLU, memusage, stat, info); +#else sgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, rpg, rcond, ferr, berr, memusage, stat, info); +#endif } }; @@ -146,9 +153,16 @@ namespace Dune double *rpg, double *rcond, double *ferr, double *berr, mem_usage_t *memusage, SuperLUStat_t *stat, int *info) { +#if SUPERLU_MIN_VERSION_5 + GlobalLU_t gLU; + dgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, + L, U, work, lwork, B, X, rpg, rcond, ferr, berr, + &gLU, memusage, stat, info); +#else dgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, rpg, rcond, ferr, berr, memusage, stat, info); +#endif } }; @@ -186,9 +200,16 @@ namespace Dune double *rpg, double *rcond, double *ferr, double *berr, mem_usage_t *memusage, SuperLUStat_t *stat, int *info) { +#if SUPERLU_MIN_VERSION_5 + GlobalLU_t gLU; + zgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, + L, U, work, lwork, B, X, rpg, rcond, ferr, berr, + &gLU, memusage, stat, info); +#else zgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, rpg, rcond, ferr, berr, memusage, stat, info); +#endif } }; @@ -226,9 +247,16 @@ namespace Dune float *rpg, float *rcond, float *ferr, float *berr, mem_usage_t *memusage, SuperLUStat_t *stat, int *info) { +#if SUPERLU_MIN_VERSION_5 + GlobalLU_t gLU; + cgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, + L, U, work, lwork, B, X, rpg, rcond, ferr, berr, + &gLU, memusage, stat, info); +#else cgssvx(options, mat, perm_c, perm_r, etree, equed, R, C, L, U, work, lwork, B, X, rpg, rcond, ferr, berr, memusage, stat, info); +#endif } };