Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimenting with building using Spack or APT packages #52

Closed
wants to merge 19 commits into from
Closed
177 changes: 177 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: CI

on:
push:
branches: [develop]
pull_request:
workflow_dispatch:

jobs:
build-with-spack-packages:
name: Build (Spack)
runs-on: ubuntu-22.04
steps:
- name: Check out
uses: actions/checkout@v4
with:
submodules: true

- name: Set up Spack
uses: spack/setup-spack@v2
with:
ref: releases/v0.21
buildcache: true
color: true
path: spack

- name: Find compilers
run: spack compiler find --mixed-toolchain

- name: Install dependencies
run: spack install --no-check-signature esmf@8.4%gcc@13

- name: Configure
shell: spack-bash {0}
run: |
spack load esmf@8.4%gcc@13

spack load --list

FC=gfortran-13 cmake -S . -B build

- name: Build
run: cmake --build build

build-with-apt-packages:
name: Build (APT)
runs-on: ubuntu-22.04
steps:
- name: Check out
uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: sudo apt-get install -y libnetcdf-dev libnetcdff-dev
liblapack-dev libopenblas-dev mpi-default-dev mpi-default-bin

- name: Build ESMF
run: |
v="8.3.1" # ESMF
gcc="12"
esmf_base=$HOME/esmf

export ESMF_DIR=${esmf_base}/${v}-gcc-${gcc}
mkdir -p $ESMF_DIR
cd $esmf_base
wget https://github.com/esmf-org/esmf/archive/refs/tags/v${v}.tar.gz
tar xzvf v${v}.tar.gz --directory=/tmp && mv /tmp/esmf-${v}/* $ESMF_DIR

export ESMF_COMPILER=gfortran
export ESMF_LAPACK=netlib
export ESMF_COMM=mpi
export ESMF_PIO=internal
export ESMF_NETCDF=nc-config

export OMPI_FC=gfortran-${gcc}
export OMPI_CC=gcc-${gcc}
export OMPI_CXX=g++-${gcc}
export ESMF_F90COMPILER=mpifort
export ESMF_CCOMPILER=mpicc
export ESMF_CXXCOMPILER=mpic++
export ESMF_F90LINKER=/usr/bin/ld
export ESMF_CLINKER=/usr/bin/ld
export ESMF_CXXLINKER=/usr/bin/ld

cd $ESMF_DIR
make -j lib

echo "ESMFMKFILE=${ESMF_DIR}/lib/libO/Linux.gfortran.64.mpi.default/esmf.mk" >> "$GITHUB_ENV"

- name: Configure
run: FC=gfortran-12 cmake -S . -B build

- name: Build
run: cmake --build build

build-with-apt-packages-nompi:
name: Build (APT, no MPI)
runs-on: ubuntu-22.04
steps:
- name: Check out
uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: sudo apt-get install -y libnetcdf-dev libnetcdff-dev
liblapack-dev libopenblas-dev

- name: Build ESMF
run: |
v="8.3.1" # ESMF
gcc="12"
esmf_base=$HOME/esmf

export ESMF_DIR=${esmf_base}/${v}-gcc-${gcc}
mkdir -p $ESMF_DIR
cd $esmf_base
wget https://github.com/esmf-org/esmf/archive/refs/tags/v${v}.tar.gz
tar xzvf v${v}.tar.gz --directory=/tmp && mv /tmp/esmf-${v}/* $ESMF_DIR

export ESMF_COMPILER=gfortran
export ESMF_LAPACK=netlib
export ESMF_COMM=mpiuni
export ESMF_NETCDF=nc-config

export ESMF_F90COMPILER=gfortran-${gcc}
export ESMF_CCOMPILER=gcc-${gcc}
export ESMF_CXXCOMPILER=g++-${gcc}
export ESMF_F90LINKER=/usr/bin/ld
export ESMF_CLINKER=/usr/bin/ld
export ESMF_CXXLINKER=/usr/bin/ld

cd $ESMF_DIR
make -j lib

echo "ESMFMKFILE=${ESMF_DIR}/lib/libO/Linux.gfortran.64.mpiuni.default/esmf.mk" >> "$GITHUB_ENV"

- name: Configure
run: FC=gfortran-12 cmake -S . -B build

- name: Build
run: cmake --build build

build-with-apt-packages-nompi-archive:
name: Build (APT, no MPI, pre-built ESMF)
runs-on: ubuntu-22.04
steps:
- name: Check out
uses: actions/checkout@v4
with:
submodules: true

- name: Install dependencies
run: sudo apt-get install -y libnetcdf-dev libnetcdff-dev
liblapack-dev libopenblas-dev

- name: Fetch pre-built ESMF
run: |
v="8.3.1" # ESMF
gcc="12"
esmf_base=$HOME/esmf
esmf=${v}-gcc-${gcc}-mpiuni

export ESMF_DIR=${esmf_base}/${esmf}
mkdir -p $ESMF_DIR
cd $ESMF_DIR
wget https://github.com/zmoon/gha-esmf/releases/download/v0.0.5/${esmf}.tar.gz
tar xzvf ${esmf}.tar.gz

echo "ESMFMKFILE=${ESMF_DIR}/lib/libO/Linux.gfortran.64.mpiuni.default/esmf.mk" >> "$GITHUB_ENV"

- name: Configure
run: FC=gfortran-12 cmake -S . -B build

- name: Build
run: cmake --build build
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ target_include_directories(NEXUS_Shared
)

# find external libraries
find_package(MPI REQUIRED)
find_package(ESMF REQUIRED)
find_package(NetCDF REQUIRED COMPONENTS Fortran)

Expand Down