Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI build #730

Merged
merged 17 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
91 changes: 91 additions & 0 deletions .github/workflows/GCC.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# This is a CI workflow for the fv3atm project.
#
# This workflow builds and tests the fv3atm library using GCC, and it tests
# different CMake build options.
#
# Alex Richert, 6 Dec 2023

name: GCC
junwang-noaa marked this conversation as resolved.
Show resolved Hide resolved
on:
push:
branches:
- develop
pull_request:
branches:
- develop

jobs:
GCC:
runs-on: ubuntu-latest

strategy:
matrix:
cmake_opts: ["-D32BIT=ON", "-D32BIT=OFF"]
gcc_ver: ["11"]
mpi: ["mpich"]

steps:

- name: install-mpi
run: |
sudo apt-get install lib${{ matrix.mpi }}-dev

- name: checkout-fv3atm
uses: actions/checkout@v3
with:
path: ${{ github.workspace }}/fv3atm
submodules: recursive

- name: cache-spack
id: cache-spack
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/spack-develop
key: spack-${{ hashFiles('fv3atm/ci/spack.yaml') }}-gcc${{ matrix.gcc_ver }}-1

# Building dependencies takes 40+ min
- name: spack-install
if: steps.cache-spack.outputs.cache-hit != 'true'
run: |
wget --no-verbose https://github.com/spack/spack/archive/refs/heads/develop.zip
unzip develop.zip -d ${GITHUB_WORKSPACE}/ &> unzip.out
# temporary fix (https://github.com/spack/spack/pull/41475)
wget https://raw.githubusercontent.com/AlexanderRichert-NOAA/spack/e9b6ada157a65a486eb1e039fdbfe66c9eebb842/var/spack/repos/builtin/packages/fms/package.py
mv package.py ${GITHUB_WORKSPACE}/spack-develop/var/spack/repos/builtin/packages/fms/package.py
#
. ${GITHUB_WORKSPACE}/spack-develop/share/spack/setup-env.sh
spack env create gcc${{ matrix.gcc_ver }} ${GITHUB_WORKSPACE}/fv3atm/ci/spack.yaml
spack env activate gcc${{ matrix.gcc_ver }}
spack compiler find | grep gcc@${{ matrix.gcc_ver }}
spack external find gmake cmake git git-lfs perl python ${{ matrix.mpi }}
spack config add "packages:all:require:['%gcc@${{ matrix.gcc_ver }}']"
spack config add "packages:mpi:require:'${{ matrix.mpi }}'"
spack concretize |& tee ${SPACK_ENV}/log.concretize
spack install -j2 --fail-fast

- name: cache-save
uses: actions/cache/save@v3
if: ${{ always() }}
with:
path: ${{ github.workspace }}/spack-develop
key: spack-${{ hashFiles('fv3atm/ci/spack.yaml') }}-gcc${{ matrix.gcc_ver }}-1

- name: build-fv3atm
run: |
. ${GITHUB_WORKSPACE}/spack-develop/share/spack/setup-env.sh
spack env activate gcc${{ matrix.gcc_ver }}
spack load $(spack find --format "{name}")
cd ${GITHUB_WORKSPACE}/fv3atm
git clone https://github.com/NOAA-EMC/CMakeModules
git clone --recurse-submodules https://github.com/NOAA-PSL/stochastic_physics
mkdir ${GITHUB_WORKSPACE}/build
cd ${GITHUB_WORKSPACE}/build
cmake ${GITHUB_WORKSPACE}/fv3atm -DBUILD_TESTING=ON ${{ matrix.cmake_opts }}
make -j2

- name: debug-artifacts
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: ccpp_prebuild_logs
path: ${{ github.workspace }}/build/ccpp/ccpp_prebuild.*
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Enable CI build & unit testing:
if(BUILD_TESTING)
cmake_minimum_required(VERSION 3.19)
project(fv3atm VERSION 1.0 LANGUAGES C CXX Fortran)
include(ci/CMakeLists.txt)
endif()

###############################################################################
### CCPP
Expand Down Expand Up @@ -81,7 +87,7 @@ add_library(fv3atm
fv3_cap.F90
module_fv3_config.F90
module_fcst_grid_comp.F90
stochastic_physics/stochastic_physics_wrapper.F90
stochastic_physics_wrapper/stochastic_physics_wrapper.F90
AlexanderRichert-NOAA marked this conversation as resolved.
Show resolved Hide resolved
cpl/module_block_data.F90
cpl/module_cplfields.F90
cpl/module_cap_cpl.F90
Expand Down
63 changes: 63 additions & 0 deletions ci/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules/Modules)
AlexanderRichert-NOAA marked this conversation as resolved.
Show resolved Hide resolved

if(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0.0)
message(FATAL_ERROR "GNU Compiler >= 9 is required")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ggdb -fbacktrace -cpp -fcray-pointer -ffree-line-length-none -fno-range-check")

if(${CMAKE_Fortran_COMPILER_VERSION} VERSION_GREATER_EQUAL 10)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch -fallow-invalid-boz")
endif()

if(NOT 32BIT)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8")
endif()
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -nowarn -sox -align array64byte -qno-opt-dynamic-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qno-opt-dynamic-align -sox -fp-model source")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -debug minimal -qoverride-limits")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -fp-model consistent")
set(CMAKE_C_FLAGS_RELEASE "-O2 -debug minimal")

if(NOT 32BIT)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -real-size 64")
endif()
endif()

set(32BIT OFF CACHE BOOL "Enable 32BIT (single precision arithmetic in dycore and fast physics)")
set(CCPP_32BIT OFF CACHE BOOL "Enable CCPP_32BIT (single precision arithmetic in slow physics)")
set(INLINE_POST ON CACHE BOOL "Enable inline post")
set(MULTI_GASES OFF CACHE BOOL "Enable MULTI_GASES")
set(MOVING_NEST OFF CACHE BOOL "Enable moving nest code")
set(OPENMP ON CACHE BOOL "Enable OpenMP threading")
set(PARALLEL_NETCDF OFF CACHE BOOL "Enable parallel NetCDF")

message("32BIT ............ ${32BIT}")
message("CCPP_32BIT ....... ${CCPP_32BIT}")
message("INLINE_POST ...... ${INLINE_POST}")
message("MULTI_GASES ...... ${MULTI_GASES}")
message("MOVING_NEST ...... ${MOVING_NEST}")
message("OPENMP ........... ${OPENMP}")
message("PARALLEL_NETCDF .. ${PARALLEL_NETCDF}")

find_package(MPI REQUIRED)
if(OPENMP)
find_package(OpenMP REQUIRED)
endif()

find_package(NetCDF 4.7.4 REQUIRED C Fortran)
find_package(ESMF 8.3.0 MODULE REQUIRED)
find_package(FMS 2022.04 REQUIRED COMPONENTS R4 R8)
if(32BIT)
add_library(fms ALIAS FMS::fms_r4)
else()
add_library(fms ALIAS FMS::fms_r8)
endif()
find_package(bacio 2.4.0 REQUIRED)
find_package(sp 2.3.3 REQUIRED)
find_package(w3emc 2.9.2 REQUIRED)

find_package(Python 3.6 REQUIRED COMPONENTS Interpreter)

add_subdirectory(stochastic_physics)
18 changes: 18 additions & 0 deletions ci/spack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
spack:
AlexanderRichert-NOAA marked this conversation as resolved.
Show resolved Hide resolved
specs:
- [email protected] precision=4,d,8
- ip@develop precision=4,d,8
- [email protected] precision=4,d,8
- [email protected]
- upp@develop
- [email protected]
- [email protected] +gfs_phys +openmp +pic +quad_precision +deprecated_io constants=GFS precision=32,64
- netcdf-c ~blosc
view: false
concretizer:
unify: true
packages:
mpich:
require: ['~libxml2 ~hwloc ~pci']
yaksa:
buildable: false
2 changes: 1 addition & 1 deletion io/module_wrt_grid_comp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module module_wrt_grid_comp
use mpi
use esmf
use fms
use mpp_mod, only : mpp_init ! needed for fms 2023.02
AlexanderRichert-NOAA marked this conversation as resolved.
Show resolved Hide resolved
use mpp_mod, only : mpp_init, uppercase ! needed for fms 2023.02
AlexanderRichert-NOAA marked this conversation as resolved.
Show resolved Hide resolved

use write_internal_state
use module_fv3_io_def, only : num_pes_fcst, &
Expand Down