Skip to content

Commit

Permalink
First pass refactor of tests into integrated stack.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaxmonsky committed Oct 30, 2024
1 parent 340c2f9 commit 1285ea9
Show file tree
Hide file tree
Showing 11 changed files with 272 additions and 603 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/capgen_unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ jobs:
- uses: actions/checkout@v3
- name: update repos and install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential ${{matrix.fortran-compiler}} cmake python3 git

- name: Build the framework
run: |
cmake -S. -B./build -DCCPP_FRAMEWORK_ENABLE_TESTS=ON
- name: Run unit tests
run: cd test && ./run_fortran_tests.sh
run: |
cd build
ctest --rerun-failed --output-on-failure . --verbose
- name: Run python tests
run: |
BUILD_DIR=./build pytest test/capgen_test/test_reports.py
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

57 changes: 52 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,46 @@ project(ccpp_framework
VERSION 5.0.0
LANGUAGES Fortran)

include(cmake/ccpp_capgen.cmake)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}/cmake")


#------------------------------------------------------------------------------
# Set package definitions
set(PACKAGE "ccpp-framework")
set(AUTHORS "Dom Heinzeller" "Grant Firl" "Mike Kavulich" "Dustin Swales" "Courtney Peverley")
string(TIMESTAMP YEAR "%Y")

option(CCPP_FRAMEWORK_BUILD_DOCUMENTATION
"Create and install the HTML documentation (requires Doxygen)" OFF)
option(CCPP_FRAMEWORK_ENABLE_OPENMP "Enable OpenMP support for the framework" OFF)
option(CCPP_FRAMEWORK_ENABLE_TESTS "Enable building/running tests" OFF)
set(CCPP_VERBOSITY "0" CACHE STRING "Verbosity level of output (default: 0)")

# Use rpaths on MacOSX
set(CMAKE_MACOSX_RPATH 1)

ADD_COMPILE_OPTIONS(-O0)
message(STATUS "Compiling Fortran with ${CMAKE_Fortran_COMPILER_ID}")
if(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
ADD_COMPILE_OPTIONS(-fcheck=all)
ADD_COMPILE_OPTIONS(-fbacktrace)
ADD_COMPILE_OPTIONS(-ffpe-trap=zero)
ADD_COMPILE_OPTIONS(-finit-real=nan)
ADD_COMPILE_OPTIONS(-ggdb)
ADD_COMPILE_OPTIONS(-ffree-line-length-none)
ADD_COMPILE_OPTIONS(-cpp)
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "IntelLLVM")
#ADD_COMPILE_OPTIONS(-check all)
ADD_COMPILE_OPTIONS(-fpe0)
ADD_COMPILE_OPTIONS(-warn)
ADD_COMPILE_OPTIONS(-traceback)
ADD_COMPILE_OPTIONS(-debug full)
ADD_COMPILE_OPTIONS(-fpp)
else()
message (WARNING "This program has only been compiled with gfortran and ifx.")
endif()

#------------------------------------------------------------------------------
# Set MPI flags for Fortran with MPI F08 interface
find_package(MPI REQUIRED Fortran)
Expand All @@ -19,18 +53,18 @@ endif()

#------------------------------------------------------------------------------
# Set OpenMP flags for C/C++/Fortran
if (OPENMP)
if (CCPP_FRAMEWORK_ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
endif (OPENMP)
endif (CCPP_FRAMEWORK_ENABLE_OPENMP)

#------------------------------------------------------------------------------
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "Coverage")
endif()

#------------------------------------------------------------------------------
Expand All @@ -46,4 +80,17 @@ option(BUILD_SHARED_LIBS "Build a static library" OFF)
#------------------------------------------------------------------------------
# Add the sub-directories
add_subdirectory(src)
add_subdirectory(doc)

if(CCPP_FRAMEWORK_ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()

if (CCPP_FRAMEWORK_BUILD_DOCUMENTATION)
find_package(Doxygen REQUIRED)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()
add_subdirectory(doc)
endif()

28 changes: 8 additions & 20 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@
# Doxygen rules
#
# Add a target to generate API documentation with Doxygen
find_package(Doxygen)
option(BUILD_DOCUMENTATION
"Create and install the HTML documentation (requires Doxygen)"
${DOXYGEN_FOUND})
set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

#
if(BUILD_DOCUMENTATION)
if(NOT DOXYGEN_FOUND)
message(FATAL_ERROR "Doxygen is needed to build the documentation.")
endif()

set(doxyfile_in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

configure_file(${doxyfile_in} ${doxyfile} @ONLY)
configure_file(${doxyfile_in} ${doxyfile} @ONLY)

add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif()
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${doxyfile}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)

set(gmtb_sty_in ${CMAKE_CURRENT_SOURCE_DIR}/DevelopersGuide/gmtb.sty)
set(gmtb_sty ${CMAKE_CURRENT_BINARY_DIR}/DevelopersGuide/gmtb.sty)
Expand Down
6 changes: 2 additions & 4 deletions scripts/ccpp_datafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,12 +1258,10 @@ def generate_ccpp_datatable(run_env, host_model, api, scheme_headers,
ARG_VARS = vars(PARGS)
_ACTION = None
_ERRMSG = ''
_ESEP = ''
for opt in ARG_VARS:
if (opt in DatatableReport.valid_actions()) and ARG_VARS[opt]:
if _ACTION:
_ERRMSG += _ESEP + "Duplicate action, '{}'".format(opt)
_ESEP = '\n'
_ERRMSG += f"Duplicate action, '{opt}'\n"
else:
_ACTION = DatatableReport(opt, ARG_VARS[opt])
# end if
Expand All @@ -1275,5 +1273,5 @@ def generate_ccpp_datatable(run_env, host_model, api, scheme_headers,
REPORT = datatable_report(PARGS.datatable, _ACTION,
PARGS.sep, PARGS.exclude_protected)
# end if
print("{}".format(REPORT.rstrip()))
print(f"{REPORT.rstrip()}")
sys.exit(0)
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ set(${PACKAGE}_LIB_DIRS
# Define the executable and what to link
add_library(ccpp_framework STATIC ${SOURCES_F90})
target_link_libraries(ccpp_framework PUBLIC MPI::MPI_Fortran)
set_target_properties(ccpp_framework PROPERTIES VERSION ${PROJECT_VERSION}
set_target_properties(ccpp_framework PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINK_FLAGS ${CMAKE_Fortran_FLAGS})
LINK_FLAGS "${CMAKE_Fortran_FLAGS}")

#------------------------------------------------------------------------------
# Installation
Expand Down
3 changes: 3 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# add_subdirectory(advection_test)
add_subdirectory(capgen_test)
# add_subdirectory(var_compatability_test)
Loading

0 comments on commit 1285ea9

Please sign in to comment.