From 31730ac2c3f44ef32e3078e05daf8b9dcc8e88dd Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 15 Aug 2023 15:26:07 -0400 Subject: [PATCH 1/5] add gcc.yaml and spack recipe --- .github/workflows/gcc.yaml | 111 +++++++++++++++++++++++++++++++++++++ ci/spack.yaml | 23 ++++++++ 2 files changed, 134 insertions(+) create mode 100644 .github/workflows/gcc.yaml create mode 100644 ci/spack.yaml diff --git a/.github/workflows/gcc.yaml b/.github/workflows/gcc.yaml new file mode 100644 index 000000000..d417e8139 --- /dev/null +++ b/.github/workflows/gcc.yaml @@ -0,0 +1,111 @@ +name: GCC Linux Build +on: [push, pull_request, workflow_dispatch] + + +# Use custom shell with -l so .bash_profile is sourced +# without having to do it in manually every step +defaults: + run: + shell: bash -leo pipefail {0} + +env: + cache_key: gcc + CC: gcc-10 + FC: gfortran-10 + CXX: g++-10 + +# The jobs are split into: +# 1. a dependency build step (setup), and +# 2. a UFS-utils build step (build) +# 3. a future UFS-utils test step (test) +# The setup is run once and the environment is cached, +# so each build of UFS-utils can reuse the cached dependencies to save time (and compute). + +jobs: + setup: + runs-on: ubuntu-latest + + steps: + - name: checkout-ufs_utils # This is for getting spack.yaml + uses: actions/checkout@v2 + with: + path: ufs_utils + + # Cache spack, compiler and dependencies + - name: cache-env + id: cache-env + uses: actions/cache@v2 + with: + path: | + spack + ~/.spack + key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} + + # Install dependencies using Spack + - name: install-dependencies-with-spack + if: steps.cache-env.outputs.cache-hit != 'true' + run: | + git clone -c feature.manyFiles=true https://github.com/JCSDA/spack.git + source spack/share/spack/setup-env.sh + spack env create ufs_utils-env ufs_utils/ci/spack.yaml + spack env activate ufs_utils-env + sudo apt install cmake + spack external find + spack add mpich@3.4.2 + spack concretize + spack install -v --fail-fast --dirty + spack clean --all + + build: + needs: setup + runs-on: ubuntu-latest + + steps: + - name: checkout-ufs_utils + uses: actions/checkout@v2 + with: + path: ufs_utils + + - name: cache-env + id: cache-env + uses: actions/cache@v2 + with: + path: | + spack + ~/.spack + key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} + + - name: build-ufs_utils + run: | + source spack/share/spack/setup-env.sh + spack env activate ufs_utils-env + export CC=mpicc + export FC=mpif90 + cd ufs_utils + mkdir -p build && cd build + cmake -DCMAKE_INSTALL_PREFIX=../install .. + make -j2 VERBOSE=1 + make install + ctest --verbose --rerun-failed --output-on-failure + + test: + needs: build + runs-on: ubuntu-latest + + steps: + - name: cache-env + id: cache-env + uses: actions/cache@v2 + with: + path: | + spack + ~/.spack + key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} + + - name: ctest + run: | + source spack/share/spack/setup-env.sh + spack env activate ufs_utils-env + cd ufs_utils + cd build + ctest --verbose --rerun-failed --output-on-failure diff --git a/ci/spack.yaml b/ci/spack.yaml new file mode 100644 index 000000000..440f4023b --- /dev/null +++ b/ci/spack.yaml @@ -0,0 +1,23 @@ +# Spack environment file to build UFS utilities dependencies +spack: + packages: + all: + compiler: + - intel + - gcc@10:10 + specs: + - netcdf-c@4.7.4 + - netcdf-fortran@4.5.3 + - bacio@2.4.1 + - g2@3.4.5 + - ip@3.3.3 + - nemsio@2.5.4 + - sp@2.3.3 + - w3emc@2.9.2 + - sfcio@1.4.1 + - sigio@2.3.2 + - nccmp@1.9.0.1 + - esmf@8.4.2~debug + view: true + concretizer: + unify: true From 8f51da40849215773e2a913b5bdfbd163cbe86b8 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 15 Aug 2023 15:41:56 -0400 Subject: [PATCH 2/5] add intel.yaml --- .github/workflows/gcc.yaml | 16 ++--- .github/workflows/intel.yaml | 126 +++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/intel.yaml diff --git a/.github/workflows/gcc.yaml b/.github/workflows/gcc.yaml index d417e8139..aa24340be 100644 --- a/.github/workflows/gcc.yaml +++ b/.github/workflows/gcc.yaml @@ -1,4 +1,4 @@ -name: GCC Linux Build +name: GCC Linux Build and Test on: [push, pull_request, workflow_dispatch] @@ -19,17 +19,19 @@ env: # 2. a UFS-utils build step (build) # 3. a future UFS-utils test step (test) # The setup is run once and the environment is cached, -# so each build of UFS-utils can reuse the cached dependencies to save time (and compute). +# so each subsequent build and test of UFS-utils can reuse the cached +# dependencies to save time (and compute). jobs: setup: runs-on: ubuntu-latest steps: - - name: checkout-ufs_utils # This is for getting spack.yaml - uses: actions/checkout@v2 + - name: checkout-ufs_utils + uses: actions/checkout@v3 with: path: ufs_utils + submodules: true # Cache spack, compiler and dependencies - name: cache-env @@ -61,11 +63,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: checkout-ufs_utils - uses: actions/checkout@v2 - with: - path: ufs_utils - - name: cache-env id: cache-env uses: actions/cache@v2 @@ -86,7 +83,6 @@ jobs: cmake -DCMAKE_INSTALL_PREFIX=../install .. make -j2 VERBOSE=1 make install - ctest --verbose --rerun-failed --output-on-failure test: needs: build diff --git a/.github/workflows/intel.yaml b/.github/workflows/intel.yaml new file mode 100644 index 000000000..39072d807 --- /dev/null +++ b/.github/workflows/intel.yaml @@ -0,0 +1,126 @@ +name: Intel Linux Build and Test +on: [push, pull_request, workflow_dispatch] + +# 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} + +# Set I_MPI_CC/F90 so Intel MPI wrapper uses icc/ifort instead of gcc/gfortran +env: + cache_key: intel + CC: icc + FC: ifort + CXX: icpc + I_MPI_CC: icc + I_MPI_F90: ifort + +# The jobs are split into: +# 1. a dependency build step (setup), and +# 2. a UFS-utils build step (build) +# 3. a UFS-utils test step (test) +# The setup is run once and the environment is cached, +# so each subsequent build and test of UFS-utils can reuse the cached +# dependencies to save time (and compute). + +jobs: + setup: + runs-on: ubuntu-20.04 + + steps: + - name: checkout-ufs_utils + if: steps.cache-env.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + path: ufs_utils + submodules: true + + # Cache spack, compiler and dependencies + - name: cache-env + id: cache-env + uses: actions/cache@v3 + with: + path: | + spack + ~/.spack + /opt/intel + key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} + + - name: install-intel-compilers + run: | + 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 + 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 + echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bash_profile + + # Install dependencies using Spack + - name: install-dependencies-with-spack + if: steps.cache-env.outputs.cache-hit != 'true' + run: | + git clone -c feature.manyFiles=true https://github.com/NOAA-EMC/spack.git + source spack/share/spack/setup-env.sh + spack env create ufs_utils-env ufs_utils/ci/spack.yaml + spack env activate ufs_utils-env + spack compiler find + sudo apt install cmake + spack external find + spack add intel-oneapi-mpi + spack concretize + spack install --dirty -v --fail-fast + spack clean --all + + build: + needs: setup + runs-on: ubuntu-20.04 + + steps: + - name: install-intel + run: | + echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bash_profile + + - name: cache-env + id: cache-env + uses: actions/cache@v3 + with: + path: | + spack + ~/.spack + /opt/intel + key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} + + - name: build-ufs_utils + run: | + source spack/share/spack/setup-env.sh + spack env activate ufs_utils-env + export CC=mpiicc + export FC=mpiifort + cd ufs_utils + mkdir -p build && cd build + cmake -DCMAKE_INSTALL_PREFIX=../install .. + make -j2 VERBOSE=1 + make install + + test: + needs: build + runs-on: ubuntu-latest + + steps: + - name: cache-env + id: cache-env + uses: actions/cache@v2 + with: + path: | + spack + ~/.spack + key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} + + - name: ctest + run: | + source spack/share/spack/setup-env.sh + spack env activate ufs_utils-env + cd ufs_utils + cd build + From 20bb211ea89f640aa29a9f1942446f98cb71b50a Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 15 Aug 2023 16:26:23 -0400 Subject: [PATCH 3/5] build external pio for esmf; --- ci/spack.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/spack.yaml b/ci/spack.yaml index 440f4023b..ffbf1c97c 100644 --- a/ci/spack.yaml +++ b/ci/spack.yaml @@ -17,7 +17,8 @@ spack: - sfcio@1.4.1 - sigio@2.3.2 - nccmp@1.9.0.1 - - esmf@8.4.2~debug + - parallelio@2.5.9+fortran~pnetcdf + - esmf@8.4.2~debug~xerces+external-parallelio view: true concretizer: unify: true From a73cb439bb360a4efb2fa5fa3ec1ccdd55a6bcf0 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 15 Aug 2023 18:07:50 -0400 Subject: [PATCH 4/5] fix errors in checkout --- .github/workflows/gcc.yaml | 30 ++++++++++-------------------- .github/workflows/intel.yaml | 31 ++++++++++--------------------- 2 files changed, 20 insertions(+), 41 deletions(-) diff --git a/.github/workflows/gcc.yaml b/.github/workflows/gcc.yaml index aa24340be..bb89ad10b 100644 --- a/.github/workflows/gcc.yaml +++ b/.github/workflows/gcc.yaml @@ -16,8 +16,7 @@ env: # The jobs are split into: # 1. a dependency build step (setup), and -# 2. a UFS-utils build step (build) -# 3. a future UFS-utils test step (test) +# 2. a UFS-utils build and test step (ufs_utils) # The setup is run once and the environment is cached, # so each subsequent build and test of UFS-utils can reuse the cached # dependencies to save time (and compute). @@ -27,11 +26,10 @@ jobs: runs-on: ubuntu-latest steps: - - name: checkout-ufs_utils + - name: checkout # this is to get the ci/spack.yaml file uses: actions/checkout@v3 with: path: ufs_utils - submodules: true # Cache spack, compiler and dependencies - name: cache-env @@ -58,11 +56,17 @@ jobs: spack install -v --fail-fast --dirty spack clean --all - build: + ufs_utils: needs: setup runs-on: ubuntu-latest steps: + - name: checkout + uses: actions/checkout@v3 + with: + path: ufs_utils + submodules: recursive + - name: cache-env id: cache-env uses: actions/cache@v2 @@ -72,7 +76,7 @@ jobs: ~/.spack key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} - - name: build-ufs_utils + - name: build run: | source spack/share/spack/setup-env.sh spack env activate ufs_utils-env @@ -84,20 +88,6 @@ jobs: make -j2 VERBOSE=1 make install - test: - needs: build - runs-on: ubuntu-latest - - steps: - - name: cache-env - id: cache-env - uses: actions/cache@v2 - with: - path: | - spack - ~/.spack - key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} - - name: ctest run: | source spack/share/spack/setup-env.sh diff --git a/.github/workflows/intel.yaml b/.github/workflows/intel.yaml index 39072d807..83d52b136 100644 --- a/.github/workflows/intel.yaml +++ b/.github/workflows/intel.yaml @@ -18,8 +18,7 @@ env: # The jobs are split into: # 1. a dependency build step (setup), and -# 2. a UFS-utils build step (build) -# 3. a UFS-utils test step (test) +# 2. a UFS-utils build and test step (ufs_utils) # The setup is run once and the environment is cached, # so each subsequent build and test of UFS-utils can reuse the cached # dependencies to save time (and compute). @@ -29,12 +28,10 @@ jobs: runs-on: ubuntu-20.04 steps: - - name: checkout-ufs_utils - if: steps.cache-env.outputs.cache-hit != 'true' + - name: checkout # this is to get the ci/spack.yaml file uses: actions/checkout@v3 with: path: ufs_utils - submodules: true # Cache spack, compiler and dependencies - name: cache-env @@ -72,7 +69,7 @@ jobs: spack install --dirty -v --fail-fast spack clean --all - build: + ufs_utils: needs: setup runs-on: ubuntu-20.04 @@ -81,6 +78,12 @@ jobs: run: | echo "source /opt/intel/oneapi/setvars.sh" >> ~/.bash_profile + - name: checkout + uses: actions/checkout@v3 + with: + path: ufs_utils + submodules: recursive + - name: cache-env id: cache-env uses: actions/cache@v3 @@ -91,7 +94,7 @@ jobs: /opt/intel key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} - - name: build-ufs_utils + - name: build run: | source spack/share/spack/setup-env.sh spack env activate ufs_utils-env @@ -103,20 +106,6 @@ jobs: make -j2 VERBOSE=1 make install - test: - needs: build - runs-on: ubuntu-latest - - steps: - - name: cache-env - id: cache-env - uses: actions/cache@v2 - with: - path: | - spack - ~/.spack - key: spack-${{ runner.os }}-${{ env.cache_key }}-${{ hashFiles('ufs_utils/ci/spack.yaml') }} - - name: ctest run: | source spack/share/spack/setup-env.sh From 0cd3302e82fcc495f17ca269b9bee2939b500e09 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Tue, 15 Aug 2023 18:19:31 -0400 Subject: [PATCH 5/5] run ctests w/ intel --- .github/workflows/intel.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/intel.yaml b/.github/workflows/intel.yaml index 83d52b136..ef801020a 100644 --- a/.github/workflows/intel.yaml +++ b/.github/workflows/intel.yaml @@ -112,4 +112,4 @@ jobs: spack env activate ufs_utils-env cd ufs_utils cd build - + ctest --verbose --rerun-failed --output-on-failure