diff --git a/packages/genie-xsec/package.py b/packages/genie-xsec/package.py index fa457642..159f0f8e 100644 --- a/packages/genie-xsec/package.py +++ b/packages/genie-xsec/package.py @@ -11,12 +11,100 @@ class GenieXsec(Package): """Data files used by genie.""" - homepage = "https://www.example.com" - url = "file://" + os.path.dirname(__file__) + "/../../config/junk.xml" - version( - "2.12.10", "2cae8b754a9f824ddd27964d11732941fd88f52f0880d7f685017caba7fea6b7", expand=False + version("3.04.00", sha256="fb4dc9badd1771c92fabbf818b33544006e8b60c7fb0f33d5288a66d93bd19ea", + url="https://scisoft.fnal.gov/scisoft/packages/genie_xsec/v3_04_00/genie_xsec-3.04.00-noarch-G1810a0211a-k250-e1000.tar.bz2") + + version("2.12.10", "2cae8b754a9f824ddd27964d11732941fd88f52f0880d7f685017caba7fea6b7", + expand=False, url="file://" + os.path.dirname(__file__) + "/../../config/junk.xml") + + # tune_name values are designed to line up with the ups setup command + # when setting the environment variable, we change to match typical + # genie tune format + variant( + "tune_name", + default="AR2320i00000-k250-e1000", + multi=False, + values=( + "AR2320i00000-k250-e1000", + "G1801a00000-k250-e1000", + "G1802a00000-k250-e1000", + "G1810a0211a-k250-e1000", + "G1810a0211b-k250-e1000", + "G2111a00000-k250-e1000", + "GDNu2001a00000-k120-e200", + "N1810j0211a-k250-e1000" + ), + when="@3.0:", + description="Name of genie xsec tune set to install.", ) + urlbase_2 = ("https://scisoft.fnal.gov/scisoft/packages/genie_xsec/v2_12_10/genie_xsec-2.12.10-noarch-") + urlbase_3 = ("https://scisoft.fnal.gov/scisoft/packages/genie_xsec/v3_04_00/genie_xsec-3.04.00-noarch-") + + resource( + name="AR2320i00000-k250-e1000", + placement="AR2320i00000-k250-e1000", + when="tune_name=AR2320i00000-k250-e1000", + url=urlbase_3 + "AR2320i00000-k250-e1000.tar.bz2", + sha256="13cc9d740c170af9033623049162eeff0fb0b68156122d380aa3262e92e9f61f", + ) + + resource( + name="G1801a00000-k250-e1000", + placement="G1801a00000-k250-e1000", + when="tune_name=G1801a00000-k250-e1000", + url=urlbase_3 + "G1801a00000-k250-e1000.tar.bz2", + sha256="f222ff56360c9c221e8f793a9c09ddbe6578dbbaa9031b3b3a49cb5ec186595d", + ) + + resource( + name="G1802a00000-k250-e1000", + placement="G1802a00000-k250-e1000", + when="tune_name=G1802a00000-k250-e1000", + url=urlbase_3 + "G1802a00000-k250-e1000.tar.bz2", + sha256="d7189bd6c3933b3017c83fafddb84d57b48414632b577835e49babec8537ab6e", + ) + + resource( + name="G1810a0211a-k250-e1000", + placement="G1810a0211a-k250-e1000", + when="tune_name=G1810a0211a-k250-e1000", + url=urlbase_3 + "G1810a0211a-k250-e1000.tar.bz2", + sha256="fb4dc9badd1771c92fabbf818b33544006e8b60c7fb0f33d5288a66d93bd19ea", + ) + + resource( + name="G1810a0211b-k250-e1000", + placement="G1810a0211b-k250-e1000", + when="tune_name=G1810a0211b-k250-e1000", + url=urlbase_3 + "G1810a0211b-k250-e1000.tar.bz2", + sha256="a1031e49ac8ac426074f247d91b2c886edaf7c4fef13993fe69aad92ad698c34", + ) + + resource( + name="G2111a00000-k250-e1000", + placement="G2111a00000-k250-e1000", + when="tune_name=G2111a00000-k250-e1000", + url=urlbase_3 + "G2111a00000-k250-e1000.tar.bz2", + sha256="ae159887772a54891fc4bddb189ab108d74c4a48db68c13ed7166524e8797590", + ) + + resource( + name="GDNu2001a00000-k120-e200", + placement="GDNu2001a00000-k120-e200", + when="tune_name=GDNu2001a00000-k120-e200", + url=urlbase_3 + "GDNu2001a00000-k120-e200.tar.bz2", + sha256="69146aacc6c55bdc5c519e917e48ea005d160824bf960d17734e9c7c6d85b6cb", + ) + + resource( + name="N1810j0211a-k250-e1000", + placement="N1810j0211a-k250-e1000", + when="tune_name=N1810j0211a-k250-e1000", + url=urlbase_3 + "N1810j0211a-k250-e1000.tar.bz2", + sha256="79e7ecd8d0dc577efb525831b90eb2f650c0cdd7fe5cd17e3ea610a686248e33", + ) + variant( "xsec_name", default="DefaultPlusMECWithNC", @@ -29,58 +117,82 @@ class GenieXsec(Package): "LocalFGNievesQEAndMEC", "ValenciaQEBergerSehgalCOHRES", ), + when="@:3.0", description="Name of genie xsec set to install.", ) - urlbase = ( - "https://scisoft.fnal.gov/scisoft/packages/genie_xsec/v2_12_10/genie_xsec-2.12.10-noarch-" - ) resource( name="AltPion", placement="AltPion", when="xsec_name=AltPion", - url=urlbase + "AltPion.tar.bz2", + url=urlbase_2 + "AltPion.tar.bz2", sha256="49c4c5332c96edc4147e8cacd5b68e8dd89737e205741a21bc75a5ba18b967c4", ) resource( name="DefaultPlusMECWithNC", placement="DefaultPlusMECWithNC", when="xsec_name=DefaultPlusMECWithNC", - url=urlbase + "DefaultPlusMECWithNC.tar.bz2", + url=urlbase_2 + "DefaultPlusMECWithNC.tar.bz2", sha256="7c57caa96c319ad8007253e2a81c6ffcc4dcc6d0923dabbf7b8938d8363ac621", ) resource( name="DefaultPlusValenciaMEC", placement="DefaultPlusValenciaMEC", when="xsec_name=DefaultPlusValenciaMEC", - url=urlbase + "DefaultPlusValenciaMEC.tar.bz2", + url=urlbase_2 + "DefaultPlusValenciaMEC.tar.bz2", sha256="fe1b584e7014bba6c4cba5646e1031f344e9efbf799a2aa26b706e28c40a4481", ) resource( name="EffSFTEM", placement="EffSFTEM", when="xsec_name=EffSFTEM", - url=urlbase + "EffSFTEM.tar.bz2", + url=urlbase_2 + "EffSFTEM.tar.bz2", sha256="b6365f1a150b90b79788f51b084a1dce7432d8ba10b7faa03ade3f6d558c82f6", ) resource( name="LocalFGNievesQEAndMEC", placement="LocalFGNievesQEAndMEC", when="xsec_name=LocalFGNievesQEAndMEC", - url=urlbase + "LocalFGNievesQEAndMEC.tar.bz2", + url=urlbase_2 + "LocalFGNievesQEAndMEC.tar.bz2", sha256="5f02d7efa46ef42052834d80b6923b41e502994daaf6037dad9793799ad4b346", ) resource( name="ValenciaQEBergerSehgalCOHRES", placement="ValenciaQEBergerSehgalCOHRES", when="xsec_name=ValenciaQEBergerSehgalCOHRES", - url=urlbase + "ValenciaQEBergerSehgalCOHRES.tar.bz2", + url=urlbase_2 + "ValenciaQEBergerSehgalCOHRES.tar.bz2", sha256="3e7c117777cb0da6232df1e1fe481fdb2afbfe55639b0d7b4ddf8027954ed1fa", ) def install(self, spec, prefix): - val = spec.variants["xsec_name"].value - install_tree( - "{0}/{2}/v{1}/NULL/{2}".format(self.stage.source_path, self.version.underscored, val), - "{0}/{1}".format(prefix, val), - ) + if(self.version >= Version("3.0")): + val = spec.variants["tune_name"].value + comb_str = val.split(':')[0].split('-')[0] + tune_str = comb_str[:3]+"_"+comb_str[3:6]+"_"+comb_str[6:8]+"_"+comb_str[8:] + + install_tree( + "{0}/{2}/v{1}/NULL/{2}".format(self.stage.source_path, self.version.underscored, val), + "{0}/v{1}/NULL/{2}".format(prefix, self.version.underscored, val), + ) + elif(self.version < Version("3.0")): + val = spec.variants["xsec_name"].value + install_tree( + "{0}/{2}/v{1}/NULL/{2}".format(self.stage.source_path, self.version.underscored, val), + "{0}/{1}".format(prefix, val), + ) + + def setup_run_environment(self, run_env): + if(self.version >= Version("3.0")): + val = self.spec['genie-xsec'].variants['tune_name'].value + data_str = "{0}/v{1}/NULL/{2}/data".format(self.spec['genie-xsec'].prefix, self.version.underscored, val) + raw_str = self.spec['genie-xsec'].variants['tune_name'].value + comb_str = raw_str.split(':')[0].split('-')[0] + tune_str = comb_str[:-8]+"_"+comb_str[-8:-5]+"_"+comb_str[-5:-3]+"_"+comb_str[-3:] + + run_env.set("GENIEXSECPATH", data_str) + run_env.set("GENIEXSECFILE", data_str+"/gxspl-NUsmall.xml") + run_env.set("GXMLPATH", data_str) + run_env.set("GENIE_XSEC_TUNE", tune_str) + run_env.set("GENIE_XSEC_GENLIST", "Default") + run_env.set("GENIE_XSEC_KNOTS", "250") + run_env.set("GENIE_XSEC_EMAX", "1000.0") diff --git a/packages/genie/package.py b/packages/genie/package.py index f07cb3d9..327fe5dd 100644 --- a/packages/genie/package.py +++ b/packages/genie/package.py @@ -25,6 +25,7 @@ def url_for_version(self, version): version.underscored ) + version("3.04.02", sha256="c5935aea86d2ba9897ab55bb581622c561575957d19e572691d3bc0833ed9512", preferred=True) version("3.04.00", sha256="72cf8a119cc59d03763b11afad1a82c0974a06677bf1c154b7c2a90d9f1529c1") version("3.00.06", sha256="ab56ea85d0c1d09029254365bfe75a1427effa717389753b9e0c1b6c2eaa5eaf") version("3.00.04", sha256="53f034618fef9f7f0e17d1c4ed72743e4bba590e824b795177a1a8a8486c861e") @@ -67,9 +68,15 @@ def url_for_version(self, version): variant("lhapdf", default=True) + # Use mainline spack gettext for lhapdf depends_on("lhapdf" , when="+lhapdf") - depends_on("root+pythia6") + # Issues caused by default root cxxstd being 11 + depends_on("root @6.24.08:6.28.12 +pythia6 cxxstd=14", when="cxxstd=14") + depends_on("root @6.24.08:6.28.12 +pythia6 cxxstd=17", when="cxxstd=17") + depends_on("root @6.24.08:6.28.12 +pythia6 cxxstd=17", when="cxxstd=default") + depends_on("root @6.24.08:6.28.12 +pythia6 cxxstd=20", when="cxxstd=20") + depends_on("pythia6+root") depends_on("libxml2") depends_on("log4cpp") @@ -81,25 +88,13 @@ def url_for_version(self, version): patch("patch/sles-cnl.patch", when="platform=cray") patch("patch/root_subdir.patch") - patch("patch/GENIE-Generator.patch", when="@3.04.00") - patch("patch/GENIE-Reweight.patch", when="@3.04.00", level=0) + patch("patch/GENIE-Generator.patch", when="@3.04.02") + patch("patch/GENIE-Reweight.patch", when="@3.04.02", level=0) - @when("os=almalinux9") + # @when("os=almalinux9") patch should be applied on polaris too def patch(self): filter_file(r'-lnsl','','src/make/Make.include') - @property - def build_targets(self): - cxxstd = self.spec.variants["cxxstd"].value - cxxstdflag = ( - "" if cxxstd == "default" else getattr(self.compiler, "cxx{0}_flag".format(cxxstd)) - ) - args = [ - "GOPT_WITH_CXX_USERDEF_FLAGS=-g -fno-omit-frame-pointer {0}".format(cxxstdflag), - "all", - ] - return args - def configure_args(self): args = [ "--enable-rwght", @@ -107,8 +102,7 @@ def configure_args(self): "--enable-atmo", "--enable-event-server", "--enable-nucleon-decay", - "--enable-neutron-osc", - "--enable-vle-extension", + "--enable-nnbar-oscillation", "--with-pythia6-lib={0}".format(self.spec["pythia6"].prefix.lib), "--with-libxml2-inc={0}/libxml2".format(self.spec["libxml2"].prefix.include), "--with-libxml2-lib={0}".format(self.spec["libxml2"].prefix.lib), @@ -164,9 +158,9 @@ def add_to_make_env(self): def build(self, spec, prefix): with working_dir(self.build_directory): - make(*self.build_targets) + make() with working_dir("{0}/Reweight".format(self.stage.source_path)): - make(*self.build_targets) + make() def install(self, spec, prefix): mkdirp(prefix.bin) @@ -174,6 +168,8 @@ def install(self, spec, prefix): mkdirp(prefix.lib64) mkdirp(prefix.include) mkdirp(prefix.src) + mkdirp(prefix.config) # necessary for tune functionality + mkdirp(prefix.data) # necessary for PDG library lookup with working_dir(self.build_directory): make("install") @@ -188,8 +184,12 @@ def install_required_src(self): os.path.join(self.prefix, "src", "scripts"), ) src_make_dir = os.path.join(self.prefix, "src", "make", "") + config_dir = os.path.join(self.prefix, "config", "") + data_dir = os.path.join(self.prefix, "data", "") # filesystem.mkdirp(src_make_dir) filesystem.install_tree(os.path.join(self.stage.source_path, "src", "make"), src_make_dir) + filesystem.install_tree(os.path.join(self.stage.source_path, "config"), config_dir) + filesystem.install_tree(os.path.join(self.stage.source_path, "data"), data_dir) def setup_build_environment(self, spack_env): spack_env.set("ROOT_INCLUDE_PATH", os.path.join(self.stage.source_path, "src")) @@ -204,6 +204,13 @@ def setup_build_environment(self, spack_env): ): spack_env.prepend_path("ROOT_INCLUDE_PATH", str(self.spec[d.name].prefix.include)) + def flag_handler(self, name, flags): + if name == "cxxflags": + cxxstd = self.spec.variants["cxxstd"].value + if cxxstd != "default": + flags.append(getattr(self.compiler, f"cxx{cxxstd}_flag")) + return (flags, None, None) + def setup_run_environment(self, run_env): run_env.prepend_path("PATH", self.prefix.bin) run_env.set("GENIE", self.prefix) diff --git a/packages/lhapdf/package.py b/packages/lhapdf/package.py deleted file mode 100644 index 674d1094..00000000 --- a/packages/lhapdf/package.py +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright 2013-2019 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 glob -import os - -from spack import * - - -class Lhapdf(AutotoolsPackage): - - homepage = "https://www.hepforge.org/lhapdf" - url = "https://lhapdf.hepforge.org/downloads/?f=lhapdf-5.9.1.tar.gz" - - version("6.5.3", sha256="57435cd695e297065d53e69bd29090765c934936b6a975ff8c559766f2230359") - version("6.3.0", sha256="ed4d8772b7e6be26d1a7682a13c87338d67821847aa1640d78d67d2cef8b9b5d") - version("6.2.3", sha256="d6e63addc56c57b6286dc43ffc56d901516f4779a93a0f1547e14b32cfd82dd1") - - def url_for_version(self, version): - # between 5.x and 6.x they went to upper case names in the URLs - if str(version)[0] < "6": - urlf = "https://lhapdf.hepforge.org/downloads/?f=lhapdf-%s.tar.gz" - else: - urlf = "https://lhapdf.hepforge.org/downloads/?f=LHAPDF-%s.tar.gz" - return urlf % version - - version("5.9.1", sha256="86b9b046d7f25627ce2aab6847ef1c5534972f4bae18de98225080cf5086919c") - - def patch(self): - if os.path.exists("./config/config.sub"): - os.remove("./config/config.sub") - install( - os.path.join(os.path.dirname(__file__), "../../config/config.sub"), - "./config/config.sub", - ) - if os.path.exists("./config/config.guess"): - os.remove("./config/config.guess") - install( - os.path.join(os.path.dirname(__file__), "../../config/config.guess"), - "./config/config.guess", - ) - - variant( - "cxxstd", - default="17", - values=("default", "98", "11", "14", "17", "20"), - multi=False, - description="Use the specified C++ standard when building.", - ) - - depends_on("pdfsets") - - def configure_args(self): - return ("--enable-low-memory", "--disable-pyext", "--disable-octave") - - @run_after("install") - def link_pdfs(self): - mkdirp(os.path.join(self.spec.prefix.share, "lhapdf/PDFsets")) - pdfs = [ - "CT10.LHgrid", - "cteq61.LHgrid", - "cteq61.LHpdf", - "GRV98lo.LHgrid", - "GRV98nlo.LHgrid", - "GRVG0.LHgrid", - "GRVG1.LHgrid", - "GRVPI0.LHgrid", - "GRVPI1.LHgrid", - ] - for pdf in pdfs: - os.symlink( - "{0}/PDFsets/{1}".format(self.spec["pdfsets"].prefix, pdf), - "{0}/lhapdf/PDFsets/{1}".format(self.spec.prefix.share, pdf), - ) - - @run_after("install") - def copy_examples(self): - with working_dir(self.stage.source_path): - install_tree("examples", self.prefix.examples) - with working_dir(self.prefix.examples): - for f in glob.glob("Makefile.*"): - os.remove(f) - for f in glob.glob("*.py"): - os.remove(f) - - def setup_build_environment(self, spack_env): - cxxstd_flag = ( - "" - if self.spec.variants["cxxstd"].value == "default" - else "cxx{0}_flag".format(self.spec.variants["cxxstd"].value) - ) - spack_env.append_flags("CXXFLAGS", getattr(self.compiler, cxxstd_flag)) diff --git a/packages/sbndcode/package.py b/packages/sbndcode/package.py index d87cd99b..92d8420f 100644 --- a/packages/sbndcode/package.py +++ b/packages/sbndcode/package.py @@ -91,6 +91,7 @@ class Sbndcode(CMakePackage): depends_on("marley", type=("build", "run")) depends_on("nug4", type=("build", "run")) depends_on("genie", type=("build", "run")) + depends_on("genie-xsec", type=("build", "run")) depends_on("ifdhc", type=("build", "run")) depends_on("libxml2", type=("build", "run")) # depends_on('nurandom', type=('build','run')) ??? @@ -151,6 +152,7 @@ def setup_run_environment(self, run_env): run_env.prepend_path("ROOT_INCLUDE_PATH", self.prefix.include) # Perl modules. run_env.prepend_path("PERL5LIB", os.path.join(self.prefix, "perllib")) + run_env.prepend_path("GENIE_INC", str(self.spec["genie"].prefix.include)) # Cleaup. sanitize_environments(run_env)