octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for SUNDIALS IDA library


From: Francesco Faccio
Subject: Patch for SUNDIALS IDA library
Date: Sat, 30 Jul 2016 23:07:38 +0000

Dear all,

a patch for using library IDA of sundials in Octave is almost ready. I would like to explain the test I wrote in configure.ac and ask for suggestions in order to follow Octave rules. This patch will be used for ode15i and ode15s.

There are three libraries which are used and tested:
-library sundials_ida (linked against klu)
-library sundials_nvecserial

-library klu (already existent in Octave inside SuiteSparse)

I wrote a test for klu. If klu is found, its flags are passed to sundials_ida. If klu is not found, a message "KLU library not found.  This will result in some lack of functionality for sparse matrices" is printed and ode15{i,s} are disabled.

Then I wrote a test for sundials_ida:
-check for the library
-check for header ida.h
-check for function IDAKLU (which tests either the version and the configuration of Sundials with klu)
If any of these test fails, a message "SUNDIALS_IDA library configured with klu not found. Solvers ode15i and ode15s will be disabled." is printed and ode15{i,s} are disabled:

### Check for SUNDIALS_IDA library and header.
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
CPPFLAGS="$KLU_CPPFLAGS $CPPFLAGS"
LIBS="$KLU_LDFLAGS $KLU_LIBS $LIBS"
OCTAVE_CHECK_LIB(sundials_ida, SUNDIALS_IDA,
  [SUNDIALS_IDA library configured with klu not found. Solvers ode15i and ode15s will be disabled.],
  [ida/ida.h ida.h], [IDAKLU], [], [],
  [warn_sundials_ida=
   OCTAVE_CHECK_SIZEOF_SUNDIALS_IDA_REALTYPE])
LIBS="$save_LIBS"
CPPFLAGS="$save_CPPFLAGS"


I tested if Sundials has been configured with a double precision for realtype with this macro:

AC_DEFUN([OCTAVE_CHECK_SIZEOF_SUNDIALS_IDA_REALTYPE], [
  AC_CACHE_CHECK([whether sundials_ida is configured with double precision realtype],
    [octave_cv_sizeof_ida_double],
    AC_LANG_PUSH(C++)
    [AC_RUN_IFELSE([AC_LANG_PROGRAM([[
        #if defined (HAVE_IDA_IDA_H)
        #include <ida/ida.h>
        #else
        #include <ida.h>
        #endif
        #include <assert.h>
        ]], [[
        assert (sizeof (double) == sizeof (realtype));
      ]])],
      octave_cv_sizeof_ida_double=yes,
      octave_cv_sizeof_ida_double=no)
  ])
  if test $octave_cv_sizeof_ida_double = yes; then
    AC_DEFINE(HAVE_SUNDIALS_IDA_DOUBLE, 1,
      [Define to 1 if sundials_ida is configured with realtype as double.])
  else
    warn_sundials_ida="sundials_ida library found, but it's not configured with double precision realtype; function ode15i and ode15s will be disabled"
  fi
])

If variable HAVE_SUNDIALS_IDA_DOUBLE is not set, ode15{i,s} are disabled.

Finally I tested for library sundials_nvecserial and if not found printed a warning message and disabled ode15{i,s}.



If the user wants to install klu or sundials in non-standard paths, she can specify include and lib flags while configuring Octave.

Is this the right approach?
Which other events could happen to make me disable ode15{i,s}?
If some SuiteSparse library is not installed, a warning message is printed during the configuration of Octave, saying that there is a lack of functionality for sparse matrices. Should I check for amd, colamd (other libraries?) flags and, in case, disable my solver?


Thank you,

Francesco


reply via email to

[Prev in Thread] Current Thread [Next in Thread]