summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/gslib/package.py
blob: fff12c49c4f020b85c576e45e615d18e25d01464 (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
# Copyright 2013-2023 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.package import *


class Gslib(Package):
    """Highly scalable Gather-scatter code with AMG and XXT solvers"""

    homepage = "https://github.com/gslib/gslib"
    git = "https://github.com/gslib/gslib.git"

    version("develop", branch="master")
    version("1.0.7", tag="v1.0.7", commit="88f90cb96953527e3e833f8dbf2719273fc8346d")
    version("1.0.6", tag="v1.0.6", commit="1c2f74420fec36d5abe1d75f194a457c61f0df53")
    version("1.0.5", tag="v1.0.5", commit="1de2fba1d94e27e20f3bc3af6a3a35901e223ecd")
    version("1.0.4", tag="v1.0.4", commit="00a074c15a13fdfd121ac5781ae450af809dde3b")
    version("1.0.3", tag="v1.0.3", commit="e2df99fad9480a981034fd0e4b3a7fe8f3cf9ae3")
    version("1.0.2", tag="v1.0.2", commit="e53419c32a4a326e55e1c3e0d7de14ce665c1788")
    version("1.0.1", tag="v1.0.1", commit="d16685f24551b7efd69e58d96dc76aec75239ea3")
    version("1.0.0", tag="v1.0.0", commit="9533e652320a3b26a72c36487ae265b02072cd48")

    variant("mpi", default=True, description="Build with MPI")
    variant("mpiio", default=True, description="Build with MPI I/O")
    variant("blas", default=False, description="Build with BLAS")

    depends_on("mpi", when="+mpi")
    depends_on("mpi", when="+mpiio")
    depends_on("blas", when="+blas")

    conflicts("~mpi", when="+mpiio")

    def install(self, spec, prefix):
        src_dir = "src"
        lib_dir = "lib"
        libname = "libgs.a"

        if self.spec.satisfies("@1.0.1:"):
            makefile = "Makefile"
        else:
            makefile = "src/Makefile"

        cc = self.compiler.cc

        if "+mpiio" not in spec:
            filter_file(r"MPIIO.*?=.*1", "MPIIO = 0", makefile)

        if "+mpi" in spec:
            cc = spec["mpi"].mpicc
        else:
            filter_file(r"MPI.*?=.*1", "MPI = 0", makefile)
            filter_file(r"MPIIO.*?=.*1", "MPIIO = 0", makefile)

        make_cmd = "CC=" + cc

        if "+blas" in spec:
            filter_file(r"BLAS.*?=.*0", "BLAS = 1", makefile)
            blas = spec["blas"].libs
            ld_flags = blas.ld_flags
            filter_file(r"\$\(LDFLAGS\)", ld_flags, makefile)

        if self.spec.satisfies("@1.0.3:"):
            make(make_cmd)
            make("install", "INSTALL_ROOT=%s" % self.prefix)
        else:
            if self.spec.satisfies("@1.0.1:"):
                make(make_cmd)
                make("install")
                install_tree(lib_dir, prefix.lib)
            elif self.version == Version("1.0.0"):
                with working_dir(src_dir):
                    make(make_cmd)
                    mkdir(prefix.lib)
                    install(libname, prefix.lib)
            # Should only install the headers (this will be fixed in gslib on
            # future releases).
            install_tree(src_dir, prefix.include)