# HG changeset patch # User Carlo de Falco # Date 1550230515 -3600 # Fri Feb 15 12:35:15 2019 +0100 # Node ID 9b27b77d2fec1a334baa7f4b2ec70751f4bf2b99 # Parent 4bf27c090f5695bcf545fc4af15e2a61a3941d46 Update detection of sundials in the build system (bug #52475). * m4/acnclude.m4 : check for sunlinsol_klu.h and sunlinsol_dense.h * configure.ac : update check for sundials features * script/ode/ode15i.m : update conditionals in tests * script/ode/ode15s.m : update conditionals in tests * libinterp/dldfcn/__ode15__.cc : udate conditionals in preprocessor directives diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -2206,15 +2206,15 @@ [], [don't use SUNDIALS IDA library, solvers ode15i and ode15s will be disabled], [warn_sundials_ida= OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE - OCTAVE_CHECK_SUNDIALS_IDA_DENSE - OCTAVE_CHECK_SUNDIALS_IDAKLU]) + OCTAVE_CHECK_SUNDIALS_SUNLINSOL_DENSE + OCTAVE_CHECK_SUNDIALS_SUNLINSOL_KLU]) LIBS="$save_LIBS" 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. if test -n "$SUNDIALS_IDA_LIBS" \ && test -n "$SUNDIALS_NVECSERIAL_LIBS" \ - && test $octave_cv_sundials_ida_dense = yes \ + && 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.]) fi diff --git a/libinterp/dldfcn/__ode15__.cc b/libinterp/dldfcn/__ode15__.cc --- a/libinterp/dldfcn/__ode15__.cc +++ b/libinterp/dldfcn/__ode15__.cc @@ -45,15 +45,31 @@ # include # endif -# if defined (HAVE_IDA_IDA_DENSE_H) -# include +# if defined (HAVE_SUNDIALS_SUNDIALS_MATRIX_H) +# include +# endif + +# if defined (HAVE_SUNDIALS_SUNDIALS_LINEARSOLVER_H) +# include +# endif + +# if defined (HAVE_SUNLINSOL_SUNLINSOL_DENSE_H) +# include # endif -# if defined (HAVE_IDA_IDA_KLU_H) -# include +# if defined (HAVE_IDA_IDA_DIRECT_H) +# include +# endif + +# if defined (HAVE_SUNDIALS_SUNDIALS_SPARSE_H) # include # endif + +# if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H) +# include +# endif + # if defined (HAVE_NVECTOR_NVECTOR_SERIAL_H) # include # endif @@ -221,7 +237,7 @@ jacdense_impl (realtype t, realtype cj, N_Vector& yy, N_Vector& yyp, SUNMatrix& JJ); -# if defined (HAVE_SUNDIALS_IDAKLU) +# if defined (HAVE_SUNDIALS_SUNLINSOL_KLU) static int jacsparse (realtype t, realtype cj, N_Vector yy, N_Vector yyp, N_Vector, SUNMatrix Jac, void *user_data, N_Vector, @@ -338,7 +354,7 @@ if (havejacsparse) { -# if defined (HAVE_SUNDIALS_IDAKLU) +#if defined (HAVE_SUNDIALS_SUNLINSOL_KLU) sunJacMatrix = SUNSparseMatrix (num, num, num*num, CSC_MAT); if (! sunJacMatrix) @@ -405,7 +421,7 @@ END_INTERRUPT_WITH_EXCEPTIONS; } -# if defined (HAVE_SUNDIALS_IDAKLU) +# if defined (HAVE_SUNDIALS_SUNLINSOL_KLU) void IDA::jacsparse_impl (realtype t, realtype cj, N_Vector& yy, N_Vector& yyp, SUNMatrix& Jac) diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -2210,14 +2210,11 @@ dnl precision realtype. dnl AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SIZEOF_REALTYPE], [ - AC_CHECK_HEADERS([ida/ida.h ida.h]) AC_CACHE_CHECK([whether SUNDIALS IDA is configured with double precision realtype], [octave_cv_sundials_realtype_is_double], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if defined (HAVE_IDA_IDA_H) #include - #else - #include #endif #include ]], [[ @@ -2233,61 +2230,72 @@ fi ]) dnl -dnl Check whether SUNDIALS IDA library is configured with IDAKLU +dnl Check whether SUNDIALS IDA library is configured with SUNLINSOL_KLU dnl enabled. dnl -AC_DEFUN([OCTAVE_CHECK_SUNDIALS_IDAKLU], [ - AC_CHECK_HEADERS([ida/ida_klu.h ida_klu.h]) - AC_CACHE_CHECK([whether SUNDIALS IDA is configured with IDAKLU enabled], - [octave_cv_sundials_idaklu], +AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNLINSOL_KLU], [ + AC_CHECK_HEADERS([sundials/sundials_sparse.h sunlinsol/sunlinsol_klu.h]) + AC_CACHE_CHECK([whether SUNDIALS IDA is configured with SUNLINSOL_KLU enabled], + [octave_cv_sundials_sunlinsol_klu], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #if defined (HAVE_IDA_IDA_KLU_H) - #include - #else - #include + #if defined (HAVE_IDA_IDA_H) + #include + #endif + #if defined (HAVE_SUNDIALS_SUNDIALS_SPARSE_H) + #include + #endif + #if defined (HAVE_SUNLINSOL_SUNLINSOL_KLU_H) + #include #endif ]], [[ - IDAKLU (0, 0, 0, 0); + SUNKLU (0, 0); ]])], - octave_cv_sundials_idaklu=yes, - octave_cv_sundials_idaklu=no) + octave_cv_sundials_sunlinsol_klu=yes, + octave_cv_sundials_sunlinsol_klu=no) ]) - if test $octave_cv_sundials_idaklu = yes; then - AC_DEFINE(HAVE_SUNDIALS_IDAKLU, 1, - [Define to 1 if SUNDIALS IDA is configured with IDAKLU enabled.]) + if test $octave_cv_sundials_sunlinsol_klu = yes; then + AC_DEFINE(HAVE_SUNDIALS_SUNLINSOL_KLU, 1, + [Define to 1 if SUNDIALS IDA is configured with SUNLINSOL_KLU enabled.]) else - warn_sundials_idaklu="SUNDIALS IDA library not configured with IDAKLU, ode15i and ode15s will not support the sparse Jacobian feature" - OCTAVE_CONFIGURE_WARNING([warn_sundials_idaklu]) + warn_sundials_idaklu="SUNDIALS IDA library not configured with SUNLINSOL_KLU, ode15i and ode15s will not support the sparse Jacobian feature" + OCTAVE_CONFIGURE_WARNING([warn_sundials_sunlinsol_klu]) fi ]) dnl -dnl Check whether SUNDIALS IDA library has the IDADENSE linear solver. +dnl Check whether SUNDIALS IDA library has the SUNLINSOL_DENSE linear solver. dnl The IDADENSE API was removed in SUNDIALS version 3.0.0. dnl -AC_DEFUN([OCTAVE_CHECK_SUNDIALS_IDA_DENSE], [ - AC_CHECK_HEADERS([ida/ida_dense.h ida_dense.h]) - AC_CACHE_CHECK([whether SUNDIALS IDA includes the IDADENSE linear solver], - [octave_cv_sundials_ida_dense], +AC_DEFUN([OCTAVE_CHECK_SUNDIALS_SUNLINSOL_DENSE], [ + AC_CHECK_HEADERS([sunlinsol/sunlinsol_dense.h sundials/sundials_matrix.h sundials/sundials_linearsolver.h ida/ida_direct.h]) + AC_CACHE_CHECK([whether SUNDIALS IDA includes the SUNLINSOL_DENSE linear solver], + [octave_cv_sundials_sunlinsol_dense], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #if defined (HAVE_IDA_IDA_DENSE_H) - #include - #else - #include + #if defined (HAVE_IDA_IDA_H) + #include + #endif + #if defined (HAVE_SUNDIALS_SUNDIALS_MATRIX_H) + #include #endif + #if defined (HAVE_SUNDIALS_SUNDIALS_LINEARSOLVER_H) + #include + #endif + #if defined (HAVE_IDA_IDA_DIRECT_H) + #include + #endif ]], [[ void *mem = 0; long int num = 0; IDADense (mem, num); ]])], - octave_cv_sundials_ida_dense=yes, - octave_cv_sundials_ida_dense=no) + octave_cv_sundials_sunlinsol_dense=yes, + octave_cv_sundials_sunlinsol_dense=no) ]) - if test $octave_cv_sundials_ida_dense = yes; then - AC_DEFINE(HAVE_SUNDIALS_IDADENSE, 1, - [Define to 1 if SUNDIALS IDA includes the IDADENSE linear solver.]) + if test $octave_cv_sundials_sunlinsol_dense = yes; then + AC_DEFINE(HAVE_SUNDIALS_SUNLINSOL_DENSE, 1, + [Define to 1 if SUNDIALS IDA includes the SUNLINSOL_DENSE linear solver.]) else - warn_sundials_ida_dense="SUNDIALS IDA library does not include the IDADENSE linear solver, ode15i and ode15s will be disabled" - OCTAVE_CONFIGURE_WARNING([warn_sundials_ida_dense]) + warn_sundials_ida_dense="SUNDIALS IDA library does not include the SUNLINSOL_DENSE linear solver, ode15i and ode15s will be disabled" + OCTAVE_CONFIGURE_WARNING([warn_sundials_sunlinsol_dense]) fi ]) dnl diff --git a/scripts/ode/ode15i.m b/scripts/ode/ode15i.m --- a/scripts/ode/ode15i.m +++ b/scripts/ode/ode15i.m @@ -452,7 +452,7 @@ %! assert ([t(end), y(end,:)], fref, 1e-3); ## Jacobian fun sparse -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! opt = odeset ("Jacobian", @jacfunsparse, "AbsTol", 1e-7, "RelTol", 1e-7); %! [t, y] = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt); %! assert ([t(end), y(end,:)], fref, 1e-3); @@ -545,7 +545,7 @@ %! "invalid value assigned to field 'Jacobian'"); ## Jacobian cell sparse wrong dimension -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! DFDY = sparse ([-0.04, 1; %! 0.04, 1]); %! DFDYP = sparse ([-1, 0, 0; diff --git a/scripts/ode/ode15s.m b/scripts/ode/ode15s.m --- a/scripts/ode/ode15s.m +++ b/scripts/ode/ode15s.m @@ -545,21 +545,21 @@ %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt); %! assert ([t(end), y(end,:)], frefrob, 1e-3); -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! opt = odeset ("MStateDependence", "none", %! "Mass", [1, 0, 0; 0, 1, 0; 0, 0, 0], %! "Jacobian", @jacfunsparse); %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt); %! assert ([t(end), y(end,:)], frefrob, 1e-3); -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! opt = odeset ("MStateDependence", "none", %! "Mass", sparse ([1, 0, 0; 0, 1, 0; 0, 0, 0]), %! "Jacobian", @jacfunsparse); %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt); %! assert ([t(end), y(end,:)], frefrob, 1e-3); -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! warning ("off", "ode15s:mass_state_dependent_provided", "local"); %! opt = odeset ("MStateDependence", "none", %! "Mass", @massdensefunstate, @@ -575,14 +575,14 @@ %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt); %! assert ([t(end), y(end,:)], frefrob, 1e-3); -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! opt = odeset ("MStateDependence", "none", %! "Mass", @massdensefuntime, %! "Jacobian", @jacfunsparse); %! [t, y] = ode15s (@rob, [0, 100], [1; 0; 0], opt); %! assert ([t(end), y(end,:)], frefrob, 1e-3); -%!testif HAVE_SUNDIALS_IDAKLU +%!testif HAVE_SUNDIALS_SUNLINSOL_KLU %! opt = odeset ("MStateDependence", "none", %! "Mass", @masssparsefuntime, %! "Jacobian", @jacfunsparse);