mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
Merge pull request #128856 from cburstedde/package-petsc-p4est
petsc: refactor using mpi and p4est
This commit is contained in:
commit
13b3e91794
2 changed files with 57 additions and 28 deletions
|
@ -1,15 +1,19 @@
|
||||||
{ lib, stdenv, fetchurl, cmake, gfortran, blas, lapack, mpi, petsc, python3 }:
|
{ lib, stdenv, fetchurl, cmake, gfortran, blas, lapack, mpi, petsc, python3 }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
name = "getdp-${version}";
|
pname = "getdp";
|
||||||
version = "3.3.0";
|
version = "3.3.0";
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = "http://getdp.info/src/getdp-${version}-source.tgz";
|
url = "http://getdp.info/src/getdp-${version}-source.tgz";
|
||||||
sha256 = "1pfviy2bw8z5y6c15czvlvyjjg9pvpgrj9fr54xfi2gmvs7zkgpf";
|
sha256 = "1pfviy2bw8z5y6c15czvlvyjjg9pvpgrj9fr54xfi2gmvs7zkgpf";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake gfortran ];
|
inherit (petsc) mpiSupport;
|
||||||
buildInputs = [ blas lapack mpi petsc python3 ];
|
nativeBuildInputs = [ cmake python3 ];
|
||||||
|
buildInputs = [ gfortran blas lapack petsc ]
|
||||||
|
++ lib.optional mpiSupport mpi
|
||||||
|
;
|
||||||
|
cmakeFlags = lib.optional mpiSupport "-DENABLE_MPI=1";
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A General Environment for the Treatment of Discrete Problems";
|
description = "A General Environment for the Treatment of Discrete Problems";
|
||||||
|
|
|
@ -1,4 +1,20 @@
|
||||||
{ lib, stdenv , darwin , fetchurl , blas , gfortran , lapack , python }:
|
{ lib
|
||||||
|
, stdenv
|
||||||
|
, fetchurl
|
||||||
|
, darwin
|
||||||
|
, gfortran
|
||||||
|
, python3
|
||||||
|
, blas
|
||||||
|
, lapack
|
||||||
|
, mpi # generic mpi dependency
|
||||||
|
, openssh # required for openmpi tests
|
||||||
|
, petsc-withp4est ? true
|
||||||
|
, p4est
|
||||||
|
, zlib # propagated by p4est but required by petsc
|
||||||
|
}:
|
||||||
|
|
||||||
|
# This version of PETSc does not support a non-MPI p4est build
|
||||||
|
assert petsc-withp4est -> p4est.mpiSupport;
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "petsc";
|
pname = "petsc";
|
||||||
|
@ -9,44 +25,53 @@ stdenv.mkDerivation rec {
|
||||||
sha256 = "04vy3qyakikslc58qyv8c9qrwlivix3w6znc993i37cvfg99dch9";
|
sha256 = "04vy3qyakikslc58qyv8c9qrwlivix3w6znc993i37cvfg99dch9";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ blas gfortran gfortran.cc.lib lapack python ];
|
mpiSupport = !withp4est || p4est.mpiSupport;
|
||||||
|
withp4est = petsc-withp4est;
|
||||||
|
|
||||||
# Upstream does some hot she-py-bang stuff, this change streamlines that
|
nativeBuildInputs = [ python3 gfortran ];
|
||||||
# process. The original script in upstream is both a shell script and a
|
buildInputs = [ blas lapack ]
|
||||||
# python script, where the shellscript just finds a suitable python
|
++ lib.optional mpiSupport mpi
|
||||||
# interpreter to execute the python script. See
|
++ lib.optional (mpiSupport && mpi.pname == "openmpi") openssh
|
||||||
# https://github.com/NixOS/nixpkgs/pull/89299#discussion_r450203444
|
++ lib.optional withp4est p4est
|
||||||
# for more details.
|
;
|
||||||
prePatch = ''
|
|
||||||
substituteInPlace configure \
|
prePatch = lib.optionalString stdenv.isDarwin ''
|
||||||
--replace /bin/sh /usr/bin/python
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
|
||||||
substituteInPlace config/install.py \
|
substituteInPlace config/install.py \
|
||||||
--replace /usr/bin/install_name_tool ${darwin.cctools}/bin/install_name_tool
|
--replace /usr/bin/install_name_tool ${darwin.cctools}/bin/install_name_tool
|
||||||
'';
|
'';
|
||||||
|
|
||||||
preConfigure = ''
|
preConfigure = ''
|
||||||
export FC="${gfortran}/bin/gfortran" F77="${gfortran}/bin/gfortran"
|
export FC="${gfortran}/bin/gfortran" F77="${gfortran}/bin/gfortran"
|
||||||
patchShebangs .
|
patchShebangs ./lib/petsc/bin
|
||||||
configureFlagsArray=(
|
configureFlagsArray=(
|
||||||
$configureFlagsArray
|
$configureFlagsArray
|
||||||
"--CC=$CC"
|
${if !mpiSupport then ''
|
||||||
"--with-cxx=$CXX"
|
"--with-mpi=0"
|
||||||
"--with-fc=$FC"
|
'' else ''
|
||||||
"--with-mpi=0"
|
"--CC=mpicc"
|
||||||
"--with-blas-lib=[${blas}/lib/libblas.so,${gfortran.cc.lib}/lib/libgfortran.a]"
|
"--with-cxx=mpicxx"
|
||||||
"--with-lapack-lib=[${lapack}/lib/liblapack.so,${gfortran.cc.lib}/lib/libgfortran.a]"
|
"--with-fc=mpif90"
|
||||||
|
"--with-mpi=1"
|
||||||
|
''}
|
||||||
|
${if withp4est then ''
|
||||||
|
"--with-p4est=1"
|
||||||
|
"--with-zlib-include=${zlib.dev}/include"
|
||||||
|
"--with-zlib-lib=-L${zlib}/lib -lz"
|
||||||
|
'' else ""}
|
||||||
|
"--with-blas=1"
|
||||||
|
"--with-lapack=1"
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
configureScript = "python ./configure";
|
||||||
|
|
||||||
|
enableParallelBuilding = true;
|
||||||
|
doCheck = stdenv.hostPlatform == stdenv.buildPlatform;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = ''
|
description = "Portable Extensible Toolkit for Scientific computation";
|
||||||
Library of linear algebra algorithms for solving partial differential
|
|
||||||
equations
|
|
||||||
'';
|
|
||||||
homepage = "https://www.mcs.anl.gov/petsc/index.html";
|
homepage = "https://www.mcs.anl.gov/petsc/index.html";
|
||||||
license = licenses.bsd2;
|
license = licenses.bsd2;
|
||||||
maintainers = with maintainers; [ wucke13 ];
|
maintainers = with maintainers; [ wucke13 cburstedde ];
|
||||||
platforms = platforms.all;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue