Add MET, METplus packages (#39238)
* Add metplus package * Add met package * add metplus develop version * copyright year var/spack/repos/builtin/packages/met/package.py * copyright year var/spack/repos/builtin/packages/metplus/package.py --------- Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
This commit is contained in:
		| @@ -0,0 +1,11 @@ | |||||||
|  | --- a/src/basic/vx_util/main.cc	2023-03-31 10:07:46 | ||||||
|  | +++ b/src/basic/vx_util/main.cc	2023-06-02 16:26:38 | ||||||
|  | @@ -157,7 +157,7 @@ | ||||||
|  |   | ||||||
|  |  void set_user_id() { | ||||||
|  |     met_user_id = geteuid (); | ||||||
|  | -   register struct passwd *pw; | ||||||
|  | +   struct passwd *pw; | ||||||
|  |     pw = getpwuid (met_user_id); | ||||||
|  |     if (pw) met_user_name = string(pw->pw_name); | ||||||
|  |  } | ||||||
| @@ -0,0 +1,20 @@ | |||||||
|  | --- a/src/basic/vx_log/concat_string.h	2023-03-31 10:07:46 | ||||||
|  | +++ b/src/basic/vx_log/concat_string.h	2023-06-02 16:26:06 | ||||||
|  | @@ -146,7 +146,7 @@ | ||||||
|  |   | ||||||
|  |        void chomp(const char *);   //  removes trailing suffix, if possible | ||||||
|  |   | ||||||
|  | -      operator const std::string () const; | ||||||
|  | +      operator std::string () const; | ||||||
|  |   | ||||||
|  |        bool startswith(const char *) const; | ||||||
|  |        bool   endswith(const char *) const; | ||||||
|  | @@ -205,7 +205,7 @@ | ||||||
|  |  inline bool         ConcatString::empty()        const { return ( s ?  s->empty() : true ); } | ||||||
|  |  inline bool         ConcatString::nonempty()     const { return ( s ? !s->empty() : false ); } | ||||||
|  |   | ||||||
|  | -inline              ConcatString::operator const std::string () const { return ( s ? *s : 0 ); } | ||||||
|  | +inline              ConcatString::operator std::string () const { return ( s ? *s : 0 ); } | ||||||
|  |   | ||||||
|  |   | ||||||
|  |  //////////////////////////////////////////////////////////////////////// | ||||||
| @@ -0,0 +1,11 @@ | |||||||
|  | --- a/src/basic/vx_util/data_plane_util.cc	2022-03-18 22:29:42.000000000 -0400 | ||||||
|  | +++ b/src/basic/vx_util/data_plane_util.cc	2022-03-18 22:30:44.000000000 -0400 | ||||||
|  | @@ -253,7 +253,7 @@ | ||||||
|  |   | ||||||
|  |  #pragma omp parallel default(none)                 \ | ||||||
|  |     shared(mlog, dp, frac_dp, width, wrap_lon, t)   \ | ||||||
|  | -   shared(use_climo, cmn, csd, vld_t, bad)         \ | ||||||
|  | +   shared(use_climo, cmn, csd, vld_t, bad, shape)  \ | ||||||
|  |     private(x, y, n_vld, n_thr, gp, v) | ||||||
|  |     { | ||||||
|  |   | ||||||
							
								
								
									
										172
									
								
								var/spack/repos/builtin/packages/met/package.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								var/spack/repos/builtin/packages/met/package.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,172 @@ | |||||||
|  | # 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 Met(AutotoolsPackage): | ||||||
|  |     """Statistical tool that matches up grids with either | ||||||
|  |     gridded analyses or point observations and applies | ||||||
|  |     configurable methods to compute statistics and diagnostics""" | ||||||
|  | 
 | ||||||
|  |     homepage = "https://dtcenter.org/community-code/model-evaluation-tools-met" | ||||||
|  |     url = "https://github.com/dtcenter/MET/archive/refs/tags/v11.0.1.tar.gz" | ||||||
|  |     git = "https://github.com/dtcenter/MET" | ||||||
|  | 
 | ||||||
|  |     maintainers("AlexanderRichert-NOAA") | ||||||
|  | 
 | ||||||
|  |     version("develop", branch="develop") | ||||||
|  |     version("11.0.2", sha256="f720d15e1d6c235c9a41fd97dbeb0eb1082fb8ae99e1bcdcb5e51be9b50bdfbf") | ||||||
|  |     version("11.0.1", sha256="48d471ad4634f1b969d9358c51925ce36bf0a1cec5312a6755203a4794b81646") | ||||||
|  |     version("11.0.0", sha256="648ebb54d07ca099680f4fc23b7ef5095c1a8ac5537c0a5d0e8587bf15991cff") | ||||||
|  |     version("10.1.1", sha256="9827e65fbd1c64e776525bae072bc2d37d14465e85a952778dcc32a26d8b5c9e") | ||||||
|  |     version("10.1.0", sha256="8d4c1fb2311d8481ffd24e30e407a1b1bc72a6add9658d76b9c323f1733db336") | ||||||
|  |     version("10.0.1", sha256="8e965bb0eb8353229a730af511c5fa62bad9744606ab6a218d741d29eb5f3acd") | ||||||
|  |     version("10.0.0", sha256="92f37c8bd83c951d86026cce294a16e4d3aa6dd41905629d0a729fa1bebe668a") | ||||||
|  |     version("9.1.3", sha256="7356a5ad79ca961fd965cadd93a7bf6c73b3aa5fb1a01a932580b94e66d0d0c8") | ||||||
|  | 
 | ||||||
|  |     variant("openmp", default=True, description="Use OpenMP multithreading") | ||||||
|  |     variant("grib2", default=False, description="Enable compilation of utilities using GRIB2") | ||||||
|  |     variant("python", default=False, description="Enable python embedding") | ||||||
|  |     variant("lidar2nc", default=False, description="Enable compilation of lidar2nc") | ||||||
|  |     variant("modis", default=False, description="Enable compilation of modis") | ||||||
|  |     variant("graphics", default=False, description="Enable compilation of mode_graphics") | ||||||
|  | 
 | ||||||
|  |     depends_on("gsl") | ||||||
|  |     depends_on("bufr") | ||||||
|  |     depends_on("zlib") | ||||||
|  |     depends_on("netcdf-c") | ||||||
|  |     depends_on("netcdf-cxx4") | ||||||
|  |     depends_on("g2c", when="+grib2") | ||||||
|  | 
 | ||||||
|  |     depends_on("hdf-eos2", when="+modis") | ||||||
|  |     depends_on("hdf-eos2", when="+lidar2nc") | ||||||
|  |     depends_on("hdf", when="+modis") | ||||||
|  |     depends_on("hdf", when="+lidar2nc") | ||||||
|  | 
 | ||||||
|  |     depends_on("cairo", when="+graphics") | ||||||
|  |     depends_on("freetype", when="+graphics") | ||||||
|  | 
 | ||||||
|  |     depends_on("python@3.6.3:", when="+python", type=("build", "run")) | ||||||
|  |     depends_on("py-netcdf4", when="+python", type=("build", "run")) | ||||||
|  |     depends_on("py-numpy", when="+python", type=("build", "run")) | ||||||
|  |     depends_on("py-xarray", when="+python", type=("build", "run")) | ||||||
|  |     depends_on("py-pandas", when="+python", type=("build", "run")) | ||||||
|  | 
 | ||||||
|  |     patch("openmp_shape_patch.patch", when="@10.1.0") | ||||||
|  | 
 | ||||||
|  |     # https://github.com/JCSDA/spack-stack/issues/615 | ||||||
|  |     # TODO(srherbener) Apple clang 14.x is getting pickier! When these updates are | ||||||
|  |     # merged into the MET code base, the following two patches can be removed. | ||||||
|  |     patch("apple-clang-string-cast-operator.patch", when="@10.1.1: %apple-clang@14:") | ||||||
|  |     patch("apple-clang-no-register.patch", when="@10.1.1: %apple-clang@14:") | ||||||
|  | 
 | ||||||
|  |     def url_for_version(self, version): | ||||||
|  |         if version < Version("11"): | ||||||
|  |             release_date = { | ||||||
|  |                 "10.1.1": "20220419", | ||||||
|  |                 "10.1.0": "20220314", | ||||||
|  |                 "10.0.1": "20211201", | ||||||
|  |                 "10.0.0": "20210510", | ||||||
|  |                 "9.1.3": "20210319", | ||||||
|  |             } | ||||||
|  |             url = "https://github.com/dtcenter/MET/releases/download/v{0}/met-{0}.{1}.tar.gz" | ||||||
|  |             return url.format(version, release_date[str(version)]) | ||||||
|  |         else: | ||||||
|  |             url = "https://github.com/dtcenter/MET/archive/refs/tags/v{0}.tar.gz" | ||||||
|  |             return url.format(version) | ||||||
|  | 
 | ||||||
|  |     def setup_build_environment(self, env): | ||||||
|  |         spec = self.spec | ||||||
|  |         cppflags = [] | ||||||
|  |         ldflags = [] | ||||||
|  |         libs = [] | ||||||
|  | 
 | ||||||
|  |         gsl = spec["gsl"] | ||||||
|  |         env.set("MET_GSL", gsl.prefix) | ||||||
|  | 
 | ||||||
|  |         netcdfcxx = spec["netcdf-cxx4"] | ||||||
|  |         cppflags.append(netcdfcxx.libs.search_flags) | ||||||
|  |         ldflags.append(netcdfcxx.libs.ld_flags) | ||||||
|  |         libs.append(netcdfcxx.libs.link_flags) | ||||||
|  | 
 | ||||||
|  |         netcdfc = spec["netcdf-c"] | ||||||
|  |         if netcdfc.satisfies("+shared"): | ||||||
|  |             cppflags.append("-I" + netcdfc.prefix.include) | ||||||
|  |             ldflags.append("-L" + netcdfc.prefix.lib) | ||||||
|  |             libs.append(netcdfc.libs.link_flags) | ||||||
|  |         else: | ||||||
|  |             nc_config = which(os.path.join(netcdfc.prefix.bin, "nc-config")) | ||||||
|  |             cppflags.append(nc_config("--cflags", output=str).strip()) | ||||||
|  |             ldflags.append(nc_config("--libs", "--static", output=str).strip()) | ||||||
|  |             libs.append(nc_config("--libs", "--static", output=str).strip()) | ||||||
|  | 
 | ||||||
|  |         zlib = spec["zlib"] | ||||||
|  |         cppflags.append("-D__64BIT__") | ||||||
|  |         ldflags.append("-L" + zlib.prefix.lib) | ||||||
|  |         libs.append("-lz") | ||||||
|  | 
 | ||||||
|  |         bufr = spec["bufr"] | ||||||
|  |         shared_bufr = True if "+shared" in bufr else False | ||||||
|  |         bufr_libdir = find_libraries( | ||||||
|  |             "libbufr_4", root=bufr.prefix, shared=shared_bufr, recursive=True | ||||||
|  |         ).directories[0] | ||||||
|  |         env.set("BUFRLIB_NAME", "-lbufr_4") | ||||||
|  |         env.set("MET_BUFRLIB", bufr_libdir) | ||||||
|  | 
 | ||||||
|  |         if "+grib2" in spec: | ||||||
|  |             g2c = spec["g2c"] | ||||||
|  |             env.set("MET_GRIB2CLIB", g2c.libs.directories[0]) | ||||||
|  |             env.set("MET_GRIB2CINC", g2c.prefix.include) | ||||||
|  |             env.set("GRIB2CLIB_NAME", "-lg2c") | ||||||
|  | 
 | ||||||
|  |         if "+python" in spec: | ||||||
|  |             python = spec["python"] | ||||||
|  |             env.set("MET_PYTHON", python.command.path) | ||||||
|  |             env.set("MET_PYTHON_CC", "-I" + python.headers.directories[0]) | ||||||
|  |             py_ld = [python.libs.ld_flags] | ||||||
|  |             if spec["python"].satisfies("~shared"): | ||||||
|  |                 py_ld.append(spec["gettext"].libs.ld_flags) | ||||||
|  |                 py_ld.append(spec["gettext"].libs.ld_flags) | ||||||
|  |                 py_ld.append(spec["libiconv"].libs.ld_flags) | ||||||
|  |                 py_ld.append("-lutil") | ||||||
|  |             env.set("MET_PYTHON_LD", " ".join(py_ld)) | ||||||
|  | 
 | ||||||
|  |         if "+lidar2nc" in spec or "+modis" in spec: | ||||||
|  |             hdf = spec["hdf"] | ||||||
|  |             hdfeos = spec["hdf-eos2"] | ||||||
|  |             env.set("MET_HDF5", hdf.prefix) | ||||||
|  |             env.set("MET_HDFEOS", hdfeos.prefix) | ||||||
|  | 
 | ||||||
|  |         if "+graphics" in spec: | ||||||
|  |             cairo = spec["cairo"] | ||||||
|  |             freetype = spec["freetype"] | ||||||
|  |             env.set("MET_CAIRO", cairo.prefix) | ||||||
|  |             cppflags.append("-I" + cairo.prefix.include.cairo) | ||||||
|  |             env.set("MET_FREETYPE", freetype.prefix) | ||||||
|  | 
 | ||||||
|  |         env.set("CPPFLAGS", " ".join(cppflags)) | ||||||
|  |         env.set("LIBS", " ".join(libs)) | ||||||
|  |         env.set("LDFLAGS", " ".join(ldflags)) | ||||||
|  | 
 | ||||||
|  |     def configure_args(self): | ||||||
|  |         args = [] | ||||||
|  |         args.extend(self.enable_or_disable("grib2")) | ||||||
|  |         args.extend(self.enable_or_disable("python")) | ||||||
|  |         args.extend(self.enable_or_disable("openmp")) | ||||||
|  |         args.extend(self.enable_or_disable("lidar2nc")) | ||||||
|  |         args.extend(self.enable_or_disable("modis")) | ||||||
|  |         args.extend(self.enable_or_disable("mode_graphics", variant="graphics")) | ||||||
|  | 
 | ||||||
|  |         if self.spec.satisfies("%apple-clang@14:"): | ||||||
|  |             args.append("CXXFLAGS=-std=gnu++17") | ||||||
|  | 
 | ||||||
|  |         return args | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | #    def setup_run_environment(self, env): | ||||||
|  | #        env.set('MET_BASE', self.prefix) | ||||||
							
								
								
									
										63
									
								
								var/spack/repos/builtin/packages/metplus/package.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										63
									
								
								var/spack/repos/builtin/packages/metplus/package.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,63 @@ | |||||||
|  | # 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 Metplus(Package): | ||||||
|  |     """ | ||||||
|  |     METplus is a verification framework that spans a wide range of temporal | ||||||
|  |     (warn-on-forecast to climate) and spatial (storm to global) scales. | ||||||
|  |     """ | ||||||
|  | 
 | ||||||
|  |     homepage = "https://dtcenter.org/community-code/metplus" | ||||||
|  |     url = "https://github.com/dtcenter/METplus/archive/refs/tags/v4.1.0.tar.gz" | ||||||
|  |     git = "https://github.com/dtcenter/METplus" | ||||||
|  | 
 | ||||||
|  |     maintainers("AlexanderRichert-NOAA") | ||||||
|  | 
 | ||||||
|  |     version("develop", branch="develop") | ||||||
|  |     version("5.0.1", sha256="0e22b4f6791496551d99f68247d382b2af02c90b34c172a64c6f060e774bdced") | ||||||
|  |     version("5.0.0", sha256="59d519bd062559b4cece9f8672e2e282b200057bc77e2e0937414003d8f2dd50") | ||||||
|  |     version("4.1.4", sha256="6b8ac395f885807fcbeea07d814bbf97cec343566cb37bee088a3c5b65880ac7") | ||||||
|  |     version("4.1.1", sha256="81c03474f57cef6c7196d65fba6427365fd761578d99804c6c367f21a29b8ced") | ||||||
|  |     version("4.1.0", sha256="4e4d74be64c9c57b910824ebefff42eb3a9bb7e8e325d86b7a3f7fdd59d3e45d") | ||||||
|  |     version("4.0.0", sha256="650c65b0cf1f1993209e69e469903c83fb4ae3c693060d8392fc1dece52493e2") | ||||||
|  |     version("3.1.1", sha256="d137420c56b2736b09ab713300f25c16e1d6fe523d3f3e4d811471aed83b0d85") | ||||||
|  | 
 | ||||||
|  |     variant("tcmpr_plotter", default=False, description="Enable TCMPRPlotter.") | ||||||
|  |     variant("series_analysis", default=False, description="Enable CyclonePlotter wrapper.") | ||||||
|  |     variant("cycloneplotter", default=False, description="Enable CyclonePlotter wrapper.") | ||||||
|  |     variant("makeplots", default=False, description="Enable MakePlots Wrapper.") | ||||||
|  |     variant("plotdataplane", default=False, description="Generate images from Postscript output.") | ||||||
|  | 
 | ||||||
|  |     depends_on("met+python", type=("run")) | ||||||
|  |     depends_on("py-python-dateutil", type=("run")) | ||||||
|  | 
 | ||||||
|  |     depends_on("py-cartopy", when="+makeplots", type=("run")) | ||||||
|  |     depends_on("py-matplotlib", when="+cycloneplotter", type=("run")) | ||||||
|  |     depends_on("py-cartopy", when="+cycloneplotter", type=("run")) | ||||||
|  | 
 | ||||||
|  |     depends_on("r", when="+tcmpr_plotter", type=("run")) | ||||||
|  |     depends_on("imagemagick", when="+series_analysis", type=("run")) | ||||||
|  |     depends_on("imagemagick", when="+plotdataplane", type=("run")) | ||||||
|  | 
 | ||||||
|  |     def install(self, spec, prefix): | ||||||
|  |         if spec.satisfies("@4.0.0:"): | ||||||
|  |             conf = "defaults.conf" | ||||||
|  |         else: | ||||||
|  |             conf = "metplus_system.conf" | ||||||
|  | 
 | ||||||
|  |         metplus_config = FileFilter(join_path("parm", "metplus_config", conf)) | ||||||
|  | 
 | ||||||
|  |         met_prefix = spec["met"].prefix | ||||||
|  |         metplus_config.filter( | ||||||
|  |             r"MET_INSTALL_DIR = /path/to", "MET_INSTALL_DIR = {}".format(met_prefix) | ||||||
|  |         ) | ||||||
|  | 
 | ||||||
|  |         install_tree(self.stage.source_path, prefix) | ||||||
|  | 
 | ||||||
|  |     def setup_run_environment(self, env): | ||||||
|  |         env.prepend_path("PATH", self.prefix.ush) | ||||||
		Reference in New Issue
	
	Block a user
	 Alex Richert
					Alex Richert