From 949766d92eade0919a2fe2bdb95de21e7f990d91 Mon Sep 17 00:00:00 2001 From: gmatteo Date: Wed, 12 Oct 2016 00:22:46 +0200 Subject: Abinit: Added package(s) (#1995) * First version of Abinit package * Ignore *.swp files * Add libxc, etsf_io packages * AtomPaw package * Make Abinit depend on mpi@2: and external version of libxc, netcdf, hdf5, etsf_io * etsf_io: install Fortran modules in prefix.include * Remove etsf_io from abinit requirements * Add libxc2.2.1 (required by Abinit and atompaw) * Cleanup * Run make check * Cleanup * Use ld_flags instead of hard-coded libs, fix pep8, add copyright * Put scalapack before lapackblas --- .gitignore | 1 + var/spack/repos/builtin/packages/abinit/package.py | 175 +++++++++++++++++++++ .../repos/builtin/packages/atompaw/package.py | 63 ++++++++ .../repos/builtin/packages/etsf_io/package.py | 67 ++++++++ var/spack/repos/builtin/packages/libxc/package.py | 1 + 5 files changed, 307 insertions(+) create mode 100644 var/spack/repos/builtin/packages/abinit/package.py create mode 100644 var/spack/repos/builtin/packages/atompaw/package.py create mode 100644 var/spack/repos/builtin/packages/etsf_io/package.py diff --git a/.gitignore b/.gitignore index f25ac615fa..a451f9e14e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ /share/spack/modules /share/spack/lmod /TAGS +*.swp /htmlcov .coverage #* diff --git a/var/spack/repos/builtin/packages/abinit/package.py b/var/spack/repos/builtin/packages/abinit/package.py new file mode 100644 index 0000000000..76fa044982 --- /dev/null +++ b/var/spack/repos/builtin/packages/abinit/package.py @@ -0,0 +1,175 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## +# +# Author: Matteo Giantomassi +# Date: October 11, 2016 + +from spack import * + + +class Abinit(Package): + """ABINIT is a package whose main program allows one to find the total + energy, charge density and electronic structure of systems made of + electrons and nuclei (molecules and periodic solids) within + Density Functional Theory (DFT), using pseudopotentials and a planewave + or wavelet basis. ABINIT also includes options to optimize the geometry + according to the DFT forces and stresses, or to perform molecular dynamics + simulations using these forces, or to generate dynamical matrices, + Born effective charges, and dielectric tensors, based on Density-Functional + Perturbation Theory, and many more properties. Excited states can be + computed within the Many-Body Perturbation Theory (the GW approximation and + the Bethe-Salpeter equation), and Time-Dependent Density Functional Theory + (for molecules). In addition to the main ABINIT code, different utility + programs are provided. + """ + + homepage = "http://www.abinit.org" + url = "http://ftp.abinit.org/abinit-8.0.8b.tar.gz" + + # Versions before 8.0.8b are not supported. + version("8.0.8b", "abc9e303bfa7f9f43f95598f87d84d5d") + + variant('mpi', default=True, + description='Builds with MPI support. Requires MPI2+') + variant('openmp', default=False, + description='Enables OpenMP threads. Use threaded FFTW3') + variant('scalapack', default=False, + description='Enables scalapack support. Requires MPI') + # variant('elpa', default=False, + # description='Uses elpa instead of scalapack. Requires MPI') + + # TODO: To be tested. + # It was working before the last `git pull` but now all tests crash. + # For the time being, the default is netcdf3 and the internal fallbacks + variant('hdf5', default=False, + description='Enables HDF5+Netcdf4 with MPI. WARNING: experimental') + + # Add dependencies + # currently one cannot forward options to virtual packages, see #1712. + # depends_on("blas", when="~openmp") + # depends_on("blas+openmp", when="+openmp") + depends_on('blas') + depends_on("lapack") + + # Require MPI2+ + depends_on("mpi@2:", when="+mpi") + + depends_on("scalapack", when="+scalapack+mpi") + # depends_on("elpa", when="+elpa+mpi~openmp") + # depends_on("elpa+openmp", when="+elpa+mpi+openmp") + + depends_on("fftw+float", when="~openmp") + depends_on("fftw+float+openmp", when="+openmp") + + depends_on("netcdf-fortran", when="+hdf5") + depends_on("hdf5+mpi", when='+mpi+hdf5') # required for NetCDF-4 support + + # pin libxc version + depends_on("libxc@2.2.1") + + def validate(self, spec): + """ + Checks if incompatible variants have been activated at the same time + + :param spec: spec of the package + :raises RuntimeError: in case of inconsistencies + """ + error = 'you cannot ask for \'+{variant}\' when \'+mpi\' is not active' + + if '+scalapack' in spec and '~mpi' in spec: + raise RuntimeError(error.format(variant='scalapack')) + + if '+elpa' in spec and ('~mpi' in spec or '~scalapack' in spec): + raise RuntimeError(error.format(variant='elpa')) + + def install(self, spec, prefix): + self.validate(spec) + + options = ['--prefix=%s' % prefix] + oapp = options.append + + if '+mpi' in spec: + # MPI version: + # let the configure script auto-detect MPI support from mpi_prefix + oapp("--with-mpi-prefix=%s" % spec["mpi"].prefix) + oapp("--enable-mpi=yes") + oapp("--enable-mpi-io=yes") + + # Activate OpenMP in Abinit Fortran code. + if '+openmp' in spec: + oapp('--enable-openmp=yes') + + # BLAS/LAPACK + if '+scalapack' in spec: + oapp("--with-linalg-flavor=custom+scalapack") + linalg = (spec['scalapack'].scalapack_libs + + spec['lapack'].lapack_libs + spec['blas'].blas_libs) + + # elif '+elpa' in spec: + else: + oapp("--with-linalg-flavor=custom") + linalg = spec['lapack'].lapack_libs + spec['blas'].blas_libs + + oapp("--with-linalg-libs=%s" % linalg.ld_flags) + + # FFTW3: use sequential or threaded version if +openmp + fftflavor, fftlibs = "fftw3", "-lfftw3 -lfftw3f" + if '+openmp' in spec: + fftflavor = "fftw3-threads" + fftlibs = "-lfftw3_omp -lfftw3 -lfftw3f" + + options.extend([ + "--with-fft-flavor=%s" % fftflavor, + "--with-fft-incs=-I%s" % spec["fftw"].prefix.include, + "--with-fft-libs=-L%s %s" % (spec["fftw"].prefix.lib, fftlibs), + ]) + oapp("--with-dft-flavor=atompaw+libxc") + + # LibXC library + options.extend([ + "with_libxc_incs=-I%s" % spec["libxc"].prefix.include, + "with_libxc_libs=-L%s -lxcf90 -lxc" % spec["libxc"].prefix.lib, + ]) + + # Netcdf4/HDF5 + if "+hdf5" in spec: + oapp("--with-trio-flavor=netcdf") + hdf_libs = "-L%s -lhdf5_hl -lhdf5" % spec["hdf5"].prefix.lib + options.extend([ + "--with-netcdf-incs=-I%s" % ( + spec["netcdf-fortran"].prefix.include), + "--with-netcdf-libs=-L%s -lnetcdff -lnetcdf %s" % ( + spec["netcdf-fortran"].prefix.lib, hdf_libs), + ]) + else: + # Use internal fallbacks (netcdf3) + oapp("--with-trio-flavor=netcdf-fallback") + + configure(*options) + make() + + # make("check") + # make("tests_in") + make("install") diff --git a/var/spack/repos/builtin/packages/atompaw/package.py b/var/spack/repos/builtin/packages/atompaw/package.py new file mode 100644 index 0000000000..17d0ef8209 --- /dev/null +++ b/var/spack/repos/builtin/packages/atompaw/package.py @@ -0,0 +1,63 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + +from spack import * + + +class Atompaw(Package): + """A Projector Augmented Wave (PAW) code for generating + atom-centered functions. + + Official website: http://pwpaw.wfu.edu + + User's guide: ~/doc/atompaw-usersguide.pdf + """ + homepage = "http://users.wfu.edu/natalie/papers/pwpaw/man.html" + url = "http://users.wfu.edu/natalie/papers/pwpaw/atompaw-4.0.0.13.tar.gz" + + version('4.0.0.13', 'af4a042380356f6780183c4b325aad1d') + version('3.1.0.3', 'c996a277e11707887177f47bbb229aa6') + + depends_on("lapack") + depends_on("blas") + + # pin libxc version + depends_on("libxc@2.2.1") + + def install(self, spec, prefix): + options = ['--prefix=%s' % prefix] + + linalg = spec['lapack'].lapack_libs + spec['blas'].blas_libs + options.extend([ + "--with-linalg-libs=%s" % linalg.ld_flags, + "--enable-libxc", + "--with-libxc-incs=-I%s" % spec["libxc"].prefix.include, + "--with-libxc-libs=-L%s -lxcf90 -lxc" % spec["libxc"].prefix.lib, + ]) + + configure(*options) + make(parallel=False) # parallel build fails + make("check") + make("install") diff --git a/var/spack/repos/builtin/packages/etsf_io/package.py b/var/spack/repos/builtin/packages/etsf_io/package.py new file mode 100644 index 0000000000..c1e6f2eded --- /dev/null +++ b/var/spack/repos/builtin/packages/etsf_io/package.py @@ -0,0 +1,67 @@ +############################################################################## +# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC. +# Produced at the Lawrence Livermore National Laboratory. +# +# This file is part of Spack. +# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved. +# LLNL-CODE-647188 +# +# For details, see https://github.com/llnl/spack +# Please also see the LICENSE file for our notice and the LGPL. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License (as +# published by the Free Software Foundation) version 2.1, February 1999. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and +# conditions of the GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +############################################################################## + +from spack import * + + +class EtsfIo(Package): + """ETSF_IO is a library implementing the Nanoquanta/ETSF file + format specifications. + + ETSF_IO enables an architecture-independent exchange of crystallographic + data, electronic wavefunctions, densities and potentials, as well as + spectroscopic data. It is meant to be used by quantum-physical and + quantum-chemical applications relying upon Density Functional Theory (DFT). + """ + + homepage = "http://www.etsf.eu/resources/software/libraries_and_tools" + url = "https://launchpad.net/etsf-io/1.0/1.0.4/+download/etsf_io-1.0.4.tar.gz" + + version('1.0.4', '32d0f7143278bd925b334c69fa425da1') + + depends_on("netcdf-fortran") + depends_on("hdf5+mpi~cxx", when='+mpi') # required for NetCDF-4 support + + def install(self, spec, prefix): + options = ['--prefix=%s' % prefix] + oapp = options.append + + # Specify installation directory for Fortran module files + # Default is [INCLUDEDIR/FC_TYPE] + oapp("--with-moduledir=%s" % prefix.include) + + # Netcdf4/HDF + hdf_libs = "-L%s -lhdf5_hl -lhdf5" % spec["hdf5"].prefix.lib + options.extend([ + "--with-netcdf-incs=-I%s" % spec["netcdf-fortran"].prefix.include, + "--with-netcdf-libs=-L%s -lnetcdff -lnetcdf %s" % ( + spec["netcdf-fortran"].prefix.lib, hdf_libs), + ]) + + configure(*options) + + make() + make("check") + make("install") diff --git a/var/spack/repos/builtin/packages/libxc/package.py b/var/spack/repos/builtin/packages/libxc/package.py index fe82613ce2..d773395e6c 100644 --- a/var/spack/repos/builtin/packages/libxc/package.py +++ b/var/spack/repos/builtin/packages/libxc/package.py @@ -34,6 +34,7 @@ class Libxc(Package): version('3.0.0', '8227fa3053f8fc215bd9d7b0d36de03c') version('2.2.2', 'd9f90a0d6e36df6c1312b6422280f2ec') + version('2.2.1', '38dc3a067524baf4f8521d5bb1cd0b8f') def install(self, spec, prefix): # Optimizations for the Intel compiler, suggested by CP2K -- cgit v1.2.3-60-g2f50