Skip to content

Commit

Permalink
Merge pull request #307 from makepath-alex/cmake-mac-win-dev
Browse files Browse the repository at this point in the history
Added basic CI for MacOS and Windows, using system and conda compilers on Linux
  • Loading branch information
RobertPincus authored Dec 11, 2024
2 parents 1d8baac + 2805eaf commit 3d99501
Show file tree
Hide file tree
Showing 17 changed files with 338 additions and 240 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
FCFLAGS: "-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -fmodule-private -fimplicit-none -finit-real=nan -g"
RRTMGP_ROOT: ${{ github.workspace }}
RTE_KERNELS: extern
RTE_BOOL: C
RTE_CBOOL: ON
RRTMGP_DATA_VERSION: v1.8.2
steps:
#
Expand All @@ -37,6 +37,6 @@ jobs:
-DCMAKE_Fortran_COMPILER=$FC \
-DCMAKE_Fortran_FLAGS="$FCFLAGS" \
-DRRTMGP_DATA_VERSION=$RRTMGP_DATA_VERSION \
-DBOOL_TYPE=$RTE_BOOL \
-DUSE_C_BOOL=$RTE_CBOOL \
-DKERNEL_MODE=$RTE_KERNELS
cmake --build build --config Release -- -j8
30 changes: 17 additions & 13 deletions .github/workflows/containerized-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
FCFLAGS: ${{ matrix.fcflags }}
# CMake variables:
NFHOME: /opt/netcdf-fortran
FP_MODEL: ${{ matrix.fpmodel }}
RTE_KERNELS: ${{ matrix.rte-kernels }}
RRTMGP_DATA_VERSION: v1.8.2
BUILD_TYPE: Debug
RUN_CMD:
# https://github.com/earth-system-radiation/rte-rrtmgp/issues/194
OMP_TARGET_OFFLOAD: DISABLED
Expand All @@ -71,7 +71,7 @@ jobs:
- name: Install Required Tools
run: |
apt-get update
apt-get install -y git cmake
apt-get install -y git cmake ninja-build
#
# Update Failure threshold if single precision
#
Expand All @@ -85,23 +85,27 @@ jobs:
id: build-success
if: matrix.fortran-compiler != 'ifx' || matrix.rte-kernels != 'accel'
run: |
$FC --version
cmake -S . -B build \
-DCMAKE_Fortran_COMPILER=$FC \
-DCMAKE_Fortran_FLAGS="$FCFLAGS" \
-DRRTMGP_DATA_VERSION=$RRTMGP_DATA_VERSION \
-DPRECISION=$FP_MODEL \
-DKERNEL_MODE=$RTE_KERNELS \
-DENABLE_TESTS=ON \
-DFAILURE_THRESHOLD=$FAILURE_THRESHOLD
cmake --build build --config Release -- -j8
# Run CMake
cmake -S . -B build -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_Fortran_COMPILER=${{ env.FC }} \
-DCMAKE_Fortran_FLAGS="${{ env.FCFLAGS }}" \
-DRRTMGP_DATA_VERSION=${{ env.RRTMGP_DATA_VERSION }} \
-DPRECISION=${{ matrix.fpmodel }} \
-DKERNEL_MODE=${{ env.RTE_KERNELS }} \
-DENABLE_TESTS=ON \
-DFAILURE_THRESHOLD=${{ env.FAILURE_THRESHOLD }}
# Build the project
cmake --build build -- -j8
#
# Run examples and tests
#
- name: Run examples and tests
working-directory: build
if: steps.build-success.outcome != 'skipped'
run: |
ctest -V --test-dir build
ctest -V
# Generate validation plots
#
- name: Generate validation plots
Expand Down
205 changes: 126 additions & 79 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Continuous Integration

on:
push:
branches:
- main
- develop
- main
- develop
pull_request:
branches-ignore:
- documentation
- documentation
workflow_dispatch:

defaults:
Expand All @@ -16,88 +17,134 @@ defaults:

jobs:
CI:
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
fortran-compiler: [gfortran-10, gfortran-11, gfortran-12]
os: [ubuntu-22.04, macos-13, windows-2022]
compiler: [gfortran-10, gfortran-11, gfortran-12, gfortran-13]
use-conda-compiler: [true, false]
fpmodel: [DP, SP]
# Conda does not contain gfortran-10/11/12 for windows
exclude:
- os: windows-2022
compiler: gfortran-10
- os: windows-2022
compiler: gfortran-11
- os: windows-2022
compiler: gfortran-12
- os: windows-2022
use-conda-compiler: false

- os: macos-13
use-conda-compiler: false

- os: ubuntu-22.04
use-conda-compiler: false
compiler: gfortran-13
env:
# Core variables:
FC: ${{ matrix.fortran-compiler }}
FCFLAGS: "-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -fmodule-private -fimplicit-none -finit-real=nan -g"
# CMake variables:
FCINCLUDE: -I/usr/include
FP_MODEL: ${{ matrix.fpmodel }}
FC: ${{ matrix.compiler }}
FCFLAGS: "-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -fmodule-private -fimplicit-none -finit-real=nan"
RTE_KERNELS: default
RTE_BOOL: C
RTE_CBOOL: ON
RRTMGP_DATA_VERSION: v1.8.2
RUN_CMD:
FAILURE_THRESHOLD: 7.e-4
# Debug - works
# Release - works with conda gfortran
# RelWithDebInfo - works
# MinSizeRel - works
BUILD_TYPE: Debug
runs-on: ${{ matrix.os }}
steps:
#
# Relax failure thresholds for single precision
#
- name: Relax failure threshold for single precision
if: matrix.fpmodel == 'SP'
run: echo "FAILURE_THRESHOLD=3.5e-1" >> $GITHUB_ENV
#
# Check out repository under $GITHUB_WORKSPACE
#
- name: Check out code
uses: actions/checkout@v4
#
# Check out data
#
# Synchronize the package index
#
- name: Synchronize the package index
run: sudo apt-get update
#
# Install NetCDF-Fortran (compatible with all compilers)
#
- name: Install NetCDF-Fortran
run: sudo apt-get install libnetcdff-dev
#
# Cache Conda packages
#
- name: Cache Conda packages
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: conda-pkgs
#
# Set up Conda
#
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: rte_rrtmgp_test
environment-file: environment-noplots.yml
python-version: 3.11
auto-activate-base: false
# Use the cache properly:
use-only-tar-bz2: true
#
# Build libraries, examples and tests
#
- name: Build libraries and tests
run: |
$FC --version
cmake -S . -B build \
-DCMAKE_Fortran_COMPILER=$FC \
-DCMAKE_Fortran_FLAGS="$FCFLAGS" \
-DPRECISION=$FP_MODEL \
-DBOOL_TYPE=$RTE_BOOL \
-DKERNEL_MODE=$RTE_KERNELS \
-DENABLE_TESTS=ON \
-DRRTMGP_DATA_VERSION=$RRTMGP_DATA_VERSION \
-DFAILURE_THRESHOLD=$FAILURE_THRESHOLD
cmake --build build --config Release -- -j8
#
# Run examples, tests and checks
#
- name: Run examples, tests and checks
run: |
ctest -V --test-dir build
#
# Relax failure thresholds for single precision
#
- name: Relax failure threshold for single precision
if: matrix.fpmodel == 'SP'
run: echo "FAILURE_THRESHOLD=3.5e-1" >> $GITHUB_ENV
#
# Check out repository under $GITHUB_WORKSPACE
#
- name: Check out code
uses: actions/checkout@v4
#
# Cache Conda packages
#
- name: Cache Conda packages
uses: actions/cache@v4
with:
path: ~/conda_pkgs_dir
key: conda-pkgs-${{ matrix.os }}
#
# Set up Conda
#
- name: Set up Conda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
activate-environment: rte_rrtmgp_test
environment-file: environment-noplots.yml
python-version: 3.11
auto-activate-base: false
# Use the cache properly:
use-only-tar-bz2: false
#
# Install dependencies
#
- name: Install dependencies
run: |
FC_VERSION="${{ env.FC }}"
FC_VERSION="${FC_VERSION##*-}"
echo "FC version: $FC_VERSION"
conda install -c conda-forge netcdf-fortran ninja -y
if ${{ matrix.use-conda-compiler }}; then
conda install -c conda-forge gfortran=$FC_VERSION -y
fi
#
# Build libraries, examples, and tests
#
- name: Build libraries and tests
run: |
AR_PATH="$(which ar)"
RANLIB_PATH="$(which ranlib)"
FC_PATH="$(which gfortran)"
if [[ "${{ matrix.os }}" == "windows-2022" ]]; then
AR_PATH="$AR_PATH.exe"
RANLIB_PATH="$RANLIB_PATH.exe"
FC_PATH="$FC_PATH.exe"
fi
# If not using conda, use the environment's FC variable instead of which gfortran
if ! ${{ matrix.use-conda-compiler }}; then
FC_PATH=${{ env.FC }}
fi
echo "Using AR: $AR_PATH"
echo "Using RANLIB: $RANLIB_PATH"
echo "Using FC: $FC_PATH"
# Run CMake
cmake -S . -B build -G "Ninja" \
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \
-DCMAKE_Fortran_COMPILER="$FC_PATH" \
-DCMAKE_Fortran_FLAGS="${{ env.FCFLAGS }}" \
-DCMAKE_AR="$AR_PATH" \
-DCMAKE_RANLIB="$RANLIB_PATH" \
-DRRTMGP_DATA_VERSION=${{ env.RRTMGP_DATA_VERSION }} \
-DPRECISION=${{ matrix.fpmodel }} \
-DUSE_C_BOOL=${{ env.RTE_CBOOL }} \
-DKERNEL_MODE=${{ env.RTE_KERNELS }} \
-DENABLE_TESTS=ON \
-DFAILURE_THRESHOLD=${{ env.FAILURE_THRESHOLD }}
# Build the project
cmake --build build -- -j8
#
# Run examples, tests and checks
#
- name: Run examples, tests and checks
working-directory: build
run: |
ctest -V --output-on-failure
2 changes: 1 addition & 1 deletion .gitlab/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# Build libraries, examples and tests
#
# - $FC -v
- cmake -S . -B build -DCMAKE_Fortran_COMPILER=$FC -DCMAKE_Fortran_FLAGS="$FCFLAGS" -DRRTMGP_DATA_VERSION=$RRTMGP_DATA_TAG -DPRECISION=$FPMODEL -DBOOL_TYPE=$RTE_BOOL -DKERNEL_MODE=$RTE_KERNELS -DENABLE_TESTS=ON -DFAILURE_THRESHOLD=$FAILURE_THRESHOLD
- cmake -S . -B build -DCMAKE_Fortran_COMPILER=$FC -DCMAKE_Fortran_FLAGS="$FCFLAGS" -DRRTMGP_DATA_VERSION=$RRTMGP_DATA_TAG -DPRECISION=$FPMODEL -DUSE_C_BOOL=$RTE_CBOOL -DKERNEL_MODE=$RTE_KERNELS -DENABLE_TESTS=ON -DFAILURE_THRESHOLD=$FAILURE_THRESHOLD
- cmake --build build --config Release -- -j8
#
# Run examples, tests and checks
Expand Down
Loading

0 comments on commit 3d99501

Please sign in to comment.