From 1f3f1100b321356ca765cfda7d3f40b350653519 Mon Sep 17 00:00:00 2001
From: Daniele Cesarini <d.cesarini@cineca.it>
Date: Tue, 25 Jan 2022 19:35:09 +0100
Subject: New packages: BigDFT suite (#26853)

---
 .../repos/builtin/packages/bigdft-atlab/package.py |  85 ++++++++
 .../repos/builtin/packages/bigdft-chess/package.py | 120 +++++++++++
 .../repos/builtin/packages/bigdft-core/package.py  | 134 +++++++++++++
 .../builtin/packages/bigdft-futile/package.py      | 100 ++++++++++
 .../bigdft-libabinit/m_libpaw_mpi.F90.patch        | 222 +++++++++++++++++++++
 .../builtin/packages/bigdft-libabinit/package.py   |  86 ++++++++
 .../builtin/packages/bigdft-psolver/package.py     | 113 +++++++++++
 .../repos/builtin/packages/bigdft-spred/package.py | 107 ++++++++++
 .../repos/builtin/packages/bigdft-suite/package.py |  39 ++++
 .../repos/builtin/packages/libgain/package.py      |  25 +++
 .../repos/builtin/packages/py-bigdft/package.py    |  31 +++
 11 files changed, 1062 insertions(+)
 create mode 100644 var/spack/repos/builtin/packages/bigdft-atlab/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-chess/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-core/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-futile/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-libabinit/m_libpaw_mpi.F90.patch
 create mode 100644 var/spack/repos/builtin/packages/bigdft-libabinit/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-psolver/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-spred/package.py
 create mode 100644 var/spack/repos/builtin/packages/bigdft-suite/package.py
 create mode 100644 var/spack/repos/builtin/packages/libgain/package.py
 create mode 100644 var/spack/repos/builtin/packages/py-bigdft/package.py

diff --git a/var/spack/repos/builtin/packages/bigdft-atlab/package.py b/var/spack/repos/builtin/packages/bigdft-atlab/package.py
new file mode 100644
index 0000000000..5fc6f832b8
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-atlab/package.py
@@ -0,0 +1,85 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftAtlab(AutotoolsPackage):
+    """BigDFT-atlab: library for ATomic related operations."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+
+    variant('mpi',       default=True,  description='Enable MPI support')
+    variant('openmp',    default=True,  description='Enable OpenMP support')
+    variant('openbabel', default=False, description='Enable detection of openbabel compilation')
+
+    depends_on('mpi',       when='+mpi')
+    depends_on('openbabel', when='+openbabel')
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers), when='@{0}'.format(vers))
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "atlab"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        openmp_flag = []
+        if '+openmp' in spec:
+            openmp_flag.append(self.compiler.openmp_flag)
+
+        args = [
+            "FCFLAGS=%s"            % " ".join(openmp_flag),
+            "--with-futile-libs=%s" % spec['bigdft-futile'].prefix.lib,
+            "--with-futile-incs=%s" % spec['bigdft-futile'].prefix.include,
+            "--with-moduledir=%s"   % prefix.include,
+            "--prefix=%s"           % prefix,
+            "--without-etsf-io",
+        ]
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        if '+openmp' in spec:
+            args.append("--with-openmp")
+        else:
+            args.append("--without-openmp")
+
+        if '+openbabel' in spec:
+            args.append("--enable-openbabel")
+            args.append("--with-openbabel-libs=%s" % spec['openbabel'].prefix.lib)
+            args.append("--with-openbabel-incs=%s" % spec['openbabel'].prefix.include)
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libatlab-*', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-chess/package.py b/var/spack/repos/builtin/packages/bigdft-chess/package.py
new file mode 100644
index 0000000000..d975c822af
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-chess/package.py
@@ -0,0 +1,120 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftChess(AutotoolsPackage, CudaPackage):
+    """BigDFT-CheSS: A module for performing Fermi Operator Expansions
+       via Chebyshev Polynomials."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    variant('mpi',       default=True,  description='Enable MPI support')
+    variant('openmp',    default=True,  description='Enable OpenMP support')
+    variant('scalapack', default=True,  description='Enable SCALAPACK support')
+    variant('ntpoly',    default=False, description='Option to use NTPoly')
+    # variant('minpack', default=False,  description='Give the link-line for MINPACK')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+
+    depends_on('blas')
+    depends_on('lapack')
+    depends_on('py-pyyaml')
+    depends_on('mpi',       when='+mpi')
+    depends_on('scalapack', when='+scalapack')
+    depends_on('ntpoly',    when='+ntpoly')
+    # depends_on('netlib-minpack', when='+minpack')
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers), when='@{0}'.format(vers))
+    for vers in ['1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-atlab@{0}'.format(vers),  when='@{0}'.format(vers))
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "chess"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        python_version = spec['python'].version.up_to(2)
+        pyyaml = join_path(spec['py-pyyaml'].prefix.lib,
+                           'python{0}'.format(python_version))
+
+        openmp_flag = []
+        if '+openmp' in spec:
+            openmp_flag.append(self.compiler.openmp_flag)
+
+        linalg = []
+        if '+scalapack' in spec:
+            linalg.append(spec['scalapack'].libs.ld_flags)
+
+        args = [
+            "FCFLAGS=%s"            % " ".join(openmp_flag),
+            "--with-ext-linalg=%s"  % " ".join(linalg),
+            "--with-pyyaml-path=%s" % pyyaml,
+            "--with-futile-libs=%s" % spec['bigdft-futile'].prefix.lib,
+            "--with-futile-incs=%s" % spec['bigdft-futile'].headers.include_flags,
+            "--with-moduledir=%s"   % prefix.include,
+            "--prefix=%s"           % prefix,
+            "--without-etsf-io",
+        ]
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        if '+openmp' in spec:
+            args.append("--with-openmp")
+        else:
+            args.append("--without-openmp")
+
+        if spec.satisfies('@1.8.3:') or spec.satisfies('@develop'):
+            args.append("--with-atlab-libs=%s" % spec['bigdft-atlab'].prefix.lib)
+
+        if '+cuda' in spec:
+            args.append("--enable-cuda-gpu")
+            args.append("--with-cuda-path=%s" % spec['cuda'].prefix)
+            args.append("--with-cuda-libs=%s" % spec['cuda'].libs.link_flags)
+
+        if '+minpack' in spec:
+            args.append("--with-minpack")
+
+        if '+ntpoly' in spec:
+            args.append("--enable-ntpoly")
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libCheSS-*', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-core/package.py b/var/spack/repos/builtin/packages/bigdft-core/package.py
new file mode 100644
index 0000000000..6d5df88413
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-core/package.py
@@ -0,0 +1,134 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftCore(AutotoolsPackage, CudaPackage):
+    """BigDFT-core: the core components of BigDFT, an electronic structure calculation
+       based on Daubechies wavelets."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    variant('mpi',       default=True,  description='Enable MPI support')
+    variant('openmp',    default=True,  description='Enable OpenMP support')
+    variant('scalapack', default=True,  description='Enable SCALAPACK support')
+    variant('openbabel', default=False, description='Enable detection of openbabel compilation')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+
+    depends_on('blas')
+    depends_on('lapack')
+    depends_on('py-pyyaml')
+    depends_on('libgain')
+    depends_on('mpi',          when='+mpi')
+    depends_on('scalapack',    when='+scalapack')
+    depends_on('openbabel',    when='+openbabel')
+    depends_on('libxc@:2.2.2', when='@:1.9.1')
+    depends_on('libxc@:4.3.4', when='@1.9.2:')
+    depends_on('libxc@:4.3.4', when='@develop')
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers),    when='@{0}'.format(vers))
+        depends_on('bigdft-chess@{0}'.format(vers),     when='@{0}'.format(vers))
+        depends_on('bigdft-psolver@{0}'.format(vers),   when='@{0}'.format(vers))
+        depends_on('bigdft-libabinit@{0}'.format(vers), when='@{0}'.format(vers))
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "bigdft"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        python_version = spec['python'].version.up_to(2)
+        pyyaml = join_path(spec['py-pyyaml'].prefix.lib,
+                           'python{0}'.format(python_version))
+
+        openmp_flag = []
+        if '+openmp' in spec:
+            openmp_flag.append(self.compiler.openmp_flag)
+
+        linalg = []
+        if '+scalapack' in spec:
+            linalg.append(spec['scalapack'].libs.ld_flags)
+        linalg.append(spec['lapack'].libs.ld_flags)
+        linalg.append(spec['blas'].libs.ld_flags)
+
+        args = [
+            "FCFLAGS=%s"               % " ".join(openmp_flag),
+            "--with-ext-linalg=%s"     % " ".join(linalg),
+            "--with-pyyaml-path=%s"    % pyyaml,
+            "--with-futile-libs=%s"    % spec['bigdft-futile'].prefix.lib,
+            "--with-futile-incs=%s"    % spec['bigdft-futile'].headers.include_flags,
+            "--with-chess-libs=%s"     % spec['bigdft-chess'].prefix.lib,
+            "--with-chess-incs=%s"     % spec['bigdft-chess'].headers.include_flags,
+            "--with-psolver-libs=%s"   % spec['bigdft-psolver'].prefix.lib,
+            "--with-psolver-incs=%s"   % spec['bigdft-psolver'].headers.include_flags,
+            "--with-libABINIT-libs=%s" % spec['bigdft-libabinit'].prefix.lib,
+            "--with-libABINIT-incs=%s" % spec['bigdft-libabinit'].headers.include_flags,
+            "--with-libgain-libs=%s"   % spec['libgain'].libs.ld_flags,
+            "--with-libgain-incs=%s"   % spec['libgain'].headers.include_flags,
+            "--with-libxc-libs=%s %s"  % (spec['libxc'].libs.ld_flags,
+                                          spec['libxc'].libs.ld_flags + "f90"),
+            "--with-libxc-incs=%s"     % spec['libxc'].headers.include_flags,
+            "--with-moduledir=%s" % prefix.include,
+            "--prefix=%s" % prefix,
+            "--without-etsf-io",
+        ]
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        if '+openmp' in spec:
+            args.append("--with-openmp")
+        else:
+            args.append("--without-openmp")
+
+        if '+cuda' in spec:
+            args.append("--enable-opencl")
+            args.append("--with-ocl-path=%s"  % spec['cuda'].prefix)
+            args.append("--enable-cuda-gpu")
+            args.append("--with-cuda-path=%s" % spec['cuda'].prefix)
+            args.append("--with-cuda-libs=%s" % spec['cuda'].libs.link_flags)
+
+        if '+openbabel' in spec:
+            args.append("--enable-openbabel")
+            args.append("--with-openbabel-libs=%s" % spec['openbabel'].prefix.lib)
+            args.append("--with-openbabel-incs=%s" % spec['openbabel'].prefix.include)
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libbigdft-*', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-futile/package.py b/var/spack/repos/builtin/packages/bigdft-futile/package.py
new file mode 100644
index 0000000000..936b9f301a
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-futile/package.py
@@ -0,0 +1,100 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftFutile(AutotoolsPackage, CudaPackage):
+    """BigDFT-futile: a library handling most common FORTRAN low-level operations,
+       like memory managment, profiling routines, I/O operations.
+       It also supports yaml output and parsing for fortran programs.
+       It also provides wrappers routines to MPI and linear algebra operations.
+       This library is intensively used in BigDFT packages."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    variant('mpi',    default=True, description='Enable MPI support')
+    variant('openmp', default=True, description='Enable OpenMP support')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+
+    depends_on('blas')
+    depends_on('lapack')
+    depends_on('libyaml')
+    depends_on('py-pyyaml')
+    depends_on('mpi', when='+mpi')
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "futile"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        linalg = [spec['blas'].libs.ld_flags, spec['lapack'].libs.ld_flags]
+
+        python_version = spec['python'].version.up_to(2)
+        pyyaml = join_path(spec['py-pyyaml'].prefix.lib,
+                           'python{0}'.format(python_version))
+
+        openmp_flag = []
+        if '+openmp' in spec:
+            openmp_flag.append(self.compiler.openmp_flag)
+
+        args = [
+            "FCFLAGS=%s"            % " ".join(openmp_flag),
+            "--with-ext-linalg=%s"  % " ".join(linalg),
+            "--with-yaml-path=%s"   % spec['libyaml'].prefix,
+            "--with-pyyaml-path=%s" % pyyaml,
+            "--prefix=%s" % prefix,
+        ]
+
+        if '+openmp' in spec:
+            args.append("--with-openmp")
+        else:
+            args.append("--without-openmp")
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        if '+cuda' in spec:
+            args.append("--enable-opencl")
+            args.append("--with-ocl-path=%s"  % spec['cuda'].prefix)
+            args.append("--enable-cuda-gpu")
+            args.append("--with-cuda-path=%s" % spec['cuda'].prefix)
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libfutile-*', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-libabinit/m_libpaw_mpi.F90.patch b/var/spack/repos/builtin/packages/bigdft-libabinit/m_libpaw_mpi.F90.patch
new file mode 100644
index 0000000000..4ee3c1df31
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-libabinit/m_libpaw_mpi.F90.patch
@@ -0,0 +1,222 @@
+--- a/libABINIT/src/libpaw/m_libpaw_mpi.F90
++++ b/libABINIT/src/libpaw/m_libpaw_mpi.F90
+@@ -54,6 +54,24 @@
+  integer,public,parameter :: xpaw_mpi_comm_null = 0
+ #endif
+ 
++ type xpaw_mpi_attr
++   integer :: attr_data
++ end type
++
++ interface xpaw_mpi_attr
++   module procedure new_xpaw_mpi_attr
++ end interface
++
++ interface mod
++   module procedure mod_xpaw_mpi_attr
++ end interface
++
++#ifdef HAVE_MPI
++ type(xpaw_mpi_attr),public,parameter :: xpaw_mpi_tag_ub = xpaw_mpi_attr(MPI_TAG_UB)
++#else
++ integer,public,parameter :: xpaw_mpi_tag_ub = 1
++#endif
++
+ !----------------------------------------------------------------------
+ !MPI public procedures.
+ 
+@@ -180,6 +198,32 @@
+ CONTAINS  !===========================================================
+ !!***
+ 
++function new_xpaw_mpi_attr(key_val)
++  type(xpaw_mpi_attr) :: new_xpaw_mpi_attr
++  integer, intent(in) :: key_val
++!Local variables-------------------
++  integer :: mpierr
++#ifdef HAVE_MPI
++  integer :: attribute_val
++  logical :: lflag
++#endif
++
++  ! Deprecated in MPI2 but not all MPI2 implementations provide MPI_Comm_get_attr !
++  call MPI_ATTR_GET(xpaw_mpi_world, key_val, attribute_val, lflag, mpierr)
++  !call MPI_Comm_get_attr(xpaw_mpi_world, key_val, attribute_val, lflag, mpierr)
++
++  if (lflag) new_xpaw_mpi_attr%attr_data = attribute_val
++end function
++
++
++function mod_xpaw_mpi_attr(a, p)
++  integer :: mod_xpaw_mpi_attr
++  integer, intent(in) :: a
++  type(xpaw_mpi_attr), intent(in) :: p
++
++  mod_xpaw_mpi_attr = mod(a, p%attr_data)
++end function
++
+ !!****f* m_libpaw_mpi/xpaw_mpi_abort
+ !! NAME
+ !!  xpaw_mpi_abort
+@@ -2297,7 +2341,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_RECV(xval,n1,MPI_INTEGER,source,my_tag,spaceComm,MPI_STATUS_IGNORE,ier)
+  end if
+ #endif
+@@ -2358,7 +2402,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_RECV(xval,n1,MPI_DOUBLE_PRECISION,source,my_tag,spaceComm,MPI_STATUS_IGNORE,ier)
+  end if
+ #endif
+@@ -2419,7 +2463,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1) ; n2=size(xval,dim=2)
+-   my_tag=MOD(tag,MPI_TAG_UB)
++   my_tag=MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_RECV(xval,n1*n2,MPI_DOUBLE_PRECISION,source,my_tag,spaceComm,MPI_STATUS_IGNORE,ier)
+  end if
+ #endif
+@@ -2480,7 +2524,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1) ; n2=size(xval,dim=2) ; n3=size(xval,dim=3)
+-   my_tag=MOD(tag,MPI_TAG_UB)
++   my_tag=MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_RECV(xval,n1*n2*n3,MPI_DOUBLE_PRECISION,source,my_tag,spaceComm,MPI_STATUS_IGNORE,ier)
+  end if
+ #endif
+@@ -2541,7 +2585,7 @@
+  ierr=0
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+-   my_tag=MOD(tag,MPI_TAG_UB)
++   my_tag=MOD(tag,xpaw_mpi_tag_ub)
+    n1=size(xval)
+    call MPI_IRECV(xval,n1,MPI_INTEGER,source,my_tag,spaceComm,request,ier)
+    ierr=ier
+@@ -2604,7 +2648,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag=MOD(tag,MPI_TAG_UB)
++   my_tag=MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_IRECV(xval,n1,MPI_DOUBLE_PRECISION,source,my_tag,spaceComm,request,ier)
+    ierr=ier
+  end if
+@@ -2666,7 +2710,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1);n2=size(xval,dim=2)
+-   my_tag=MOD(tag,MPI_TAG_UB)
++   my_tag=MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_IRECV(xval,n1*n2,MPI_DOUBLE_PRECISION,source,my_tag,spaceComm,request,ier)
+    ierr=ier
+  end if
+@@ -2727,7 +2771,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_SEND(xval,n1,MPI_INTEGER,dest,my_tag,spaceComm,ier)
+  end if
+ #endif
+@@ -2785,7 +2829,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_SEND(xval,n1,MPI_DOUBLE_PRECISION,dest,my_tag,spaceComm,ier)
+  end if
+ #endif
+@@ -2843,7 +2887,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1) ; n2=size(xval,dim=2)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_SEND(xval,n1*n2,MPI_DOUBLE_PRECISION,dest,my_tag,spaceComm,ier)
+  end if
+ #endif
+@@ -2901,7 +2945,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1) ; n2=size(xval,dim=2) ; n3=size(xval,dim=3)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_SEND(xval,n1*n2*n3,MPI_DOUBLE_PRECISION,dest,my_tag,spaceComm,ier)
+  end if
+ #endif
+@@ -2961,7 +3005,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_ISEND(xval,n1,MPI_INTEGER,dest,my_tag,spaceComm,request,ier)
+    ierr=ier
+  end if
+@@ -3020,7 +3064,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_ISEND(xval,n1,MPI_DOUBLE_PRECISION,dest,my_tag,spaceComm,request,ier)
+    ierr=ier
+  end if
+@@ -3079,7 +3123,7 @@
+ #if defined HAVE_MPI
+  if (spaceComm /= xpaw_mpi_comm_self .and. spaceComm /= xpaw_mpi_comm_null) then
+    n1=size(xval,dim=1) ; n1=size(xval,dim=2)
+-   my_tag = MOD(tag,MPI_TAG_UB)
++   my_tag = MOD(tag,xpaw_mpi_tag_ub)
+    call MPI_ISEND(xval,n1*n2,MPI_DOUBLE_PRECISION,dest,my_tag,spaceComm,request,ier)
+    ierr=ier
+  end if
+@@ -3145,7 +3189,7 @@
+ #if defined HAVE_MPI
+  if (sender==recever.or.spaceComm==xpaw_mpi_comm_null.or.(n1==0)) return
+  call MPI_COMM_RANK(spaceComm,me,ier)
+- tag = MOD(n1,MPI_TAG_UB)
++ tag = MOD(n1,xpaw_mpi_tag_ub)
+  if (recever==me) then
+    call MPI_RECV(vrecv,n1,MPI_INTEGER,sender,tag,spaceComm,status,ier)
+  end if
+@@ -3212,7 +3256,7 @@
+ #if defined HAVE_MPI
+  if (sender==recever.or.spaceComm==xpaw_mpi_comm_null.or.(n1==0)) return
+  call MPI_COMM_RANK(spaceComm,me,ier)
+- tag = MOD(n1,MPI_TAG_UB)
++ tag = MOD(n1,xpaw_mpi_tag_ub)
+  if (recever==me) then
+    call MPI_RECV(vrecv,n1,MPI_DOUBLE_PRECISION,sender,tag,spaceComm,status,ier)
+  end if
+@@ -3279,7 +3323,7 @@
+ #if defined HAVE_MPI
+  if (sender==recever.or.spaceComm==xpaw_mpi_comm_null.or.(nt==0)) return
+  call MPI_COMM_RANK(spaceComm,me,ier)
+- tag=MOD(nt,MPI_TAG_UB)
++ tag=MOD(nt,xpaw_mpi_tag_ub)
+  if (recever==me) then
+    call MPI_RECV(vrecv,nt,MPI_DOUBLE_PRECISION,sender,tag,spaceComm,status,ier)
+  end if
+@@ -3346,7 +3390,7 @@
+ #if defined HAVE_MPI
+  if (sender==recever.or.spaceComm==xpaw_mpi_comm_null.or.(nt==0)) return
+  call MPI_COMM_RANK(spaceComm,me,ier)
+- tag=MOD(nt,MPI_TAG_UB)
++ tag=MOD(nt,xpaw_mpi_tag_ub)
+  if (recever==me) then
+    call MPI_RECV(vrecv,nt,MPI_DOUBLE_PRECISION,sender,tag,spaceComm,status,ier)
+  end if
diff --git a/var/spack/repos/builtin/packages/bigdft-libabinit/package.py b/var/spack/repos/builtin/packages/bigdft-libabinit/package.py
new file mode 100644
index 0000000000..ff61338334
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-libabinit/package.py
@@ -0,0 +1,86 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftLibabinit(AutotoolsPackage):
+    """BigDFT-libABINIT: this is a subsection of files coming from ABINIT software package,
+       to which BigDFT has been coupled since the early days. It handles different parts
+       like symmetries, ewald corrections, PAW routines, density and potential mixing
+       routines and some MD minimizers."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    variant('mpi', default=True, description='Enable MPI support')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+
+    depends_on('mpi',          when='+mpi')
+    depends_on('libxc@:2.2.2', when='@:1.9.1')
+    depends_on('libxc@:4.3.4', when='@1.9.1:')
+    depends_on('libxc@:4.3.4', when='@develop')
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers), when='@{0}'.format(vers))
+
+    patch('m_libpaw_mpi.F90.patch', when='@:1.8.2')
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "libABINIT"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            if spec.satisfies('@:1.8.2'):
+                autoreconf('-i')
+            else:
+                autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        args = [
+            "--with-libxc-libs=%s %s" % (spec['libxc'].libs.ld_flags,
+                                         spec['libxc'].libs.ld_flags + "f90"),
+            "--with-libxc-incs=%s"    % spec['libxc'].headers.include_flags,
+            "--with-futile-libs=%s"   % spec['bigdft-futile'].prefix.lib,
+            "--with-futile-incs=%s"   % spec['bigdft-futile'].headers.include_flags,
+            "--with-moduledir=%s"     % prefix.include,
+            "--prefix=%s" % prefix,
+        ]
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libabinit', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-psolver/package.py b/var/spack/repos/builtin/packages/bigdft-psolver/package.py
new file mode 100644
index 0000000000..1ae24f617b
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-psolver/package.py
@@ -0,0 +1,113 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftPsolver(AutotoolsPackage, CudaPackage):
+    """BigDFT-Psolver: a flexible real-space Poisson Solver based on
+       Interpolating Scaling Functions. It constitutes a fundamental building block
+       of BigDFT code, and it can also be used separately and linked to other codes."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    variant('mpi',       default=True, description='Enable MPI support')
+    variant('openmp',    default=True, description='Enable OpenMP support')
+    variant('scalapack', default=True, description='Enable SCALAPACK support')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+
+    depends_on('blas')
+    depends_on('lapack')
+    depends_on('py-pyyaml')
+    depends_on('mpi',       when='+mpi')
+    depends_on('scalapack', when='+scalapack')
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers), when='@{0}'.format(vers))
+    for vers in ['1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-atlab@{0}'.format(vers),  when='@{0}'.format(vers))
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "psolver"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        python_version = spec['python'].version.up_to(2)
+        pyyaml = join_path(spec['py-pyyaml'].prefix.lib,
+                           'python{0}'.format(python_version))
+
+        openmp_flag = []
+        if '+openmp' in spec:
+            openmp_flag.append(self.compiler.openmp_flag)
+
+        linalg = []
+        if '+scalapack' in spec:
+            linalg.append(spec['scalapack'].libs.ld_flags)
+        linalg.append(spec['lapack'].libs.ld_flags)
+        linalg.append(spec['blas'].libs.ld_flags)
+
+        args = [
+            "FCFLAGS=%s"            % " ".join(openmp_flag),
+            "--with-ext-linalg=%s"  % " ".join(linalg),
+            "--with-pyyaml-path=%s" % pyyaml,
+            "--with-futile-libs=%s" % spec['bigdft-futile'].prefix.lib,
+            "--with-futile-incs=%s" % spec['bigdft-futile'].headers.include_flags,
+            "--with-moduledir=%s"   % prefix.include,
+            "--prefix=%s"           % prefix,
+            "--without-etsf-io",
+        ]
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        if '+openmp' in spec:
+            args.append("--with-openmp")
+        else:
+            args.append("--without-openmp")
+
+        if spec.satisfies('@1.8.3:') or spec.satisfies('@develop'):
+            args.append("--with-atlab-libs=%s" % spec['bigdft-atlab'].prefix.lib)
+
+        if '+cuda' in spec:
+            args.append("--enable-cuda-gpu")
+            args.append("--with-cuda-path=%s" % spec['cuda'].prefix)
+            args.append("--with-cuda-libs=%s" % spec['cuda'].libs.link_flags)
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libPSolver-*', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-spred/package.py b/var/spack/repos/builtin/packages/bigdft-spred/package.py
new file mode 100644
index 0000000000..10a4cbac9c
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-spred/package.py
@@ -0,0 +1,107 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftSpred(AutotoolsPackage):
+    """BigDFT-spred: a library for structure prediction tools,
+       that is compiled on top of BigDFT routines."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    variant('mpi',       default=True, description='Enable MPI support')
+    variant('openmp',    default=True, description='Enable OpenMP support')
+    variant('scalapack', default=True, description='Enable SCALAPACK support')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+
+    depends_on('blas')
+    depends_on('lapack')
+    depends_on('py-pyyaml')
+    depends_on('mpi',       when='+mpi')
+    depends_on('scalapack', when='+scalapack')
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers),  when='@{0}'.format(vers))
+        depends_on('bigdft-psolver@{0}'.format(vers), when='@{0}'.format(vers))
+        depends_on('bigdft-core@{0}'.format(vers),    when='@{0}'.format(vers))
+
+    phases = ['autoreconf', 'configure', 'build', 'install']
+
+    build_directory = "spred"
+
+    def autoreconf(self, spec, prefix):
+        autoreconf = which('autoreconf')
+
+        with working_dir(self.build_directory):
+            autoreconf('-fi')
+
+    def configure_args(self):
+        spec = self.spec
+        prefix = self.prefix
+
+        python_version = spec['python'].version.up_to(2)
+        pyyaml = join_path(spec['py-pyyaml'].prefix.lib,
+                           'python{0}'.format(python_version))
+
+        openmp_flag = []
+        if '+openmp' in spec:
+            openmp_flag.append(self.compiler.openmp_flag)
+
+        linalg = []
+        if '+scalapack' in spec:
+            linalg.append(spec['scalapack'].libs.ld_flags)
+        linalg.append(spec['lapack'].libs.ld_flags)
+        linalg.append(spec['blas'].libs.ld_flags)
+
+        args = [
+            "FCFLAGS=%s"             % " ".join(openmp_flag),
+            "--with-ext-linalg=%s"   % " ".join(linalg),
+            "--with-pyyaml-path=%s"  % pyyaml,
+            "--with-futile-libs=%s"  % spec['bigdft-futile'].prefix.lib,
+            "--with-futile-incs=%s"  % spec['bigdft-futile'].headers.include_flags,
+            "--with-psolver-libs=%s" % spec['bigdft-psolver'].prefix.lib,
+            "--with-psolver-incs=%s" % spec['bigdft-psolver'].headers.include_flags,
+            "--with-core-libs=%s"    % spec['bigdft-core'].prefix.lib,
+            "--with-core-incs=%s"    % spec['bigdft-core'].headers.include_flags,
+            "--with-moduledir=%s"    % prefix.include,
+            "--prefix=%s"            % prefix,
+        ]
+
+        if '+mpi' in spec:
+            args.append("CC=%s"  % spec['mpi'].mpicc)
+            args.append("CXX=%s" % spec['mpi'].mpicxx)
+            args.append("FC=%s"  % spec['mpi'].mpifc)
+            args.append("F90=%s" % spec['mpi'].mpifc)
+            args.append("F77=%s" % spec['mpi'].mpif77)
+        else:
+            args.append("--disable-mpi")
+
+        if '+openmp' in spec:
+            args.append("--with-openmp")
+        else:
+            args.append("--without-openmp")
+
+        return args
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libspred-*', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/bigdft-suite/package.py b/var/spack/repos/builtin/packages/bigdft-suite/package.py
new file mode 100644
index 0000000000..a5dd855ea8
--- /dev/null
+++ b/var/spack/repos/builtin/packages/bigdft-suite/package.py
@@ -0,0 +1,39 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class BigdftSuite(BundlePackage):
+    """BigDFT-suite: the complete suite of BigDFT for electronic structure calculation
+       based on Daubechies wavelets."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+    version('1.8.3',   sha256='f112bb08833da4d11dd0f14f7ab10d740b62bc924806d77c985eb04ae0629909')
+    version('1.8.2',   sha256='042e5a3b478b1a4c050c450a9b1be7bcf8e13eacbce4759b7f2d79268b298d61')
+    version('1.8.1',   sha256='e09ff0ba381f6ffbe6a3c0cb71db5b73117874beb41f22a982a7e5ba32d018b3')
+
+    depends_on('python@:2.8', type=('run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('run'), when="@develop")
+
+    for vers in ['1.8.1', '1.8.2', '1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers),    when='@{0}'.format(vers))
+        depends_on('bigdft-psolver@{0}'.format(vers),   when='@{0}'.format(vers))
+        depends_on('bigdft-libabinit@{0}'.format(vers), when='@{0}'.format(vers))
+        depends_on('bigdft-chess@{0}'.format(vers),     when='@{0}'.format(vers))
+        depends_on('bigdft-core@{0}'.format(vers),      when='@{0}'.format(vers))
+        depends_on('bigdft-spred@{0}'.format(vers),     when='@{0}'.format(vers))
+    for vers in ['1.8.3', '1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-atlab@{0}'.format(vers),     when='@{0}'.format(vers))
+    for vers in ['1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('py-bigdft@{0}'.format(vers),        when='@{0}'.format(vers))
diff --git a/var/spack/repos/builtin/packages/libgain/package.py b/var/spack/repos/builtin/packages/libgain/package.py
new file mode 100644
index 0000000000..30a6ebeabf
--- /dev/null
+++ b/var/spack/repos/builtin/packages/libgain/package.py
@@ -0,0 +1,25 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class Libgain(AutotoolsPackage):
+    """GaIn is intended to provide routines with a relatively simple interface
+       for calculation of overlap, kinetic and 2,3 and 4 center Coulomb integrals
+       over either Solid or Cubic Harmonics Gaussian basis sets."""
+
+    homepage = "https://bigdft.org/"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('1.0.0',   sha256='3e02637433272f5edfee74ea47abf93ab7e3f1ce717664d22329468a5bd45c3a',
+            url="https://gitlab.com/l_sim/bigdft-suite/-/raw/1.9.1/GaIn-1.0.tar.gz")
+
+    @property
+    def libs(self):
+        shared = "+shared" in self.spec
+        return find_libraries(
+            'libGaIn', root=self.prefix, shared=shared, recursive=True
+        )
diff --git a/var/spack/repos/builtin/packages/py-bigdft/package.py b/var/spack/repos/builtin/packages/py-bigdft/package.py
new file mode 100644
index 0000000000..2566e4d34f
--- /dev/null
+++ b/var/spack/repos/builtin/packages/py-bigdft/package.py
@@ -0,0 +1,31 @@
+# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack import *
+
+
+class PyBigdft(PythonPackage):
+    """BigDFT: the python interface of BigDFT for electronic structure calculation
+       based on Daubechies wavelets."""
+
+    homepage = "https://bigdft.org/"
+    url      = "https://gitlab.com/l_sim/bigdft-suite/-/archive/1.9.2/bigdft-suite-1.9.2.tar.gz"
+    git      = "https://gitlab.com/l_sim/bigdft-suite.git"
+
+    version('develop', branch='devel')
+    version('1.9.2',   sha256='dc9e49b68f122a9886fa0ef09970f62e7ba21bb9ab1b86be9b7d7e22ed8fbe0f')
+    version('1.9.1',   sha256='3c334da26d2a201b572579fc1a7f8caad1cbf971e848a3e10d83bc4dc8c82e41')
+    version('1.9.0',   sha256='4500e505f5a29d213f678a91d00a10fef9dc00860ea4b3edf9280f33ed0d1ac8')
+
+    depends_on('python@:2.8', type=('build', 'run'), when="@:1.8.3")
+    depends_on('python@3.0:', type=('build', 'run'), when="@1.9.0:")
+    depends_on('python@3.0:', type=('build', 'run'), when="@develop")
+    depends_on('py-numpy')
+    depends_on('py-setuptools')
+
+    for vers in ['1.9.0', '1.9.1', '1.9.2', 'develop']:
+        depends_on('bigdft-futile@{0}'.format(vers), type='run', when='@{0}'.format(vers))
+
+    build_directory = "PyBigDFT"
-- 
cgit v1.2.3-70-g09d2