Refactor MPAS dynamical core in preparation for unit testing (#407) #247
This file contains hidden or 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: Fortran Unit Tests | |
on: | |
push: | |
branches: | |
- development | |
- main | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
gcc-toolchain: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
version: [12, 13, 14] | |
env: | |
CC: gcc-${{ matrix.version }} | |
CXX: g++-${{ matrix.version }} | |
FC: gfortran-${{ matrix.version }} | |
steps: | |
- name: install dependencies | |
run: | | |
sudo apt install -y libnetcdff-dev libnetcdf-mpi-dev libopenmpi-dev openmpi-bin doxygen | |
- name: Checkout cam-sima | |
uses: actions/checkout@v4 | |
- name: Build pFUnit | |
run: | | |
git clone --depth 1 --branch v4.10.0 https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git | |
cd pFUnit | |
cmake -B./build -S. | |
cd build | |
make install | |
- name: Build PIO | |
run: | | |
git clone --depth 1 --branch pio2_6_6 https://github.com/NCAR/ParallelIO.git | |
cd ParallelIO | |
FC=$(which mpif90) \ | |
CC=$(which mpicc) \ | |
cmake -S./ -B./build \ | |
-DCMAKE_INSTALL_PREFIX=./install \ | |
-DPIO_ENABLE_TIMING=OFF \ | |
-DWITH_PNETCDF=OFF \ | |
-DCMAKE_PREFIX_PATH="/usr/lib/x86_64-linux-gnu/cmake/netCDF" \ | |
-DNetCDF_Fortran_LIBRARY="/usr/lib/x86_64-linux-gnu/libnetcdff.a" \ | |
-DNetCDF_C_LIBRARY="/usr/lib/x86_64-linux-gnu/libnetcdf.so" \ | |
-DCMAKE_EXE_LINKER_FLAGS="-lmpi -Wl,--no-as-needed" | |
cd build | |
make | |
make install | |
- name: Checkout atmospheric_physics | |
run: | | |
bin/git-fleximod update ncar-physics ccpp-framework share | |
- name: Build cam-sima | |
run: | | |
PIO_ROOT=$GITHUB_WORKSPACE/ParallelIO/install/ \ | |
cmake \ | |
-DCMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/pFUnit/build/installed;/usr/lib/x86_64-linux-gnu/cmake/netCDF;/usr/lib/x86_64-linux-gnu/" \ | |
-DCAM_SIMA_ENABLE_CODE_COVERAGE=ON \ | |
-DCAM_SIMA_ENABLE_IO_TESTS=ON \ | |
-DCAM_SIMA_ENABLE_TESTS=ON \ | |
-B./build \ | |
-S./test/unit/fortran | |
cd build | |
make | |
- name: Checkout datafiles for file IO reader tests | |
run: | | |
git clone https://github.com/earth-system-radiation/rrtmgp-data.git | |
- name: Run fortran unit tests | |
run: | | |
cd build && ctest -V --output-on-failure --output-junit test_results.xml | |
- name: Upload unit test results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: unit-test-results-${{ env.FC }} | |
path: build/test_results.xml | |
- name: Setup Gcov | |
run: | | |
python3 -m venv venv | |
source venv/bin/activate | |
pip3 install gcovr | |
- name: Run Gcov | |
run: | | |
source venv/bin/activate | |
cd build | |
gcovr --gcov-executable gcov-${{ matrix.version }} -r .. --filter '\.\./src' --html cam_sima_code_coverage.html --txt | |
- name: Upload code coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-results-${{ env.FC }} | |
path: build/cam_sima_code_coverage.html |