Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 164 additions & 37 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,184 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application
name: Test GeoClaw

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

workflow_dispatch:

permissions:
contents: read

jobs:
build:
env:
CLAW: ${{ github.workspace }}

runs-on: ubuntu-latest
jobs:
tests:
name: >
${{ matrix.os }} - ${{ matrix.toolchain.compiler }} ${{ matrix.build }} - py ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Probably want to turn this off for a large matrix
matrix:
os: [ubuntu-latest, macos-latest]
build: [debug, opt]
python-version: [3.12]
toolchain:
- {compiler: gcc, version: 14}
- {compiler: gcc, version: 15}
# - {compiler: intel, version: '2025.0'}
# - {compiler: intel-classic, version: '2021.10'}
# - {compiler: nvidia-hpc, version: '25.1'} # does not build python
# - {compiler: lfortran, version: '0.45.0'} # lfortran not yet supported
# - {compiler: flang, version: '20.1.0'} # flang not yet supported
# include:
# 3.8 does not seem to work.
# - os: ubuntu-latest
# build: opt
# python-version: 3.8
# toolchain: {compiler: gcc, version: 14}
exclude:
- os: ubuntu-latest
toolchain: {compiler: gcc, version: 15}
- os: macos-latest
toolchain: {compiler: gcc, version: 14}

steps:
- name: Set up Python 3.10
uses: actions/setup-python@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6.2.0
with:
python-version: "3.10"
- name: Checkout clawpack
uses: actions/[email protected]
python-version: ${{ matrix.python-version }}

- name: Set up compilers
uses: fortran-lang/[email protected]
id: setup-fortran
with:
repository: clawpack/clawpack
- name: Install dependencies
compiler: ${{ matrix.toolchain.compiler }}
version: ${{ matrix.toolchain.version }}

- name: Install python dependencies
run: |
sudo apt-get update
sudo apt-get install gfortran
# sudo apt-get liblapack-pic
sudo apt-get install liblapack-dev
sudo apt-get install libnetcdf-dev libnetcdff-dev
python -m pip install --upgrade pip
pip install flake8 pytest
- name: Setup clawpack super repository
run: |
git submodule init
git submodule update
pip install --user -e .
- name: Setup geoclaw
run: |
cd geoclaw
git checkout ${{ github.ref }}
- name: Lint with flake8
pip install flake8 meson-python ninja pytest numpy pandas

- name: Checkout Clawpack
uses: actions/[email protected]
with:
repository: clawpack/clawpack
submodules: true

- name: Checkout GeoClaw branch
uses: actions/[email protected]
with:
path: geoclaw

- name: Install clawpack python
run: |
cd geoclaw
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude old_dtopotools.py
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
pip install --no-build-isolation --editable .

# Temporarily disable linting
# - name: Lint with flake8
# if: ${{ matrix.build == 'debug' }}
# run: |
# cd ${CLAW}/geoclaw
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude dev
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Test with pytest
run: |
cd geoclaw
pytest
if [ "${{ matrix.toolchain.compiler }}" = "gcc" ]; then
if [ "${{ matrix.build }}" = "debug" ]; then
export FFLAGS="-O0 -g -fcheck=all -fbacktrace -fbounds-check -ffpe-trap=invalid,zero,overflow -finit-real=nan -finit-integer=nan -Wall -Wunderflow -Wextra -Wconversion -Wuninitialized -Warray-bounds -Wshadow -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-unused-label -Wno-unused-but-set-variable"
export OMP_NUM_THREADS=1
elif [ "${{ matrix.build }}" = "opt" ]; then
# Removed -flto -march=native
export FFLAGS="-O1 -fopenmp -funroll-loops -finline-functions -ftree-vectorize -fstack-protector-strong"
export OMP_NUM_THREADS=2
else
echo "Unknown build type: ${{ matrix.build }}"
exit 1
fi
elif [ "${{ matrix.toolchain.compiler }}" = "intel-classic" ]; then
if [ "${{ matrix.build }}" = "debug" ]; then
export FFLAGS="-O0 -debug all -check all -warn all,nodec,interfaces -gen_interfaces -traceback -fpe0 -ftrapuv -init=snan,arrays -check bounds"
export OMP_NUM_THREADS=1
elif [ "${{ matrix.build }}" = "opt" ]; then
export FFLAGS="-O -qopenmp -unroll -finline-functions -inline-forceinline -ipo -ip"
export OMP_NUM_THREADS=2
fi
elif [ "${{ matrix.toolchain.compiler }}" = "intel" ]; then
if [ "${{ matrix.build }}" = "debug" ]; then
export FFLAGS="-O0 -debug all -check all -warn all,nodec,interfaces -gen_interfaces -traceback -fpe0 -ftrapuv -init=snan,arrays -check bounds"
export OMP_NUM_THREADS=1
elif [ "${{ matrix.build }}" = "opt" ]; then
export FFLAGS="-O -qopenmp -unroll -finline-functions -inline-forceinline -ipo -ip"
export OMP_NUM_THREADS=2
else
echo "Unknown build type: ${{ matrix.build }}"
exit 1
fi
elif [ "${{ matrix.toolchain.compiler }}" = "nvidia-hpc" ]; then
echo "nvidia-hpc compiler not yet supported"
exit 1
if [ "${{ matrix.build }}" = "debug" ]; then
export FFLAGS="-g -O0 -check all -traceback"
export OMP_NUM_THREADS=1
elif [ "${{ matrix.build }}" = "opt" ]; then
export FFLAGS="-O1 -qopenmp"
export OMP_NUM_THREADS=2
else
echo "Unknown build type: ${{ matrix.build }}"
exit 1
fi
elif [ "${{ matrix.toolchain.compiler }}" = "flang" ]; then
echo "flang compiler not yet supported"
exit 1
if [ "${{ matrix.build }}" = "debug" ]; then
export FFLAGS=""
export OMP_NUM_THREADS=1
elif [ "${{ matrix.build }}" = "opt" ]; then
export FFLAGS=""
export OMP_NUM_THREADS=2
else
echo "Unknown build type: ${{ matrix.build }}"
exit 1
fi
elif [ "${{ matrix.toolchain.compiler }}" = "lfortran" ]; then
if [ "${{ matrix.build }}" = "debug" ]; then
export FFLAGS=""
export OMP_NUM_THREADS=1
elif [ "${{ matrix.build }}" = "opt" ]; then
export FFLAGS="--fast --openmp"
export OMP_NUM_THREADS=2
else
echo "Unknown build type: ${{ matrix.build }}"
exit 1
fi
else
echo "Unknown compiler: ${{ matrix.toolchain.compiler }}"
exit 1
fi
echo "FFLAGS: $FFLAGS"
echo "OMP_NUM_THREADS: $OMP_NUM_THREADS"
cd ${CLAW}/geoclaw
# Temporarily only run a subset of tests to speed up CI. We can add more tests back in as we optimize the test suite.
pytest \
tests/test_units.py \
tests/test_util.py \
tests/test_topotools.py \
tests/test_storm.py \
tests/test_dtopotools.py \
examples/tsunami/bowl-slosh/test_bowl_slosh.py \
examples/storm-surge/ike/test_ike.py

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v7
with:
name: test_results
path: ${{ env.CLAW }}/geoclaw/*_output
if-no-files-found: ignore
10 changes: 10 additions & 0 deletions examples/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Configuration for PyTest"""

import pytest

def pytest_addoption(parser):
parser.addoption('--save', action='store_true')

@pytest.fixture
def save(request):
return request.config.getoption("--save", False)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
53
2008-09-13T07:00:00
2008-09-13 07:00:00

-1.04040000e+06 -3.70000000e+01 1.72000000e+01 1.54333332e+01 1.66680000e+05 1.00600000e+05 4.63000000e+05
-1.01880000e+06 -3.84000000e+01 1.73000000e+01 1.80055554e+01 1.66680000e+05 1.00500000e+05 4.63000000e+05
Expand Down
Loading
Loading