summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/q-e-sirius/package.py
blob: 3aee3e101bacc15f98886887466d0f7a83480fe5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright 2013-2024 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)
# adapted from official quantum espresso package


from spack.package import *


class QESirius(CMakePackage):
    """SIRIUS enabled fork of QuantumESPRESSO."""

    homepage = "https://github.com/electronic-structure/q-e-sirius/"
    url = "https://github.com/electronic-structure/q-e-sirius/archive/v6.5-rc4-sirius.tar.gz"
    git = "https://github.com/electronic-structure/q-e-sirius.git"

    maintainers("simonpintarelli")

    license("GPL-2.0-or-later")

    version("develop-ristretto", branch="ristretto", preferred=True, submodules=True)
    version(
        "6.7-rc1-sirius",
        tag="v6.7-rc1-sirius",
        commit="b1c79e30a2f9351316a90ca296f98cffef1f35c3",
        submodules=True,
    )

    variant("mpi", default=True, description="Builds with MPI support")
    variant("openmp", default=True, description="Enables OpenMP support")
    variant("libxc", default=False, description="Support functionals through libxc")
    variant("sirius_apps", default=False, description="Build SIRIUS standalone binaries")
    # Support for HDF5 has been added starting in QE 6.1.0 and is
    # still experimental
    variant(
        "hdf5",
        default="none",
        description="Orbital and density data I/O with HDF5",
        values=("parallel", "serial", "none"),
        multi=False,
    )

    depends_on("sirius +fortran")
    depends_on("sirius +apps", when="+sirius_apps")
    depends_on("sirius ~apps", when="~sirius_apps")
    depends_on("sirius +openmp", when="+openmp")
    depends_on("sirius@develop", when="@develop-ristretto")

    depends_on("mpi", when="+mpi")
    depends_on("elpa", when="+elpa")
    depends_on("libxc", when="+libxc")
    depends_on("fftw-api@3")
    depends_on("blas")
    depends_on("lapack")
    depends_on("git", type="build")
    depends_on("pkgconfig", type="build")

    conflicts("~mpi", when="+scalapack", msg="SCALAPACK requires MPI support")
    conflicts("~scalapack", when="+elpa", msg="ELPA requires SCALAPACK support")

    with when("+mpi"):
        depends_on("mpi")
        variant("scalapack", default=True, description="Enables scalapack support")

    with when("+scalapack"):
        depends_on("scalapack")
        variant("elpa", default=False, description="Uses elpa as an eigenvalue solver")

    # Versions of HDF5 prior to 1.8.16 lead to QE runtime errors
    depends_on("hdf5@1.8.16:+fortran+hl+mpi", when="hdf5=parallel")
    depends_on("hdf5@1.8.16:+fortran+hl~mpi", when="hdf5=serial")

    with when("+openmp"):
        depends_on("fftw+openmp", when="^fftw")
        depends_on("openblas threads=openmp", when="^openblas")
        depends_on("intel-mkl threads=openmp", when="^intel-mkl")

    def cmake_args(self):
        args = [
            "-DQE_ENABLE_SIRIUS=ON",
            "-DQE_ENABLE_CUDA=OFF",
            "-DQE_LAPACK_INTERNAL=OFF",
            "-DQE_ENABLE_DOC=OFF",
            self.define_from_variant("QE_ENABLE_MPI", "mpi"),
            self.define_from_variant("QE_ENABLE_OPENMP", "openmp"),
            self.define_from_variant("QE_ENABLE_ELPA", "elpa"),
            self.define_from_variant("QE_ENABLE_LIBXC", "libxc"),
            self.define_from_variant("QE_ENABLE_SCALAPACK", "scalapack"),
        ]

        if not self.spec.satisfies("hdf5=none"):
            args.append(self.define("QE_ENABLE_HDF5", True))

        # Work around spack issue #19970 where spack sets
        # rpaths for MKL just during make, but cmake removes
        # them during make install.
        if self.spec["lapack"].name in INTEL_MATH_LIBRARIES:
            args.append("-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON")
        spec = self.spec
        args.append(self.define("BLAS_LIBRARIES", spec["blas"].libs.joined(";")))
        args.append(self.define("LAPACK_LIBRARIES", spec["lapack"].libs.joined(";")))

        return args