summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/siesta/package.py
blob: 8b1c299f675615db4f201fba63ed4a67bebc753f (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
# 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)


import os

from spack.package import *


class Siesta(MakefilePackage):
    """SIESTA performs electronic structure calculations and ab initio molecular
    dynamics simulations of molecules and solids.
    """

    homepage = "https://departments.icmab.es/leem/siesta/"

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

    version("4.0.2", sha256="bafbda19358f0c1dd39bb1253c92ee548791a1c0f648977051d2657216874f7e")
    version(
        "4.0.1",
        sha256="bfb9e4335ae1d1639a749ce7e679e739fdead5ee5766b5356ea1d259a6b1e6d1",
        url="https://launchpad.net/siesta/4.0/4.0.1/+download/siesta-4.0.1.tar.gz",
    )
    version(
        "3.2-pl-5",
        sha256="e438bb007608e54c650e14de7fa0b5c72562abb09cbd92dcfb5275becd929a23",
        url="http://departments.icmab.es/leem/siesta/CodeAccess/Code/siesta-3.2-pl-5.tgz",
    )

    patch("configure.patch", when="@:4.0")

    depends_on("mpi")
    depends_on("blas")
    depends_on("lapack")
    depends_on("scalapack")
    depends_on("netcdf-c")
    depends_on("netcdf-fortran")

    def flag_handler(self, name, flags):
        if "%gcc@10:" in self.spec and name == "fflags":
            flags.append("-fallow-argument-mismatch")
        return flags, None, None

    def edit(self, spec, prefix):
        sh = which("sh")
        configure_args = [
            "--enable-mpi",
            "--with-blas=%s" % spec["blas"].libs,
            "--with-lapack=%s" % spec["lapack"].libs,
            # need to include BLAS below because Intel MKL's
            # BLACS depends on BLAS, otherwise the compiler
            # test fails
            "--with-blacs=%s" % (spec["scalapack"].libs + spec["blas"].libs),
            "--with-scalapack=%s" % spec["scalapack"].libs,
            "--with-netcdf=%s" % (spec["netcdf-fortran"].libs + spec["netcdf-c"].libs),
            # need to specify MPIFC explicitly below, otherwise
            # Intel's mpiifort is not found
            "MPIFC=%s" % spec["mpi"].mpifc,
        ]
        if self.spec.satisfies("%gcc"):
            configure_args.append("FCFLAGS=-ffree-line-length-0")
        for d in ["Obj", "Obj_trans"]:
            with working_dir(d, create=True):
                sh("../Src/configure", *configure_args)
                if spec.satisfies("@:4.0%intel"):
                    with open("arch.make", "a") as f:
                        f.write("\natom.o: atom.F\n")
                        f.write("\t$(FC) -c $(FFLAGS) -O1")
                        f.write("$(INCFLAGS) $(FPPFLAGS) $<")
                sh("../Src/obj_setup.sh")

    def build(self, spec, prefix):
        with working_dir("Obj"):
            make(parallel=False)
        with working_dir("Obj_trans"):
            make("transiesta", parallel=False)
        with working_dir("Util"):
            sh = which("sh")
            sh("build_all.sh")

    def install(self, spec, prefix):
        mkdir(prefix.bin)
        with working_dir("Obj"):
            install("siesta", prefix.bin)
        with working_dir("Obj_trans"):
            install("transiesta", prefix.bin)
        for root, _, files in os.walk("Util"):
            for fname in files:
                fname = join_path(root, fname)
                if os.access(fname, os.X_OK):
                    install(fname, prefix.bin)