commit:     c8e6ee71ad4d6e9e6804f56a1e56eab18426284b
Author:     Tiziano Müller <dev-zero <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 22 08:40:02 2016 +0000
Commit:     Tiziano Müller <dev-zero <AT> gentoo <DOT> org>
CommitDate: Fri Apr 22 08:40:02 2016 +0000
URL:        https://gitweb.gentoo.org/dev/dev-zero.git/commit/?id=c8e6ee71

sci-chemistry/cp2k: add mpi support

 sci-chemistry/cp2k/cp2k-3.0.ebuild | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/sci-chemistry/cp2k/cp2k-3.0.ebuild 
b/sci-chemistry/cp2k/cp2k-3.0.ebuild
index b7daf1b..8a047fe 100644
--- a/sci-chemistry/cp2k/cp2k-3.0.ebuild
+++ b/sci-chemistry/cp2k/cp2k-3.0.ebuild
@@ -18,13 +18,17 @@ SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"
 LICENSE="GPL-2"
 SLOT="0"
 KEYWORDS="~amd64"
-IUSE="+fftw +libint +libxc +openmp"
+IUSE="+fftw +libint +libxc +openmp mpi"
 
 RDEPEND="virtual/blas
        fftw? ( openmp? ( sci-libs/fftw:3.0=[fortran,openmp] )
                !openmp? ( sci-libs/fftw:3.0=[fortran,threads] ) )
        libint? ( sci-libs/libint:1 )
-       libxc? ( =sci-libs/libxc-2.2*[fortran] )"
+       libxc? ( =sci-libs/libxc-2.2*[fortran] )
+       mpi? (
+               virtual/mpi[fortran]
+               virtual/scalapack
+               )"
 DEPEND="${RDEPEND}
        virtual/pkgconfig
        ${PYTHON_DEPS}"
@@ -35,14 +39,22 @@ pkg_setup() {
 }
 
 src_configure() {
+       incs=("-I/usr/include")
        libs=()
-       pkgs=("lapack")
+       pkgs=()
 
        if use openmp ; then
                append-fflags -fopenmp
                append-ldflags -fopenmp
        fi
 
+       if use mpi ; then
+               append-cppflags -D__parallel -D__SCALAPACK -D__MPI_VERSION=3
+               pkgs+=("scalapack")
+       else
+               pkgs+=("lapack")
+       fi
+
        if use fftw ; then
                append-cppflags -D__FFTW3
 
@@ -62,16 +74,24 @@ src_configure() {
                libs+=("-lxc" "-lxcf90")
        fi
 
+       CC=$(tc-getCC)
+       FC=$(tc-getFC)
+
+       if use mpi ; then
+               CC=mpicc
+               FC=mpifort
+       fi
+
        # /usr/include must be included explicitly to have gfortran look for 
.mod-files there
        cat > arch/custom.gentoo << EOF
-CC         = $(tc-getCC)
+CC         = ${CC}
 # empty CPP var makes it use the compiler directly instead of two-step
 CPP        =
-FC         = $(tc-getFC)
-LD         = $(tc-getFC)
+FC         = ${FC}
+LD         = ${FC}
 AR         = $(tc-getAR) -r
-CPPFLAGS   = ${CPPFLAGS} $(pkg-config --cflags ${pkgs[*]})
-FCFLAGS    = -ffree-form -ffree-line-length-none ${CPPFLAGS} -I/usr/include 
$(pkg-config --cflags ${pkgs[*]}) ${FCFLAGS}
+CPPFLAGS   = ${CPPFLAGS} ${incs[*]} $(pkg-config --cflags ${pkgs[*]})
+FCFLAGS    = -ffree-form -ffree-line-length-none ${CPPFLAGS} ${incs[*]} 
$(pkg-config --cflags ${pkgs[*]}) ${FCFLAGS}
 LDFLAGS    = ${LDFLAGS}
 LIBS       = $(pkg-config --libs ${pkgs[*]}) ${libs[*]}
 DATA_DIR   = ${EPREFIX}/usr/share/cp2k

Reply via email to