Feature: perfect restart and n-cores CI #531
Workflow file for this run
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
name: build | |
on: | |
push: | |
branches: [ main, v5.2.x ] | |
pull_request: | |
branches: [ main, v5.2.x ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
pr: | |
description: "PR to test" | |
required: true | |
jobs: | |
Model_Testing: | |
strategy: | |
fail-fast: false | |
matrix: | |
configuration: [nwm_ana, nwm_long_range, gridded, reach] | |
runs-on: ubuntu-latest | |
env: | |
MPI_HOME: /usr/share/miniconda | |
NETCDF: /usr/share/miniconda | |
NETCDF_INCLUDES: /usr/share/miniconda/include | |
NETCDF_LIBRARIES: /usr/share/miniconda/lib | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Checkout candidate (pull request / push) | |
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }} | |
uses: actions/checkout@v4 | |
with: | |
path: candidate | |
- name: Checkout candidate (manual) | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: gh repo clone ${{ github.repository }} candidate && cd candidate && gh pr checkout -R ${{ github.repository }} ${{ github.event.inputs.pr }} | |
- name: Checkout reference (pull request) | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.base.ref }} | |
path: reference | |
- name: Checkout reference (push) | |
if: ${{ github.event_name == 'push' }} | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.before }} | |
path: reference | |
- name: Checkout reference (manual) | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
env: | |
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
run: gh repo clone ${{ github.repository }} reference && cd reference && git checkout origin/$(gh pr view ${{ github.event.inputs.pr }} --json baseRefName --jq '.baseRefName') | |
- name: Install dependencies with apt-get | |
run: | | |
sudo apt-get update \ | |
&& sudo apt-get install -yq --no-install-recommends \ | |
wget \ | |
curl \ | |
bzip2 \ | |
ca-certificates \ | |
libhdf5-dev \ | |
gfortran \ | |
g++ \ | |
m4 \ | |
make \ | |
libswitch-perl \ | |
git \ | |
bc \ | |
openmpi-bin openmpi-common libopenmpi-dev \ | |
libxml2-dev \ | |
libnetcdf-dev \ | |
libnetcdff-dev | |
- name: Install dependencies with pip | |
run: | | |
python3 -m pip install matplotlib numpy xarray dask netCDF4 pygithub | |
- name: Compile reference | |
run: | | |
cd $GITHUB_WORKSPACE/reference | |
cmake -B build | |
make -C build -j | |
- name: Compile candidate | |
run: | | |
cd $GITHUB_WORKSPACE/candidate | |
cmake -B build | |
make -C build -j | |
- name: Run reference model | |
run: | | |
cd $GITHUB_WORKSPACE/reference/build/Run | |
make run-croton-${{ matrix.configuration }} | |
- name: Run candidate model | |
run: | | |
cd $GITHUB_WORKSPACE/candidate/build/Run | |
make run-croton-${{ matrix.configuration }} | |
- name: Compare output of serial runs | |
uses: ./.github/actions/compare-output | |
- name: Clean candidate model output | |
run: | | |
cd $GITHUB_WORKSPACE/candidate/build/Run | |
make clean | |
- name: Run parallel candidate model | |
run: | | |
cd $GITHUB_WORKSPACE/candidate/build/Run | |
make run-croton-${{ matrix.configuration }}-parallel | |
- name: Compare output of n-cores candidate model | |
uses: ./.github/actions/compare-output | |
# Testing perfect restart, not cleaning candidate model output | |
- name: Setup and run candidate model perfect restart startup | |
run: | | |
cd $GITHUB_WORKSPACE/candidate/build/Run | |
sed -i 's|RESTART_FILENAME_REQUESTED = "RESTART/RESTART.2011082600_DOMAIN1"|RESTART_FILENAME_REQUESTED = "./RESTART.2011090100_DOMAIN1"|' namelist.hrldas | |
sed -i 's/KDAY = 7/KDAY = 1/' namelist.hrldas | |
rm RESTART.2011090200_DOMAIN1 | |
make run-croton-${{ matrix.configuration }}-parallel | |
- name: Compare output of perfect restart candidate model | |
uses: ./.github/actions/compare-output |