forked from NOAA-EMC/NCEPLIBS-ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e8bce8
commit af57730
Showing
4 changed files
with
166 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# This is a CI workflow for the NCEPLIBS-ip project. | ||
# | ||
# This workflow builds ip with Spack, including installing with the "--test | ||
# root" option to run the CTest suite. It also has a one-off job that validates | ||
# the recipe by ensuring that every CMake option that should be set in the | ||
# Spack recipe is so set. | ||
# | ||
# Alex Richert, Sep 2023 | ||
name: Spack | ||
on: | ||
push: | ||
branches: | ||
- develop | ||
pull_request: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
# This job builds with Spack using every combination of variants and runs the CTest suite each time | ||
Spack: | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest"] | ||
openmp: ["+openmp", "~openmp"] | ||
sharedlibs: ["+shared", "~shared"] | ||
pic: ["+pic", "~pic"] | ||
precision: ["precision=d", "precision=4", "precision=8"] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
|
||
- name: checkout-ip | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ip | ||
|
||
- name: spack-build-and-test | ||
run: | | ||
git clone -c feature.manyFiles=true https://github.com/spack/spack | ||
. spack/share/spack/setup-env.sh | ||
spack env create ip-env | ||
spack env activate ip-env | ||
cp $GITHUB_WORKSPACE/ip/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/ip/package.py | ||
mv $GITHUB_WORKSPACE/ip $SPACK_ENV/ip | ||
spack develop --no-clone ip@develop | ||
spack add ip@develop%gcc@11 ${{ matrix.openmp }} ${{ matrix.sharedlibs }} ${{ matrix.pic }} ${{ matrix.precision }} target=x86_64 | ||
spack external find cmake gmake | ||
spack concretize | ||
# Run installation and run CTest suite | ||
spack install --verbose --fail-fast --test root | ||
# Run 'spack load' to check for obvious errors in setup_run_environment | ||
spack load ip | ||
# This job validates the Spack recipe by making sure each cmake build option is represented | ||
recipe-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: checkout-ip | ||
uses: actions/checkout@v4 | ||
with: | ||
path: ip | ||
|
||
- name: recipe-check | ||
run: | | ||
echo "If this jobs fails, look at the most recently output CMake option below and make sure that option appears in spack/package.py" | ||
for opt in $(grep -ioP '^option\(\K(?!(ENABLE_DOCS))[^ ]+' $GITHUB_WORKSPACE/ip/CMakeLists.txt) ; do | ||
echo "Checking for presence of '$opt' CMake option in package.py" | ||
grep -cP "define.+\b${opt}\b" $GITHUB_WORKSPACE/ip/spack/package.py | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This directory contains an authoritative, up-to-date Spack recipe for NCEPLIBS-ip, which is found under Spack as "ip". | ||
|
||
Before each release of NCEPLIBS-ip, this file should be updated to accommodate changes in build options, etc., and .github/workflows/spack.yml should be updated to exercise all variants. Only the version entry should need to be updated after the release prior to incorporation into the Spack repository and the JCSDA Spack fork. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# 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 Ip(CMakePackage): | ||
"""The NCEP general interpolation library (iplib) contains Fortran 90 | ||
subprograms to be used for interpolating between nearly all grids used at | ||
NCEP. This is part of the NCEPLIBS project.""" | ||
|
||
homepage = "https://noaa-emc.github.io/NCEPLIBS-ip" | ||
url = "https://github.com/NOAA-EMC/NCEPLIBS-ip/archive/refs/tags/v3.3.3.tar.gz" | ||
git = "https://github.com/NOAA-EMC/NCEPLIBS-ip" | ||
|
||
maintainers("AlexanderRichert-NOAA", "edwardhartnett", "Hang-Lei-NOAA") | ||
|
||
version("develop", branch="develop") | ||
version("4.2.0", sha256="9b9f47106822044ff224c6dfd9f140c146dffc833904f2a0c5db7b5d8932e39e") | ||
version("4.1.0", sha256="b83ca037d9a5ad3eb0fb1acfe665c38b51e01f6bd73ce9fb8bb2a14f5f63cdbe") | ||
version("4.0.0", sha256="a2ef0cc4e4012f9cb0389fab6097407f4c623eb49772d96eb80c44f804aa86b8") | ||
version( | ||
"3.3.3", | ||
sha256="d5a569ca7c8225a3ade64ef5cd68f3319bcd11f6f86eb3dba901d93842eb3633", | ||
preferred=True, | ||
) | ||
|
||
variant("openmp", description="Enable OpenMP threading", default=True) | ||
variant("pic", default=True, description="Build with position-independent-code") | ||
variant("shared", default=False, description="Build shared library", when="@4.1:") | ||
variant( | ||
"precision", | ||
default=["4", "d"], | ||
values=["4", "d"], | ||
multi=True, | ||
description="Set precision (_4/_d library versions)", | ||
when="@4.1:", | ||
) | ||
variant( | ||
"precision", | ||
default=["4", "d"], | ||
values=["4", "d", "8"], | ||
multi=True, | ||
description="Set precision (_4/_d/_8 library versions)", | ||
when="@4.2:", | ||
) | ||
|
||
depends_on("sp") | ||
depends_on("sp@:2.3.3", when="@:4.0") | ||
depends_on("sp precision=4", when="@4.1: precision=4") | ||
depends_on("sp precision=d", when="@4.1: precision=d") | ||
depends_on("sp precision=8", when="@4.1: precision=8") | ||
|
||
def cmake_args(self): | ||
args = [ | ||
self.define_from_variant("OPENMP", "openmp"), | ||
self.define_from_variant("CMAKE_POSITION_INDEPENDENT_CODE", "pic"), | ||
] | ||
|
||
if self.spec.satisfies("@4:"): | ||
args.append(self.define("BUILD_TESTING", self.run_tests)) | ||
|
||
if self.spec.satisfies("@4.1:"): | ||
args.append(self.define_from_variant("BUILD_SHARED_LIBS", "shared")) | ||
args.append(self.define("BUILD_4", self.spec.satisfies("precision=4"))) | ||
args.append(self.define("BUILD_D", self.spec.satisfies("precision=d"))) | ||
|
||
if self.spec.satisfies("@4.2:"): | ||
args.append(self.define("BUILD_8", self.spec.satisfies("precision=8"))) | ||
|
||
return args | ||
|
||
def setup_run_environment(self, env): | ||
suffixes = ( | ||
self.spec.variants["precision"].value | ||
if self.spec.satisfies("@4.1:") | ||
else ["4", "8", "d"] | ||
) | ||
shared = False if self.spec.satisfies("@:4.0") else self.spec.satisfies("+shared") | ||
for suffix in suffixes: | ||
lib = find_libraries( | ||
"libip_" + suffix, root=self.prefix, shared=shared, recursive=True | ||
) | ||
env.set("IP_LIB" + suffix, lib[0]) | ||
env.set("IP_INC" + suffix, join_path(self.prefix, "include_" + suffix)) | ||
|
||
def check(self): | ||
with working_dir(self.builder.build_directory): | ||
make("test") |