Skip to content

sima0_09_000: Complete CCPPization of gravity wave drag #355

sima0_09_000: Complete CCPPization of gravity wave drag

sima0_09_000: Complete CCPPization of gravity wave drag #355

name: Fortran Unit Tests
on:
push:
branches:
- 'staging/**'
- development
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
gcc-toolchain:
name: Build and run with GCC ${{ matrix.version }}
runs-on: ubuntu-24.04
strategy:
matrix:
version: [12, 13, 14]
env:
CC: gcc-${{ matrix.version }}
CXX: g++-${{ matrix.version }}
FC: gfortran-${{ matrix.version }}
PFUNIT_BUILD_TYPE: Release
PFUNIT_PATH: ${{ github.workspace }}/pFUnit
PFUNIT_REFERENCE: 'v4.13.0'
PIO_BUILD_TYPE: Release
PIO_PATH: ${{ github.workspace }}/ParallelIO
PIO_REFERENCE: 'pio2_6_7'
RRTMGP_DATA_REFERENCE: 'v1.9'
steps:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y libnetcdf-mpi-dev libnetcdff-dev libopenmpi-dev
- name: Checkout CAM-SIMA
uses: actions/checkout@v5
# pFUnit takes a while to build. Cache it if possible to save time on consecutive workflow runs.
- name: Cache pFUnit
id: cache-pfunit
uses: actions/cache@v4
with:
key: cache-pfunit-${{ env.PFUNIT_REFERENCE }}-gcc-v${{ matrix.version }}-cam-sima
path: ${{ env.PFUNIT_PATH }}/install
# If there is a cache hit, just use the cached pFUnit and skip this step.
- name: Checkout pFUnit
if: ${{ steps.cache-pfunit.outputs.cache-hit != 'true' }}
uses: actions/checkout@v5
with:
repository: Goddard-Fortran-Ecosystem/pFUnit
ref: ${{ env.PFUNIT_REFERENCE }}
path: pFUnit
# If there is a cache hit, just use the cached pFUnit and skip this step.
- name: Build pFUnit
if: ${{ steps.cache-pfunit.outputs.cache-hit != 'true' }}
run: |
cmake \
-D CMAKE_BUILD_TYPE="$PFUNIT_BUILD_TYPE" \
-D CMAKE_INSTALL_PREFIX="$PFUNIT_PATH/install" \
-B "$PFUNIT_PATH/build" \
-S "$PFUNIT_PATH"
cmake --build "$PFUNIT_PATH/build" --config "$PFUNIT_BUILD_TYPE"
cmake --install "$PFUNIT_PATH/build" --config "$PFUNIT_BUILD_TYPE" --prefix "$PFUNIT_PATH/install"
- name: Checkout PIO
uses: actions/checkout@v5
with:
repository: NCAR/ParallelIO
ref: ${{ env.PIO_REFERENCE }}
path: ParallelIO
- name: Build PIO
env:
CC: mpicc
CXX: mpic++
FC: mpifort
run: |
cmake \
-D CMAKE_BUILD_TYPE="$PIO_BUILD_TYPE" \
-D CMAKE_INSTALL_PREFIX="$PIO_PATH/install" \
-D NetCDF_C_LIBRARY="/usr/lib/x86_64-linux-gnu/libnetcdf_mpi.so" \
-D NetCDF_Fortran_LIBRARY="/usr/lib/x86_64-linux-gnu/libnetcdff.so" \
-D PIO_ENABLE_DOC=OFF \
-D PIO_ENABLE_TESTS=OFF \
-D PIO_ENABLE_TIMING=OFF \
-D WITH_PNETCDF=OFF \
-B "$PIO_PATH/build" \
-S "$PIO_PATH"
cmake --build "$PIO_PATH/build" --config "$PIO_BUILD_TYPE"
cmake --install "$PIO_PATH/build" --config "$PIO_BUILD_TYPE" --prefix "$PIO_PATH/install"
- name: Checkout atmospheric_physics
run: |
bin/git-fleximod update ncar-physics ccpp-framework share
- name: Checkout rrtmgp-data for PIO file reader tests
uses: actions/checkout@v5
with:
repository: earth-system-radiation/rrtmgp-data
ref: ${{ env.RRTMGP_DATA_REFERENCE }}
path: rrtmgp-data
- name: Build Fortran unit tests
run: |
cmake \
-D CMAKE_PREFIX_PATH="$PFUNIT_PATH/install;$PIO_PATH/install" \
-D CAM_SIMA_ENABLE_CODE_COVERAGE=ON \
-D CAM_SIMA_ENABLE_IO_TESTS=ON \
-D CAM_SIMA_ENABLE_TESTS=ON \
-B ./build \
-S ./test/unit/fortran
cd build
make
- name: Run Fortran unit tests
run: |
ctest \
--output-junit test_results.xml \
--output-on-failure \
--test-dir ./build \
--test-output-size-failed 524288 \
--test-output-size-passed 524288 \
--verbose
- 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