Add MPI example #27
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
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build ESMF ${{ matrix.esmf_version }} | |
with GCC ${{ matrix.gcc_major_version }} | |
(${{ matrix.esmf_comm }}) | |
runs-on: ubuntu-22.04 | |
strategy: | |
matrix: | |
gcc_major_version: ["12"] | |
esmf_version: ["8.3.1", "8.4.2", "8.5.0", "8.6.1"] | |
esmf_comm: ["mpiuni", "mpi"] | |
steps: | |
- name: Check out | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: sudo apt-get install -y libnetcdf-dev libnetcdff-dev | |
liblapack-dev libopenblas-dev libopenmpi-dev openmpi-bin | |
- name: Build ESMF | |
run: | | |
v="${{ matrix.esmf_version }}" # ESMF | |
comm="${{ matrix.esmf_comm }}" | |
gcc="${{ matrix.gcc_major_version }}" | |
esmf_base=$HOME/esmf | |
export ESMF_DIR=${esmf_base}/${v}-gcc-${gcc}-${comm} | |
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=${comm} | |
export ESMF_NETCDF=nc-config | |
if [ "${comm}" == "mpiuni" ]; then | |
export ESMF_F90COMPILER=gfortran-${gcc} | |
export ESMF_CCOMPILER=gcc-${gcc} | |
export ESMF_CXXCOMPILER=g++-${gcc} | |
elif [ "${comm}" == "mpi" ]; then | |
export ESMF_PIO=internal | |
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++ | |
fi | |
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.${comm}.default/esmf.mk" >> "$GITHUB_ENV" | |
echo "ESMF_DIR=${ESMF_DIR}" >> "$GITHUB_ENV" | |
- name: Compress ESMF dir | |
run: | | |
du -sh ${{ env.ESMF_DIR }} | |
tar czvf ${{ env.ESMF_DIR }}.tar.gz --directory=${{ env.ESMF_DIR }} . | |
du -sh ${{ env.ESMF_DIR }}.tar.gz | |
- name: Upload ESMF dir as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: esmf-${{ matrix.esmf_version }}-gcc-${{ matrix.gcc_major_version }}-${{ matrix.esmf_comm }} | |
path: ${{ env.ESMF_DIR }}.tar.gz | |
retention-days: 1 | |
release: | |
name: Release | |
runs-on: ubuntu-22.04 | |
needs: build | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Download ESMF dir artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: | |
- name: List downloaded artifacts | |
run: ls -Al esmf-* | |
- name: Upload ESMFs to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./esmf-*/*.tar.gz | |
tag: ${{ github.ref }} | |
overwrite: true | |
file_glob: true |