Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7ac08f1
Switch to AMRClawTestRunner for acoustics 1d test
mandli Sep 12, 2025
125c9f0
Switch acoustics 1d test
mandli Sep 12, 2025
3490434
Remove old scripts and Makefile
mandli Sep 12, 2025
4d106ad
Convert advection 2d square test
mandli Sep 12, 2025
30314d4
Adjoint test is almost working
mandli Sep 15, 2025
6db51d9
Convert over existing unittest tests
mandli Mar 16, 2026
e8344ba
Update to new testing framework for acoustics 2d radial example
mandli Mar 16, 2026
f63aeb4
Change gcc opt testing flags to be a bit easier to debug
mandli Mar 16, 2026
e7d29cc
Convert to new test runner
mandli Mar 16, 2026
44656ea
Add better comment for testing in makefile
mandli Mar 16, 2026
a5fb822
Add support for adjoint testing
mandli Mar 16, 2026
c2a9245
Fix problem with new binary gauge test
mandli Mar 16, 2026
0171a66
Fix missing keyword arg
mandli Mar 16, 2026
6f27fbb
Regress to older regression data
mandli Mar 16, 2026
3ee30fe
Switch to ClawpackTestRunner generic functions
mandli Apr 1, 2026
07d6f41
Fix adjoint testing to use general test functionality
mandli Apr 2, 2026
a0ceb11
Fix missing set_data call
mandli Apr 2, 2026
c9bfdd1
Import the correct test functions and add marks
mandli Apr 2, 2026
4ef21c7
Fix test archiving and turn on very verbose for CI
mandli Apr 2, 2026
8f7e6e6
Fix CLI test calling and add pytest.ini for marking
mandli Apr 3, 2026
e413634
Add missing save test attribute
mandli Apr 3, 2026
9220c25
Fix save attribute
mandli Apr 3, 2026
bc6c5fe
Update testing structure
mandli Apr 3, 2026
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
84 changes: 84 additions & 0 deletions .github/scripts/set_test_env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash

# Configure CI test environment variables for Clawpack workflows.
# Usage:
# source .github/scripts/set_test_env.sh <test_group> <compiler> <build>

set -euo pipefail

test_group="${1:-}"
compiler="${2:-}"
build="${3:-}"

if [[ -z "${test_group}" || -z "${compiler}" || -z "${build}" ]]; then
echo "Usage: source .github/scripts/set_test_env.sh <test_group> <compiler> <build>"
return 1 2>/dev/null || exit 1
fi

case "${test_group}" in
regression|slow)
case "${compiler}" in
gcc)
case "${build}" in
debug)
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
;;
opt)
# Removed -flto -march=native
export FFLAGS="-O1 -fopenmp -funroll-loops -finline-functions -ftree-vectorize -fstack-protector-strong"
export OMP_NUM_THREADS=2
;;
*)
echo "Unknown build type: ${build}"
return 1 2>/dev/null || exit 1
;;
esac
;;
intel|intel-classic)
case "${build}" in
debug)
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
;;
opt)
export FFLAGS="-O -qopenmp -unroll -finline-functions -inline-forceinline -ipo -ip"
export OMP_NUM_THREADS=2
;;
*)
echo "Unknown build type: ${build}"
return 1 2>/dev/null || exit 1
;;
esac
;;
lfortran)
case "${build}" in
debug)
export FFLAGS=""
export OMP_NUM_THREADS=1
;;
opt)
export FFLAGS="--fast --openmp"
export OMP_NUM_THREADS=2
;;
*)
echo "Unknown build type: ${build}"
return 1 2>/dev/null || exit 1
;;
esac
;;
nvidia-hpc|flang)
echo "${compiler} compiler not yet supported"
return 1 2>/dev/null || exit 1
;;
*)
echo "Unknown compiler: ${compiler}"
return 1 2>/dev/null || exit 1
;;
esac
;;
*)
echo "Unknown test group: ${test_group}"
return 1 2>/dev/null || exit 1
;;
esac
154 changes: 47 additions & 107 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ name: Test AMRClaw

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

branches: ["master"]
workflow_dispatch:

permissions:
Expand All @@ -15,30 +14,50 @@ env:
CLAW: ${{ github.workspace }}

jobs:
tests:
python-lint:
name: >
${{ matrix.os }} - ${{ matrix.toolchain.compiler }} ${{ matrix.build }} - py ${{ matrix.python-version }}
python-lint - ubuntu-latest - py ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.12', '3.13']

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ matrix.python-version }}

- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install flake8

- name: Checkout AMRClaw branch
uses: actions/checkout@v6.0.2

- name: Lint with flake8
run: |
cd ${CLAW}
# 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

regression-tests:
name: >
regression - ${{ 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
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
build: [debug, opt]
python-version: [3.12]
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}
Expand All @@ -47,12 +66,12 @@ jobs:

steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6.2.0
with:
python-version: ${{ matrix.python-version }}

- name: Set up compilers
uses: fortran-lang/setup-fortran@v1
uses: fortran-lang/setup-fortran@v1.9.0
id: setup-fortran
with:
compiler: ${{ matrix.toolchain.compiler }}
Expand All @@ -64,111 +83,32 @@ jobs:
pip install flake8 meson-python ninja pytest numpy

- name: Checkout Clawpack
uses: actions/checkout@v4.1.5
uses: actions/checkout@v6.0.2
with:
repository: clawpack/clawpack
submodules: true

- name: Checkout AMRClaw branch
uses: actions/checkout@v4.1.5
uses: actions/checkout@v6.0.2
with:
path: amrclaw

- name: Install clawpack python
run: |
pip install --no-build-isolation --editable .

- name: Lint with flake8
if: ${{ matrix.build == 'debug' }}
- name: Run regression tests
run: |
cd ${CLAW}/amrclaw
# 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: |
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
export FFLAGS="-O1 -fopenmp -funroll-loops -finline-functions -ftree-vectorize -fstack-protector-strong -flto -march=native"
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
source .github/scripts/set_test_env.sh regression "${{ matrix.toolchain.compiler }}" "${{ matrix.build }}"
echo "FFLAGS: $FFLAGS"
echo "OMP_NUM_THREADS: $OMP_NUM_THREADS"
cd ${CLAW}/amrclaw
pytest
pytest --basetemp=${CLAW}/amrclaw/pytest_tmp -vv -s -o addopts=""

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: test_results
path: ${{ env.CLAW }}/amrclaw/*_output
name: test_results_${{ matrix.os }}_${{ matrix.toolchain.compiler }}_${{ matrix.build }}
path: ${{ env.CLAW }}/amrclaw/pytest_tmp
if-no-files-found: ignore
11 changes: 0 additions & 11 deletions examples/Makefile

This file was deleted.

55 changes: 21 additions & 34 deletions examples/acoustics_1d_adjoint/adjoint/test_acoustics_1d_adjoint.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,32 @@
#!/usr/bin/env python
"""
Test for the adjoint problem for 2D acoustics
Test for the adjoint problem for 1D acoustics
"""

import sys
import unittest
from pathlib import Path
import pytest

import clawpack.amrclaw.test as test
import clawpack.amrclaw.data as data

class Acoustics1DAdjointTest(test.AMRClawRegressionTest):
def set_adjoint_data(runner):
"""Set the adjoint data for the test case"""
runner.set_data()

def runTest(self, save=False):
@pytest.mark.regression
@pytest.mark.adjoint
def test_acoustics_1d_adjoint(tmp_path: Path, save: bool):
"""Acoustics 1D adjoint test"""

# Write out data files
self.load_rundata()

# self.rundata.clawdata.num_output_times = 10
# self.rundata.clawdata.tfinal = 1.0
runner = test.AMRClawTestRunner(tmp_path, test_path=Path(__file__).parent)

runner.set_data()
runner.write_data()
runner.build_executable()
runner.run_code()

# self.rundata.clawdata.use_fwaves = False
runner.check_gauge(gauge_id=0, save=save)
runner.check_gauge(gauge_id=1, save=save)

self.write_rundata_objects()

self.run_code()

# Perform Tests
self.check_gauges(save=save, gauge_id=0)
self.check_gauges(save=save, gauge_id=1)

self.success = True


if __name__=="__main__":
if len(sys.argv) > 1:
if bool(sys.argv[1]):
# Fake the setup and save out output
test = Acoustics1DAdjointTest()
try:
test.setUp()
test.runTest(save=True)
finally:
test.tearDown()
sys.exit(0)
unittest.main()
if __name__ == "__main__":
raise SystemExit(pytest.main([__file__]))
Loading
Loading