# HG changeset patch # User John W. Eaton # Date 1552514231 0 # Node ID 73b141d5a888009a82460af33244b1a09191877a # Parent cb5c1ea2062c45cbfaa52334d93a6888e8d9f959 improve configure checks for sundials (bug #55911) * acinclude.m4 (OCTAVE_CHECK_SUNDIALS_SUNLINSOL_KLU): Also check for sundials_sunlinsol_klu library. Some systems require linking with this explicitly. Define SUNDIALS_SUNLINSOL_KLU_LIBS if found. * configure.ac (SUNDIALS_XLIBS): Include $SUNDIALS_SUNLINSOL_KLU_LIBS in the list. (HAVE_SUNDIALS): Also require sunlinsol/sunlinsol_klu.h to be defined. Warn if disabling because something is missing. Check for current and deprecated sundials function names that we can easily replace (only the names have changed). * __ode15__.cc: Allow building with ida.h if it is available but ida/ida.h is not. Do include ida_direct.h or ida/ida_direct.h if they are present. (IDASetJacFn, IDASetLinearSolver, SUNLinSol_Dense, SUNLinSol_KLU): New inline wrapper functions to allow building when only the older deprecated funtions are available. diff -r cb5c1ea2062c -r 73b141d5a888 configure.ac --- a/configure.ac Tue Mar 12 09:21:54 2019 +0100 +++ b/configure.ac Wed Mar 13 21:57:11 2019 +0000 @@ -2212,11 +2212,20 @@ dnl Define this way instead of with an #if in oct-conf-post.h so that dnl the build features script will get the correct value. +dnl +dnl The test on the sunlinsol_klu.h header is a bit of a kluge. +dnl How can we do a better job here? Do we need to disable sundials +dnl any tests fail, or can we fix __ode15__.cc so that it still partially +dnl works when some things are missing (for example, KLU)? if test -n "$SUNDIALS_IDA_LIBS" \ && test -n "$SUNDIALS_NVECSERIAL_LIBS" \ + && test "x$ac_cv_header_sunlinsol_sunlinsol_klu_h" = xyes \ && test $octave_cv_sundials_sunlinsol_dense = yes \ && test $octave_cv_sundials_realtype_is_double = yes; then AC_DEFINE(HAVE_SUNDIALS, 1, [Define to 1 if SUNDIALS is available.]) +else + warn_sundials_disabled="disabling SUNDIALS because something is missing, solvers odee15i and ode15s will be disabled" + OCTAVE_CONFIGURE_WARNING([warn_sundials_disabled]) fi ## Collections of flags. @@ -2229,12 +2238,21 @@ SUNDIALS_XLDFLAGS="$SUNDIALS_IDA_LDFLAGS $SUNDIALS_NVECSERIAL_LDFLAGS $KLU_LDFLAGS" -SUNDIALS_XLIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_NVECSERIAL_LIBS $KLU_LIBS" +SUNDIALS_XLIBS="$SUNDIALS_IDA_LIBS $SUNDIALS_SUNLINSOL_KLU_LIBS $SUNDIALS_NVECSERIAL_LIBS $KLU_LIBS" AC_SUBST(SUNDIALS_XCPPFLAGS) AC_SUBST(SUNDIALS_XLDFLAGS) AC_SUBST(SUNDIALS_XLIBS) +save_LIBS="$LIBS" +LIBS="$SUNDIALS_XLIBS $LIBS" +## Current interface: +AC_CHECK_FUNCS([IDASetJacFn IDASetLinearSolver SUNLinSol_Dense SUNLinSol_KLU]) +## Deprecated interface: +AC_CHECK_HEADERS([ida/ida_direct.h ida_direct.h]) +AC_CHECK_FUNCS([IDADlsSetJacFn IDADlsSetLinearSolver SUNDenseLinearSolver SUNKLU]) +LIBS="$save_LIBS" + ### Check for ARPACK library. save_LIBS="$LIBS" diff -r cb5c1ea2062c -r 73b141d5a888 libinterp/dldfcn/__ode15__.cc --- a/libinterp/dldfcn/__ode15__.cc Tue Mar 12 09:21:54 2019 +0100 +++ b/libinterp/dldfcn/__ode15__.cc Wed Mar 13 21:57:11 2019 +0000 @@ -47,6 +47,13 @@ # if defined (HAVE_IDA_IDA_H) # include +# elif defined (HAVE_IDA_H) +# include +# endif +# if defined (HAVE_IDA_IDA_DIRECT_H) +# include +# elif defined (HAVE_IDA_DIRECT_H) +# include # endif # if defined (HAVE_SUNLINSOL_SUNLINSOL_DENSE_H) @@ -69,6 +76,38 @@ # include # endif +# if ! defined (HAVE_IDASETJACFN) && defined (HAVE_IDADLSSETJACFN) +static inline int +IDASetJacFn (void *ida_mem, IDADlsJacFn jac) +{ + return IDADlsSetJacFn (ida_mem, jac); +} +# endif + +# if ! defined (HAVE_IDASETLINEARSOLVER) && defined (HAVE_IDADLSSETLINEARSOLVER) +static inline int +IDASetLinearSolver (void *ida_mem, SUNLinearSolver LS, SUNMatrix A) +{ + return IDADlsSetLinearSolver (ida_mem, LS, A); +} +# endif + +# if ! defined (HAVE_SUNLINSOL_DENSE) && defined (HAVE_SUNDENSELINEARSOLVER) +static inline SUNLinearSolver +SUNLinSol_Dense (N_Vector y, SUNMatrix A) +{ + return SUNDenseLinearSolver (y, A); +} +# endif + +# if ! defined (HAVE_SUNLINSOL_KLU) && defined (HAVE_SUNKLU) +static inline SUNLinearSolver +SUNLinSol_KLU (N_Vector y, SUNMatrix A) +{ + return SUNKLU (y, A); +} +# endif + static inline realtype * nv_data_s (N_Vector& v) { diff -r cb5c1ea2062c -r 73b141d5a888 m4/acinclude.m4 --- a/m4/acinclude.m4 Tue Mar 12 09:21:54 2019 +0100 +++ b/m4/acinclude.m4 Wed Mar 13 21:57:11 2019 +0000 @@ -2240,6 +2240,8 @@ dnl AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNLINSOL_KLU], [ AC_CHECK_HEADERS([sunlinsol/sunlinsol_klu.h]) + AC_CHECK_LIB([sundials_sunlinsolklu], [SUNKLU], + [SUNDIALS_SUNLINSOL_KLU_LIBS=-lsundials_sunlinsolklu]) AC_CACHE_CHECK([whether SUNDIALS IDA is configured with SUNLINSOL_KLU enabled], [octave_cv_sundials_sunlinsol_klu], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[