Skip to content

Commit

Permalink
petsc: added features, especially mpi support
Browse files Browse the repository at this point in the history
  • Loading branch information
bzizou committed Sep 11, 2017
1 parent c51b089 commit ee78e6d
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
87 changes: 87 additions & 0 deletions pkgs/development/libraries/science/math/petsc/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{ stdenv
, fetchurl
, openblasCompat
, python
, gfortran
, openmpi
, tcsh
, valgrind
, suitesparse
, hwloc
, metis
, superlu
, hdf5
, netcdf
, scalarType ? "complex" # May be "real" or "complex"
}:

stdenv.mkDerivation rec {
name = "petsc-${version}";
version = "3.7.6";

src = fetchurl {
url = "http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-${version}.tar.gz";
sha256 = "0jfl35lrhzvv982z6h1v5rcp39g0x16ca43rm9dx91wm6i8y13iw";
};

patches = [ ./petscmpiexec.patch ];

buildInputs = [
openblasCompat
python
gfortran
openmpi
tcsh
valgrind
suitesparse
hwloc
metis
superlu
hdf5
netcdf
];

enableParallelBuilding = true;

preConfigure = ''
patchShebangs .
'';

configureFlags = let
sharedLibraryExtension = if stdenv.isDarwin then ".dylib" else ".so";
in [
"--with-scalar-type=${scalarType}"
"--with-debugging=0"
"--with-mpi=1"
# PETSc is not threadsafe, disable pthread/openmp (see http://www.mcs.anl.gov/petsc/miscellaneous/petscthreads.html)
"--with-pthread=0"
"--with-openmp=0"
"--with-ssl=0"
"--with-x=0"
"--with-mpi-dir=${openmpi}"
"--with-blas-lapack-lib=${openblasCompat}/lib/libopenblas${sharedLibraryExtension}"
"--with-valgrind=1"
"--with-valgrind-dir=${valgrind}"
"--with-suitesparse-dir=${suitesparse}"
"--with-hwloc-dir=${hwloc}"
"--with-netcdf-dir=${netcdf}"
"--with-hdf5-dir=${hdf5}"
"--with-superlu-dir=${superlu}"
"--with-metis-dir=${metis}"
];

postInstall = ''
rm $out/bin/popup
rm $out/bin/uncrustify.cfg
rm -rf $out/bin/win32fe
'';

doCheck = true;

meta = {
description = "Library of linear algebra algorithms for solving partial differential equations";
homepage = https://www.mcs.anl.gov/petsc/index.html;
platforms = stdenv.lib.platforms.all;
license = stdenv.lib.licenses.bsd2;
};
}
24 changes: 24 additions & 0 deletions pkgs/development/libraries/science/math/petsc/petscmpiexec.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff -r -u petsc-3.7.6.orig/bin/petscmpiexec petsc-3.7.6/bin/petscmpiexec
--- petsc-3.7.6.orig/bin/petscmpiexec 2016-05-16 04:57:35.000000000 +0200
+++ petsc-3.7.6/bin/petscmpiexec 2017-09-08 10:20:15.766763209 +0200
@@ -1,4 +1,4 @@
-#! /bin/csh -f
+#!/bin/tcsh -f
# $Id: petscmpiexec,v 1.3 2001/09/04 16:18:05 bsmith Exp $
#
# Uses PETSC_ARCH and PETSC_DIR plus the MPIEXEC command in
@@ -38,11 +38,11 @@
#echo $MPI_HOME

#echo $run
-set trun = `echo ${run} | sed -e sz\$MPI_BUILD_HOMEz${MPI_BUILD_HOME}z`
+set trun = `echo ${run} | sed -e s,\$MPI_BUILD_HOME,${MPI_BUILD_HOME},`
#echo $trun
-set nrun = `echo ${trun} | sed -e sz\$MPI_HOMEz${MPI_HOME}z`
+set nrun = `echo ${trun} | sed -e s,\$MPI_HOME,${MPI_HOME},`
#echo $nrun
-set qrun = `echo ${nrun} | sed -e sz\$PETSC_DIRz${PETSC_DIR}z`
+set qrun = `echo ${nrun} | sed -e s,\$PETSC_DIR,${PETSC_DIR},`
#echo $qrun

#echo $qrun $*
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18071,6 +18071,10 @@ with pkgs;

nauty = callPackage ../applications/science/math/nauty {};

petscComplex = callPackage ../development/libraries/science/math/petsc { scalarType="complex"; };
petscReal = callPackage ../development/libraries/science/math/petsc { scalarType="real"; };
petsc = petscComplex;

sage = callPackage ../applications/science/math/sage { };

suitesparse_4_2 = callPackage ../development/libraries/science/math/suitesparse/4.2.nix { };
Expand Down

0 comments on commit ee78e6d

Please sign in to comment.