Skip to content

Commit

Permalink
Merge pull request #36 from AlexanderRichert-NOAA/ci_updates_nov2023
Browse files Browse the repository at this point in the history
Add IntelLLVM support & Spack-based CI
  • Loading branch information
edwardhartnett authored Nov 10, 2023
2 parents 525664c + de5236d commit a940431
Show file tree
Hide file tree
Showing 6 changed files with 197 additions and 2 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Intel
on:
push:
branches:
- develop
pull_request:
branches:
- develop

# Use custom shell with -l so .bash_profile is sourced which loads intel/oneapi/setvars.sh
# without having to do it in manually every step
defaults:
run:
shell: bash -leo pipefail {0}

jobs:
Intel:
runs-on: ubuntu-latest
strategy:
matrix:
compilers: ["CC=icc FC=ifort", "CC=icx FC=ifx"]

steps:

# See https://software.intel.com/content/www/us/en/develop/articles/oneapi-repo-instructions.html
- name: install-intel
run: |
cd /tmp
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB
echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt-get update
sudo apt-get install intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bash_profile
- name: checkout-pfunit
uses: actions/checkout@v2
with:
repository: Goddard-Fortran-Ecosystem/pFUnit
path: pfunit

- name: cache-pfunit
id: cache-pfunit
uses: actions/cache@v2
with:
path: ~/pfunit
key: pfunit-${{ runner.os }}-${{ matrix.compilers }}

- name: build-pfunit
if: steps.cache-pfunit.outputs.cache-hit != 'true'
run: |
cd pfunit
mkdir build
cd build
${{ matrix.compilers }} cmake .. -DSKIP_MPI=YES -DSKIP_ESMF=YES -DSKIP_FHAMCREST=YES -DCMAKE_INSTALL_PREFIX=~/pfunit -DCMAKE_BUILD_TYPE=Release
make -j2 VERBOSE=1
make install
- name: checkout
uses: actions/checkout@v4
with:
path: sfcio
submodules: true

- name: build
run: |
cd sfcio
mkdir build
cd build
${{ matrix.compilers }} cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit"
make -j2 VERBOSE=1
- name: test
run: |
cd $GITHUB_WORKSPACE/sfcio/build
make test VERBOSE=1
67 changes: 67 additions & 0 deletions .github/workflows/Spack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This is a CI workflow for the NCEPLIBS-sfcio project.
#
# This workflow builds sfcio with Spack, including installing with the "--test
# root" option to run the pFunit test. 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:
Spack:
strategy:
matrix:
os: ["ubuntu-latest"]

runs-on: ${{ matrix.os }}

steps:

- name: checkout-sfcio
uses: actions/checkout@v4
with:
path: sfcio

- name: spack-build-and-test
run: |
git clone -c feature.manyFiles=true https://github.com/jcsda/spack
. spack/share/spack/setup-env.sh
spack env create sfcio-env
spack env activate sfcio-env
cp $GITHUB_WORKSPACE/sfcio/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/sfcio/package.py
spack develop --no-clone --path $GITHUB_WORKSPACE/sfcio sfcio@develop
spack add sfcio@develop%gcc@11 +pfunit
spack external find cmake gmake m4 python
spack concretize
# Run installation and run pFunit testing
spack install --verbose --fail-fast --test root
# Run 'spack load' to check for obvious errors in setup_run_environment
spack load sfcio
ls $SFCIO_LIB
# This job validates the Spack recipe by making sure each cmake build option is represented
recipe-check:
runs-on: ubuntu-latest

steps:

- name: checkout-sfcio
uses: actions/checkout@v4
with:
path: sfcio

- 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/sfcio/CMakeLists.txt) ; do
echo "Checking for presence of '$opt' CMake option in package.py"
grep -cP "define.+\b${opt}\b" $GITHUB_WORKSPACE/sfcio/spack/package.py
done
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
"MinSizeRel" "RelWithDebInfo")
endif()

if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM|GNU|Clang|AppleClang)$")
message(
WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
endif()
Expand Down
3 changes: 3 additions & 0 deletions spack/README
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-sfcio, which is found under Spack as "sfcio".

Before each release of NCEPLIBS-sfcio, 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.
47 changes: 47 additions & 0 deletions spack/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 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 Sfcio(CMakePackage):
"""The SFCIO library provides an API to read the NCEP Spectral model surface
files.
This is part of the NCEPLIBS project."""

homepage = "https://noaa-emc.github.io/NCEPLIBS-sfcio"
url = "https://github.com/NOAA-EMC/NCEPLIBS-sfcio/archive/refs/tags/v1.4.1.tar.gz"
git = "https://github.com/NOAA-EMC/NCEPLIBS-sfcio"

maintainers("AlexanderRichert-NOAA", "Hang-Lei-NOAA", "edwardhartnett")

version("develop", branch="develop")
version("1.4.1", sha256="d9f900cf18ec1a839b4128c069b1336317ffc682086283443354896746b89c59")

variant("pfunit", default=False, description="Add pfunit dependency to enable testing")

depends_on("pfunit", when="+pfunit")

def cmake_args(self):
args = [self.define("ENABLE_TESTS", self.run_tests)]
return args

def setup_run_environment(self, env):
lib = find_libraries("libsfcio", root=self.prefix, shared=False, recursive=True)
# Only one library version, but still need to set _4 to make NCO happy
for suffix in ("4", ""):
env.set("SFCIO_LIB" + suffix, lib[0])
env.set("SFCIO_INC" + suffix, join_path(self.prefix, "include"))

def flag_handler(self, name, flags):
if self.spec.satisfies("%fj"):
if name == "fflags":
flags.append("-Free")
return (None, None, flags)

def check(self):
with working_dir(self.builder.build_directory):
make("test")
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Mark Potts, Kyle Gerheiser

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$")
set(CMAKE_Fortran_FLAGS
"-g -traceback -free -convert big_endian -assume byterecl ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
Expand Down

0 comments on commit a940431

Please sign in to comment.