Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/build.oasis3-mct.ubuntu22.04
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ BUILD_DIR = $(OASIS_ROOT)/util/make_dir
#
#
# ARCHDIR : directory created when compiling
ARCHDIR = $(HOME)/.local
ARCHDIR = $(OASIS_ROOT)/install
#
# MPI library ((see the file /etc/modulefiles/mpi/openmpi-x86_64)
MPIDIR = /usr/lib/x86_64-linux-gnu/openmpi
Expand Down
97 changes: 82 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
runs-on: ubuntu-22.04

strategy:
fail-fast: false
matrix:
config:
- {
Expand Down Expand Up @@ -70,7 +71,10 @@ jobs:
FC: mpifort
BUILD_DIR: bld
INSTALL_DIR: install
CMAKE_BUILD_PARALLEL_LEVEL: 4
OASIS_TAG: tsmp-patches-v0.1
OASIS_INSTALL_PREFIX: ${{ github.workspace }}/oasis3-mct/install
PFUNIT_TAG: v4.12.0
PFUNIT_INSTALL_PREFIX: ${{ github.workspace }}/pFUnit/install

steps:
- uses: actions/checkout@v4
Expand All @@ -83,29 +87,75 @@ jobs:
- name: Download MPI Fortran compiler
run: sudo apt-get install gfortran openmpi-bin libopenmpi-dev

#
# OASIS3-MCT
#
- if: matrix.config.use_oasis == 'True'
name: Cache OASIS3-MCT
uses: actions/cache@v4
id: cache-deps
env:
cache-name: cache-eCLM-dependencies
name: Restore cached OASIS3-MCT ${{ env.OASIS_TAG }}
uses: actions/cache/restore@v4
id: cache-oasis-restore
with:
path: "~/.local"
key: cache-${{ matrix.config.name }}
path: ${{ env.OASIS_INSTALL_PREFIX }}
key: cache-${{ matrix.config.name }}-${{ env.OASIS_TAG }}

- if: matrix.config.use_oasis == 'True' && steps.cache-deps.outputs.cache-hit != 'true'
name: Install OASIS3-MCT
- if: matrix.config.use_oasis == 'True' && steps.cache-oasis-restore.outputs.cache-hit != 'true'
name: Install OASIS3-MCT ${{ env.OASIS_TAG }}
working-directory: ${{ github.workspace }}
run: |
git clone https://icg4geo.icg.kfa-juelich.de/ExternalReposPublic/oasis3-mct.git
git clone -b $OASIS_TAG https://icg4geo.icg.kfa-juelich.de/ExternalReposPublic/oasis3-mct.git
cd oasis3-mct
export OASIS_ROOT=$(pwd)
echo "OASIS_ROOT=${OASIS_ROOT}"
echo "DEPENDENCIES_DIR=${DEPENDENCIES_DIR}"
cd util/make_dir
echo "include ${GITHUB_WORKSPACE}/.github/build.oasis3-mct.ubuntu22.04" > make.inc
cat make.inc
make realclean static-libs -f TopMakefileOasis3

- if: matrix.config.use_oasis == 'True' && steps.cache-oasis-restore.outputs.cache-hit != 'true'
name: Cache OASIS3-MCT ${{ env.OASIS_TAG }}
uses: actions/cache/save@v4
with:
path: ${{ env.OASIS_INSTALL_PREFIX }}
key: cache-${{ matrix.config.name }}-${{ env.OASIS_TAG }}

- if: matrix.config.use_oasis == 'True'
name: Add OASIS to CMAKE_PREFIX_PATH
run: |
echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:${OASIS_INSTALL_PREFIX}" >> $GITHUB_ENV

#
# pFUnit
#
- name: Restore cached pFUnit ${{ env.PFUNIT_TAG }}
uses: actions/cache/restore@v4
id: cache-pFUnit-restore
with:
path: ${{ env.PFUNIT_INSTALL_PREFIX }}
key: cache-${{ matrix.config.name }}-${{ env.PFUNIT_TAG }}

- if: steps.cache-pFUnit-restore.outputs.cache-hit != 'true'
name: Install pFUnit ${{ env.PFUNIT_TAG }}
working-directory: ${{ github.workspace }}
run: |
git clone -b ${PFUNIT_TAG} --recursive https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git
cd pFUnit
cmake -S . -B bld -DCMAKE_INSTALL_PREFIX=install
cmake --build bld
cmake --install bld
echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:${PFUNIT_INSTALL_PREFIX}" >> $GITHUB_ENV

- if: steps.cache-pFUnit-restore.outputs.cache-hit != 'true'
name: Cache pFUnit ${{ env.PFUNIT_TAG }}
uses: actions/cache/save@v4
with:
path: ${{ env.PFUNIT_INSTALL_PREFIX }}
key: cache-${{ matrix.config.name }}-${{ env.PFUNIT_TAG }}

- name: Add pFUnit to CMAKE_PREFIX_PATH
run: |
echo "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:${PFUNIT_INSTALL_PREFIX}" >> $GITHUB_ENV

#
# Configure, build, and install eCLM
#
- name: Configure eCLM
run: |
cmake -S src -B $BUILD_DIR \
Expand All @@ -117,7 +167,8 @@ jobs:
-DUSE_OASIS=${{ matrix.config.use_oasis }} \
-DCOUP_OAS_ICON=${{ matrix.config.coup_oas_icon }} \
-DCOUP_OAS_PFL=${{ matrix.config.coup_oas_pfl }} \
-DUSE_PDAF=${{ matrix.config.use_pdaf }}
-DUSE_PDAF=${{ matrix.config.use_pdaf }} \
-DENABLE_TESTS="True"

- name: Build eCLM
run: cmake --build $BUILD_DIR
Expand All @@ -127,3 +178,19 @@ jobs:

- name: Install eCLM namelist generator
run: pip3 install --user ./namelist_generator

#
# Run tests
#
- name: Run eCLM tests
id: eclm-unit-test
working-directory: ${{ env.BUILD_DIR }}
continue-on-error: true
run: |
ctest

- name: Re-run failed eCLM tests with verbose logging
if: steps.eclm-unit-test.outcome == 'failure'
working-directory: ${{ env.BUILD_DIR }}
run: |
ctest --rerun-failed --output-on-failure
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ if (USE_PDAF)
set(CMAKE_Fortran_MODULE_DIRECTORY_GPTL ${CMAKE_BINARY_DIR}/externals/gptl/include)
endif()

option(ENABLE_TESTS "Enable unit tests." OFF)
if (ENABLE_TESTS)
find_package(PFUNIT REQUIRED)
enable_testing()
message(STATUS "Found pFUnit v${PFUNIT_VERSION}")
message(STATUS "Unit tests enabled.")
endif()

add_subdirectory(externals)
add_subdirectory(csm_share)
add_subdirectory(clm5)
Expand Down
4 changes: 4 additions & 0 deletions src/csm_share/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,8 @@ if (USE_PDAF)
target_compile_definitions(${PROJECT_NAME} PUBLIC USE_PDAF)
endif()

if (ENABLE_TESTS)
add_subdirectory(util/test)
endif()

install (TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
19 changes: 0 additions & 19 deletions src/csm_share/esmf_wrf_timemgr/CMakeLists.txt

This file was deleted.

9 changes: 0 additions & 9 deletions src/csm_share/mct/CMakeLists.txt

This file was deleted.

44 changes: 0 additions & 44 deletions src/csm_share/util/CMakeLists.txt

This file was deleted.

40 changes: 34 additions & 6 deletions src/csm_share/util/shr_abort_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ module shr_abort_mod
#endif

implicit none

! PUBLIC: Public interfaces

private

! The public routines here are only meant to be used directly by shr_sys_mod. Other code
Expand All @@ -31,11 +28,42 @@ module shr_abort_mod
! when these routines were defined in shr_sys_mod.)
public :: shr_abort_abort ! abort a program
public :: shr_abort_backtrace ! print a backtrace, if possible

public :: set_abort_method ! change abort method (necessary for unit testing)
public :: abort_program

abstract interface
subroutine abort_interface(error_msg, error_code)
character(len=*) , intent(in), optional :: error_msg
integer , intent(in), optional :: error_code
end subroutine abort_interface
end interface

procedure (abort_interface), pointer :: abort_method => null()
logical, save :: initialized = .false.
contains

subroutine initialize()
abort_method => abort_program
initialized = .true.
end subroutine initialize

subroutine set_abort_method(method)
procedure (abort_interface) :: method
if (.not. initialized) call initialize()
abort_method => method
end subroutine set_abort_method

subroutine shr_abort_abort(error_msg, error_code)
character(len=*) , intent(in), optional :: error_msg
integer , intent(in), optional :: error_code

if (.not. initialized) call initialize()

call abort_method(error_msg, error_code)
end subroutine shr_abort_abort

!===============================================================================
subroutine shr_abort_abort(string,rc)
subroutine abort_program(string,rc)
! Consistent stopping mechanism

!----- arguments -----
Expand Down Expand Up @@ -75,7 +103,7 @@ subroutine shr_abort_abort(string,rc)
! usually sends SIGTERM to the process, and we don't catch that signal.
call abort()

end subroutine shr_abort_abort
end subroutine abort_program
!===============================================================================

!===============================================================================
Expand Down
66 changes: 66 additions & 0 deletions src/csm_share/util/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# shr_abort_test
add_pfunit_ctest (csm_share_abort
TEST_SOURCES shr_abort_test/test_shr_abort.pf
OTHER_SOURCES abort_with_pfunit.F90
LINK_LIBRARIES csm_share
EXTRA_USE abort_with_pfunit_mod
EXTRA_INITIALIZE initialize_abort
)

# shr_assert_test
add_pfunit_ctest (csm_share_assert
TEST_SOURCES shr_assert_test/test_assert_array.pf
shr_assert_test/test_assert.pf
shr_assert_test/test_macro.pf
shr_assert_test/test_ndebug.pf
OTHER_SOURCES abort_with_pfunit.F90
LINK_LIBRARIES csm_share
EXTRA_USE abort_with_pfunit_mod
EXTRA_INITIALIZE initialize_abort
)

# shr_cal_test
add_pfunit_ctest (csm_share_calendar
TEST_SOURCES shr_cal_test/test_shr_cal.pf
LINK_LIBRARIES csm_share
)

# shr_log_test
add_pfunit_ctest (csm_share_log
TEST_SOURCES shr_log_test/test_error_printers.pf
LINK_LIBRARIES csm_share
)

# shr_precip_test
add_pfunit_ctest (csm_share_precip
TEST_SOURCES shr_precip_test/test_shr_precip.pf
LINK_LIBRARIES csm_share
)

# shr_spfn_test
add_pfunit_ctest (csm_share_spfn
TEST_SOURCES shr_spfn_test/test_erf_r4.pf
shr_spfn_test/test_erf_r8.pf
shr_spfn_test/test_gamma_factorial.pf
shr_spfn_test/test_igamma.pf
LINK_LIBRARIES csm_share
)

# shr_strconvert_test
add_pfunit_ctest (csm_share_strconvert
TEST_SOURCES shr_strconvert_test/test_toString.pf
LINK_LIBRARIES csm_share
)

# shr_string_test
add_pfunit_ctest (csm_share_string
TEST_SOURCES shr_string_test/test_shr_string.pf
LINK_LIBRARIES csm_share
)

# shr_wv_sat_test
add_pfunit_ctest (csm_share_wv_sat
TEST_SOURCES shr_wv_sat_test/test_wv_sat_each_method.pf
shr_wv_sat_test/test_wv_sat.pf
LINK_LIBRARIES csm_share
)
Loading