2021-01-21 17:00:13 +00:00
|
|
|
{ lib, stdenv
|
2019-07-02 13:55:34 +01:00
|
|
|
, cmake
|
|
|
|
, fetchurl
|
2020-12-20 19:29:07 +00:00
|
|
|
, fetchpatch
|
2019-08-01 13:28:19 +01:00
|
|
|
, python
|
2020-03-31 15:47:18 +01:00
|
|
|
, blas
|
|
|
|
, lapack
|
2019-08-01 13:28:19 +01:00
|
|
|
, gfortran
|
2020-08-08 10:36:03 +01:00
|
|
|
, suitesparse
|
|
|
|
, lapackSupport ? true
|
2020-09-22 22:41:47 +01:00
|
|
|
, kluSupport ? true
|
|
|
|
}:
|
2019-08-01 13:28:19 +01:00
|
|
|
|
2020-03-31 15:47:18 +01:00
|
|
|
stdenv.mkDerivation rec {
|
2018-03-01 09:14:18 +00:00
|
|
|
pname = "sundials";
|
2020-12-20 19:29:07 +00:00
|
|
|
version = "5.6.1";
|
2018-03-01 09:14:18 +00:00
|
|
|
|
2021-01-04 13:51:51 +00:00
|
|
|
outputs = [ "out" "examples" ];
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://computation.llnl.gov/projects/${pname}/download/${pname}-${version}.tar.gz";
|
|
|
|
sha256 = "Frd5mex+fyFXqh0Eyh3kojccqBUOBW0klR0MWJZvKoM=";
|
|
|
|
};
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# Fixing an upstream regression in treating cmake prefix directories:
|
|
|
|
# https://github.com/LLNL/sundials/pull/58
|
|
|
|
(fetchpatch {
|
|
|
|
url = "https://github.com/LLNL/sundials/commit/dd32ff9baa05618f36e44aadb420bbae4236ea1e.patch";
|
|
|
|
sha256 = "kToAuma+2iHFyL1v/l29F3+nug4AdK5cPG6IcXv2afc=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
2020-08-08 10:36:03 +01:00
|
|
|
buildInputs = [
|
|
|
|
python
|
2020-09-23 10:56:28 +01:00
|
|
|
]
|
2021-01-21 17:00:13 +00:00
|
|
|
++ lib.optionals (lapackSupport)
|
2020-09-22 22:41:47 +01:00
|
|
|
# Check that the same index size is used for both libraries
|
|
|
|
(assert (blas.isILP64 == lapack.isILP64); [
|
|
|
|
gfortran
|
|
|
|
blas
|
|
|
|
lapack
|
|
|
|
])
|
2020-08-08 10:36:03 +01:00
|
|
|
# KLU support is based on Suitesparse.
|
|
|
|
# It is tested upstream according to the section 1.1.4 of
|
|
|
|
# [INSTALL_GUIDE.pdf](https://raw.githubusercontent.com/LLNL/sundials/master/INSTALL_GUIDE.pdf)
|
2021-01-21 17:00:13 +00:00
|
|
|
++ lib.optionals (kluSupport) [
|
2020-08-08 10:36:03 +01:00
|
|
|
suitesparse
|
|
|
|
];
|
2019-08-01 13:02:00 +01:00
|
|
|
|
2019-07-02 13:55:34 +01:00
|
|
|
cmakeFlags = [
|
2020-12-20 19:30:15 +00:00
|
|
|
"-DEXAMPLES_INSTALL_PATH=${placeholder "examples"}/share/examples"
|
2021-01-21 17:00:13 +00:00
|
|
|
] ++ lib.optionals (lapackSupport) [
|
2020-12-20 19:29:07 +00:00
|
|
|
"-DENABLE_LAPACK=ON"
|
2020-03-31 15:47:18 +01:00
|
|
|
"-DLAPACK_LIBRARIES=${lapack}/lib/liblapack${stdenv.hostPlatform.extensions.sharedLibrary}"
|
2021-01-21 17:00:13 +00:00
|
|
|
] ++ lib.optionals (kluSupport) [
|
2020-12-20 19:29:07 +00:00
|
|
|
"-DENABLE_KLU=ON"
|
2020-08-08 10:36:03 +01:00
|
|
|
"-DKLU_INCLUDE_DIR=${suitesparse.dev}/include"
|
|
|
|
"-DKLU_LIBRARY_DIR=${suitesparse}/lib"
|
2020-12-20 19:29:07 +00:00
|
|
|
] ++ [(
|
|
|
|
# Use the correct index type according to lapack and blas used. They are
|
|
|
|
# already supposed to be compatible but we check both for extra safety. 64
|
|
|
|
# should be the default but we prefer to be explicit, for extra safety.
|
|
|
|
if blas.isILP64 then
|
|
|
|
"-DSUNDIALS_INDEX_SIZE=64"
|
|
|
|
else
|
|
|
|
"-DSUNDIALS_INDEX_SIZE=32"
|
|
|
|
)]
|
2020-09-22 22:41:47 +01:00
|
|
|
;
|
2018-03-01 09:14:18 +00:00
|
|
|
|
2019-08-01 13:02:00 +01:00
|
|
|
doCheck = true;
|
2020-09-22 22:41:47 +01:00
|
|
|
checkTarget = "test";
|
2019-08-01 13:02:00 +01:00
|
|
|
|
2021-01-21 17:00:13 +00:00
|
|
|
meta = with lib; {
|
2018-03-01 09:14:18 +00:00
|
|
|
description = "Suite of nonlinear differential/algebraic equation solvers";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://computation.llnl.gov/projects/sundials";
|
2018-03-01 09:14:18 +00:00
|
|
|
platforms = platforms.all;
|
2020-09-23 10:56:28 +01:00
|
|
|
maintainers = with maintainers; [ idontgetoutmuch ];
|
2018-03-11 15:21:37 +00:00
|
|
|
license = licenses.bsd3;
|
2018-03-01 09:14:18 +00:00
|
|
|
};
|
|
|
|
}
|