diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3bca275..578b166 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,6 +12,50 @@ env: MACOSX_DEPLOYMENT_TARGET: 14.0 jobs: + Run_standalone_tests_with_GFortran: + name: "Run standalone tests with GFortran" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] + steps: + - uses: actions/checkout@v4 + + - name: Setup Micromamba + uses: mamba-org/setup-micromamba@v2.0.2 + with: + micromamba-version: '2.0.4-0' + environment-file: ci/environment_gfortran.yml + + - name: Run standalone tests with GFortran with and without optimization + shell: bash -e -x -l {0} + run: | + cd tests + FC="gfortran" ./run_tests.sh + FC="gfortran -O3 -march=native" ./run_tests.sh + + Run_standalone_tests_with_LFortran: + name: "Run standalone tests with LFortran" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["macos-latest", "ubuntu-20.04"] + steps: + - uses: actions/checkout@v4 + + - name: Setup Micromamba + uses: mamba-org/setup-micromamba@v2.0.2 + with: + micromamba-version: '2.0.4-0' + environment-file: ci/environment_lfortran.yml + + - name: Run standalone tests with LFortran with and without optimization + shell: bash -e -x -l {0} + run: | + cd tests + FC="lfortran" ./run_tests.sh + FC="lfortran --fast" ./run_tests.sh + Compile_POT3D_with_GFortran: name: "Build POT3D and validate with GFortran" runs-on: ${{ matrix.os }} diff --git a/tests/run_tests.sh b/tests/run_tests.sh new file mode 100755 index 0000000..18e1b1d --- /dev/null +++ b/tests/run_tests.sh @@ -0,0 +1,32 @@ +set -ex + +MPIEXEC=${CONDA_PREFIX}/bin/mpiexec + +if [[ "$(uname)" == "Linux" ]]; then + CC=gcc +else + CC=clang +fi + +$CC -I$CONDA_PREFIX/include -c ../src/mpi_wrapper.c +$FC -c ../src/mpi_c_bindings.f90 +$FC -c ../src/mpi.f90 + +for file in *.f90; do + filename=$(basename "$file" .f90) + # TODO: currently "allreduce.f90" fails to compile, hence + # we skip that test for now + if [ "$filename" == "allreduce" ]; then + continue + fi + $FC -c $file + $FC mpi_wrapper.o mpi_c_bindings.o mpi.o $filename.o -o $filename -L$CONDA_PREFIX/lib -lmpi -Wl,-rpath,$CONDA_PREFIX/lib + + echo "Running $filename with 1 MPI rank..." + ${MPIEXEC} -np 1 $filename + echo "Done!" + + echo "Running $filename with 2 MPI rank..." + ${MPIEXEC} -np 2 $filename + echo "Done!" +done