nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 161 lines 4.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchzip, 5 mpi, 6 gfortran, 7 fixDarwinDylibNames, 8 blas, 9 lapack, 10 scalapack, 11 scotch, 12 metis, 13 parmetis, 14 mpiCheckPhaseHook, 15 static ? stdenv.hostPlatform.isStatic, 16 mpiSupport ? false, 17 withParmetis ? false, # default to false due to unfree license 18 withPtScotch ? mpiSupport, 19}: 20assert withParmetis -> mpiSupport; 21assert withPtScotch -> mpiSupport; 22let 23 profile = if mpiSupport then "debian.PAR" else "debian.SEQ"; 24 LMETIS = toString ([ "-lmetis" ] ++ lib.optional withParmetis "-lparmetis"); 25 LSCOTCH = toString ( 26 if withPtScotch then 27 [ 28 "-lptscotch" 29 "-lptesmumps" 30 "-lptscotcherr" 31 ] 32 else 33 [ 34 "-lesmumps" 35 "-lscotch" 36 "-lscotcherr" 37 ] 38 ); 39 ORDERINGSF = toString ( 40 [ 41 "-Dmetis" 42 "-Dpord" 43 "-Dscotch" 44 ] 45 ++ lib.optional withParmetis "-Dparmetis" 46 ++ lib.optional withPtScotch "-Dptscotch" 47 ); 48in 49stdenv.mkDerivation (finalAttrs: { 50 name = "mumps"; 51 version = "5.8.0"; 52 # makeFlags contain space and one should use makeFlagsArray+ 53 # Setting this magic var is an optional solution 54 __structuredAttrs = true; 55 56 strictDeps = true; 57 58 src = fetchzip { 59 url = "https://mumps-solver.org/MUMPS_${finalAttrs.version}.tar.gz"; 60 hash = "sha256-opJW7+Z/YhyUFwYTTTuWZuykz8Z4do6/XTBThHyTVCs="; 61 }; 62 63 postPatch = lib.optionalString stdenv.hostPlatform.isDarwin '' 64 substituteInPlace src/Makefile --replace-fail \ 65 "-Wl,\''$(SONAME),libmumps_common" \ 66 "-Wl,-install_name,$out/lib/libmumps_common" 67 ''; 68 69 configurePhase = '' 70 cp Make.inc/Makefile.${profile} ./Makefile.inc 71 ''; 72 73 enableParallelBuilding = true; 74 75 makeFlags = 76 lib.optionals stdenv.hostPlatform.isDarwin [ 77 "SONAME=" 78 "LIBEXT_SHARED=.dylib" 79 ] 80 ++ [ 81 "ISCOTCH=-I${lib.getDev scotch}/include" 82 "LMETIS=${LMETIS}" 83 "LSCOTCH=${LSCOTCH}" 84 "ORDERINGSF=${ORDERINGSF}" 85 "OPTF=-O3 -fallow-argument-mismatch" 86 "OPTC=-O3" 87 "OPTL=-O3" 88 "SCALAP=-lscalapack" 89 "${if static then "all" else "allshared"}" 90 ]; 91 92 installPhase = '' 93 mkdir $out 94 cp -r include lib $out 95 '' 96 + lib.optionalString (!mpiSupport) '' 97 # Install mumps_seq headers 98 install -Dm 444 -t $out/include/mumps_seq libseq/*.h 99 100 # Add some compatibility with coin-or-mumps 101 ln -s $out/include/mumps_seq/mpi.h $out/include/mumps_mpi.h 102 ''; 103 104 nativeBuildInputs = [ 105 gfortran 106 ] 107 ++ lib.optional mpiSupport mpi 108 ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; 109 110 # Parmetis should be placed before scotch to avoid conflict of header file "parmetis.h" 111 buildInputs = 112 lib.optional withParmetis parmetis 113 ++ lib.optional mpiSupport scalapack 114 ++ [ 115 blas 116 lapack 117 metis 118 scotch 119 ]; 120 121 doInstallCheck = true; 122 123 nativeInstallCheckInputs = lib.optional mpiSupport mpiCheckPhaseHook; 124 125 installCheckPhase = '' 126 runHook preInstallCheck 127 128 ${lib.optionalString stdenv.hostPlatform.isDarwin "export DYLD_LIBRARY_PATH=$out/lib\n"} 129 ${lib.optionalString mpiSupport "export MPIRUN='mpirun -n 2'\n"} 130 cd examples 131 $MPIRUN ./ssimpletest <input_simpletest_real 132 $MPIRUN ./dsimpletest <input_simpletest_real 133 $MPIRUN ./csimpletest <input_simpletest_cmplx 134 $MPIRUN ./zsimpletest <input_simpletest_cmplx 135 $MPIRUN ./c_example 136 $MPIRUN ./multiple_arithmetics_example 137 $MPIRUN ./ssimpletest_save_restore <input_simpletest_real 138 $MPIRUN ./dsimpletest_save_restore <input_simpletest_real 139 $MPIRUN ./csimpletest_save_restore <input_simpletest_cmplx 140 $MPIRUN ./zsimpletest_save_restore <input_simpletest_cmplx 141 $MPIRUN ./c_example_save_restore 142 143 runHook postInstallCheck 144 ''; 145 146 passthru = { 147 inherit withParmetis withPtScotch mpiSupport; 148 }; 149 150 meta = { 151 description = "MUltifrontal Massively Parallel sparse direct Solver"; 152 homepage = "https://mumps-solver.org/"; 153 changelog = "https://mumps-solver.org/index.php?page=dwnld#cl"; 154 license = lib.licenses.cecill-c; 155 maintainers = with lib.maintainers; [ 156 nim65s 157 qbisi 158 ]; 159 platforms = lib.platforms.unix; 160 }; 161})