summary refs log tree commit diff
path: root/pkgs/development/libraries/science/math/arpack/default.nix
blob: a418df7050eb12747f29e57679b6948591d43eab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake
, gfortran, blas, lapack, eigen
, useMpi ? false
, mpi
, openssh
}:

# MPI version can only be built with LP64 interface.
# See https://github.com/opencollab/arpack-ng#readme
assert useMpi -> !blas.isILP64;

stdenv.mkDerivation rec {
  pname = "arpack";
  version = "3.8.0";

  src = fetchFromGitHub {
    owner = "opencollab";
    repo = "arpack-ng";
    rev = version;
    sha256 = "sha256-nc710iLRqy/p3EaVgbEoCRzNJ9GpKqqQp33tbn7R6lA=";
  };

  patches = [
    # https://github.com/opencollab/arpack-ng/pull/301
    (fetchpatch {
      name = "pkg-config-paths.patch";
      url = "https://github.com/opencollab/arpack-ng/commit/47fc83cb371a9cc8a8c058097de5e0298cd548f5.patch";
      excludes = [ "CHANGES" ];
      sha256 = "1aijvrfsxkgzqmkzq2dmaj8q3jdpg2hwlqpfl8ddk9scv17gh9m8";
    })
  ];

  nativeBuildInputs = [ cmake gfortran ];
  buildInputs = assert (blas.isILP64 == lapack.isILP64); [
    blas
    lapack
    eigen
  ] ++ lib.optional useMpi mpi;

  nativeCheckInputs = lib.optional useMpi openssh;

  doCheck = true;

  cmakeFlags = [
    "-DBUILD_SHARED_LIBS=ON"
    "-DINTERFACE64=${if blas.isILP64 then "1" else "0"}"
    "-DMPI=${if useMpi then "ON" else "OFF"}"
  ];

  preCheck = ''
    # Prevent tests from using all cores
    export OMP_NUM_THREADS=2
  '';

  postFixup = lib.optionalString stdenv.isDarwin ''
    install_name_tool -change libblas.dylib ${blas}/lib/libblas.dylib $out/lib/libarpack.dylib
  '';

  passthru = { inherit (blas) isILP64; };

  meta = {
    homepage = "https://github.com/opencollab/arpack-ng";
    description = ''
      A collection of Fortran77 subroutines to solve large scale eigenvalue
      problems.
    '';
    license = lib.licenses.bsd3;
    maintainers = with lib.maintainers; [ ttuegel dotlambda ];
    platforms = lib.platforms.unix;
  };
}