File indexing completed on 2025-01-18 09:15:26
0001 from spack.package import *
0002 import os
0003 import tarfile
0004
0005
0006 class Fluka(Package):
0007 """FLUKA is a general purpose Monte Carlo code for the interaction
0008 and transport of hadrons, leptons, and photons from keV (with the
0009 exception of neutrons, tracked down to thermal energies) to cosmic
0010 ray energies in any material.
0011
0012 Note: A manual download is required for FLUKA.
0013 Spack will search your current directory for the download file.
0014 Alternatively, add this file to a mirror so that Spack can find it.
0015 For instructions on how to set up a mirror, see
0016 https://spack.readthedocs.io/en/latest/mirrors.html"""
0017
0018 homepage = "https://fluka.cern"
0019 list_url = "https://fluka.cern/download/latest-fluka-release"
0020 url = "https://flukafiles.web.cern.ch/flukafiles/fluka-4-2.3/fluka-4-2.3.x86-Linux-gfor9.tgz"
0021
0022 maintainers = ["wdconinc"]
0023
0024 tags = ["eic"]
0025
0026 version(
0027 "4-3.4",
0028 sha256="be3197c8162b4e2727dcda88c1b35320b8b01152c3ca9e83c4567bfb8da2b02b",
0029 )
0030 version(
0031 "4-3.3",
0032 sha256="f22a6e81ac4e149baabac4cf5d5060bf2d5190774f1bd299b6891988fd1e93a1",
0033 )
0034 version(
0035 "4-3.2",
0036 sha256="9c196cb2dccc07fbe46e0e20e6355621069d3a5eb762927c4e58766d6bce51b7",
0037 )
0038 version(
0039 "4-3.1",
0040 sha256="e4174e3bcd8eb728cb581028a13e38168ed763bfb57dcf324559991daa906dc5",
0041 )
0042 version(
0043 "4-3.0",
0044 sha256="d9f7f4ec0764c35a24ed412e48d7017d03966a0e3a6515b0c171539c5cc995f7",
0045 )
0046 version(
0047 "4-2.2",
0048 sha256="15fe7ad9e45604e1e9f8c3a8c24db2c53181155712c07f7dee3242a890229997",
0049 )
0050 version(
0051 "4-2.1",
0052 sha256="a78a8e9bdb75e4b7eda0c190dc7241b399d1abffcbc3fd6f42505b789f1cdb5f",
0053 url="file://{}/fluka-4-2.1.x86-Linux-gfor9.tgz".format(os.getcwd()),
0054 )
0055 version(
0056 "4-2.0",
0057 sha256="a3b3f9617079aa64d39632b32a01b65dc32375d01804bb80ae1d3e87de599393",
0058 url="file://{}/fluka-4-2.0.x86-Linux-gfor9.tgz".format(os.getcwd()),
0059 )
0060
0061 conflicts("%gcc@:7", when="@4.2.0")
0062
0063 depends_on("fortran", type="build")
0064
0065 manual_download = True
0066
0067 @property
0068 def download_instr(self):
0069 v = self.spec.version
0070 file = self.file_for_version(v)
0071 url = f"https://flukafiles.web.cern.ch/flukafiles/fluka-{v}/{file}"
0072 return f"""Manual download is required for {self.spec.name}.
0073 Register as a FLUKA user at https://fluka.cern/download/registration,
0074 then authenticate and download {url} into the current directory."""
0075
0076 def file_for_version(self, version):
0077 return f"fluka-{version}.x86-Linux-gfor9.tgz"
0078
0079 def url_for_version(self, version):
0080 return f"file://{os.getcwd()}/{self.file_for_version(version)}"
0081
0082 def install(self, spec, prefix):
0083 with working_dir("src"):
0084 make()
0085 install_tree("bin", prefix.bin)
0086 install_tree("lib", prefix.lib)
0087 install_tree("data", prefix.data)
0088 install_tree("include", prefix.include)
0089 install_tree("doc", join_path(prefix.share, "doc"))
0090 install_tree("examples", join_path(prefix.share, "examples"))
0091 for file in [
0092 "AUTHORS",
0093 "INSTALL",
0094 "LICENSE",
0095 "REFERENCES",
0096 "RELEASE-NOTES",
0097 "README.md",
0098 "Version.tag",
0099 ]:
0100 install(file, prefix.share)
0101
0102 def setup_run_environment(self, env):
0103 env.set("FLUDIR", self.spec.prefix)