Skip to content

Commit

Permalink
Merge pull request #42 from AlexanderRichert-NOAA/ci_uppates_nov2023
Browse files Browse the repository at this point in the history
Add IntelLLVM support & Spack-based CI builds
  • Loading branch information
edwardhartnett authored Nov 10, 2023
2 parents 377b967 + fafd040 commit f47e8c0
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 16 deletions.
19 changes: 5 additions & 14 deletions .github/workflows/Intel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,33 @@ defaults:
jobs:
Intel:
runs-on: ubuntu-latest
env:
CC: icc
FC: ifort
strategy:
matrix:
compilers: ["CC=icc FC=ifort", "CC=icx FC=ifx"]

steps:

- name: checkout-wrf_io
uses: actions/checkout@v2
with:
path: wrf_io

- name: Installs
run: |
sudo apt-get install libnetcdf-dev libnetcdff-dev

# See https://software.intel.com/content/www/us/en/develop/articles/oneapi-repo-instructions.html
- name: install-dependencies
run: |
sudo apt-get update
sudo apt-get install libmpich-dev
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-dev-utilities intel-oneapi-mpi-devel intel-oneapi-openmp intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
sudo apt-get install intel-oneapi-openmp intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
sudo apt-get install libnetcdf-dev libnetcdff-dev
echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bash_profile
- name: build_wrf_io
run: |
set -x
cd wrf_io
mkdir build
cd build
cmake ..
make VERBOSE=1
85 changes: 85 additions & 0 deletions .github/workflows/Spack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This is a CI workflow for the NCEPLIBS-wrf_io project.
#
# This workflow builds wrf_io with Spack. 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, Nov 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-wrf-io
uses: actions/checkout@v4
with:
path: wrf-io

- name: cache-spack
id: cache-spack
uses: actions/cache@v3
with:
path: ~/spack-build-cache
key: spack-build-cache-${{ matrix.os }}-1

- name: spack-build-and-test
run: |
cd
git clone -c feature.manyFiles=true https://github.com/jcsda/spack
. spack/share/spack/setup-env.sh
spack env create wrf-io-env
spack env activate wrf-io-env
cp $GITHUB_WORKSPACE/wrf-io/spack/package.py $SPACK_ROOT/var/spack/repos/builtin/packages/wrf-io/package.py
spack develop --no-clone --path $GITHUB_WORKSPACE/wrf-io wrf-io@develop
spack add wrf-io@develop%gcc@11 ^netcdf-c ~blosc ~szip ~mpi ^hdf5~mpi
spack external find cmake gmake openmpi
spack config add "packages:openmpi:buildable:false"
for mirror in $(spack mirror list | awk '{print $1}'); do
spack mirror rm --scope defaults ${mirror}
done
spack mirror add spack-build-cache ~/spack-build-cache
spack concretize
# Run installation and run CTest suite
if [ "${{ steps.cache.outputs.cache-hit }}" == true ]; then deps=only; else deps=auto; fi
spack install --verbose --fail-fast --no-check-signature --use-buildcache package:never,dependencies:${deps} --test root
spack buildcache push --only dependencies --unsigned --allow-root ~/spack-build-cache wrf-io
- name: Upload test results
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: spackci-ctest-output-${{ matrix.os }}-${{ matrix.openmp }}
path: ${{ github.workspace }}/wrf-io/spack-build-*/Testing/Temporary/LastTest.log

# This job validates the Spack recipe by making sure each cmake build option is represented
recipe-check:
runs-on: ubuntu-latest

steps:

- name: checkout-wrf-io
uses: actions/checkout@v4
with:
path: wrf-io

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

if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU)$")
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM|GNU)$")
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-wrf_io, which is found under Spack as "wrf-io".

Before each release of NCEPLIBS-wrf_io, 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.
32 changes: 32 additions & 0 deletions spack/package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# 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 WrfIo(CMakePackage):
"""The WRFIO package is a lightweight WRF-IO API library for Unified
Post Processor (UPP). It reads wrf forecasts (WRF state plus
diagnostics).
This is part of the NCEPLIBS project."""

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

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

version("develop", branch="develop")
version("1.2.0", sha256="000cf5294a2c68460085258186e1f36c86d3d0d9c433aa969a0f92736b745617")

variant("openmp", default=False, description="Enable multithreading with OpenMP")

depends_on("netcdf-c")
depends_on("netcdf-fortran")

def cmake_args(self):
args = [self.define_from_variant("OPENMP", "openmp")]
return args
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NetCDF_VERSION VERSION_GREATER_EQUAL 4)
USE_NETCDF4_FEATURES)
endif()

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|IntelLLVM)$")
set(CMAKE_Fortran_FLAGS "-fpp -g -traceback -fp-model source -ftz -assume byterecl -convert big_endian -heap-arrays -nostdinc ${CMAKE_Fortran_FLAGS}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -w")
set(CMAKE_Fortran_FLAGS_DEBUG "-O0")
Expand Down

0 comments on commit f47e8c0

Please sign in to comment.