Skip to content
Open
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/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
run: |
cmake --preset debug-gcc
cmake --build --preset debug-gcc --parallel
ctest --test-dir build/debug --output-on-failure -V
ctest --test-dir ../build-shumlib-debug-gcc --output-on-failure -V
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
_build/
build/

Testing/

# Virtual environment
.venv/
uv.lock
Expand Down
44 changes: 44 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,47 @@ if(BUILD_TESTS)
ENVIRONMENT SHUM_TMPDIR=/tmp)

endif()

# Generate legacy compatibility header for wgdos version API.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/common/src/c_shum_wgdos_packing_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/c_shum_wgdos_packing_version.h
@ONLY
)
# Generate legacy compatibility header for data conversion version API.
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/common/src/c_shum_data_conv_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/c_shum_data_conv_version.h
@ONLY
)

# Install additional headers expected by downstream users.
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/common/src/shumlib_version.h
${CMAKE_CURRENT_BINARY_DIR}/c_shum_wgdos_packing_version.h
${CMAKE_CURRENT_BINARY_DIR}/c_shum_data_conv_version.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# Install standalone sub-libraries requested by packaging.
install(TARGETS
shum_constants
shum_string_conv
shum_wgdos_packing
shum_byteswap
shum_spiral_search
shum_data_conv
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Create install prefix symlink: lib -> lib64 (when lib64 exists).
# Variables are escaped (\$) so they evaluate at install time, not configure time.
install(CODE
"if(EXISTS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib64\"
AND NOT EXISTS \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib\")
execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
lib64 \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/lib\")
endif()"
)
98 changes: 81 additions & 17 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
{
"version": 2,
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Debug",
"name": "base-debug",
"displayName": "Base Debug Configuration",
"description": "Abstract base preset for debug builds",
"hidden": true,
"generator": "Unix Makefiles",
"binaryDir": "build/debug",
"binaryDir": "${sourceParentDir}/build-${sourceDirName}-${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "debug-gcc",
"displayName": "GCC Debug",
"inherits": "debug",
"inherits": "base-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_Fortran_COMPILER": "gfortran",
"CMAKE_C_FLAGS_INIT": "-g -Wall -Wextra -Werror -Wformat=2 -Winit-self -Wfloat-equal -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wconversion -Wlogical-op -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Woverlength-strings -Wshadow -Wall -Wextra -Wpedantic -fdiagnostics-show-option",
"CMAKE_C_FLAGS_INIT": "-g -Wall -Wextra -Werror -Wformat=2 -Winit-self -Wfloat-equal -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wcast-align -Wconversion -Wlogical-op -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Woverlength-strings -Wshadow -Wpedantic -fdiagnostics-show-option",
"CMAKE_Fortran_FLAGS_INIT": "-g -std=f2018 -pedantic -pedantic-errors -fno-range-check -Wall -Wextra -Werror -Wno-compare-reals -Wconversion -Wno-unused-dummy-argument -Wno-c-binding-type -fdiagnostics-show-option"
}
},
{
"name": "debug-cce",
"displayName": "Cray CCE Debug",
"inherits": "debug",
"inherits": "base-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "cc",
"CMAKE_Fortran_COMPILER": "ftn",
"CMAKE_C_FLAGS_INIT": "-g -Weverything -Wno-vla -Wno-padded -Wno-missing-noreturn -Wno-declaration-after-statement -Werror -pedantic -pedantic-errors -fdiagnostics-show-option -DSHUM_X86_INTRINSIC",
Expand All @@ -37,9 +42,19 @@
{
"name": "debug-nvhpc",
"displayName": "nvidia HPC Debug",
"inherits": "debug",
"inherits": "base-debug",
"cacheVariables": {
"CMAKE_C_COMPILER": "nvc",
"CMAKE_Fortran_COMPILER": "nvfortran",
"CMAKE_C_FLAGS_INIT": "-g -Minform=inform",
"CMAKE_Fortran_FLAGS_INIT": "-g -Minform=inform"
}
},
{
"name": "debug-nvhpcc",
"displayName": "nvidia HPC Cuda Debug",
"inherits": "base-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "nvcc",
"CMAKE_Fortran_COMPILER": "nvfortran",
"CMAKE_C_FLAGS_INIT": "-g",
Expand All @@ -48,23 +63,72 @@
}
],
"buildPresets": [
{
"name": "base-build",
"hidden": true,
"jobs": 0
},
{
"name": "debug-gcc",
"displayName": "GCC Debug Build",
"configurePreset": "debug",
"configuration": "Debug"
"inherits": "base-build",
"configurePreset": "debug-gcc"
},
{
"name": "debug-cce",
"displayName": "Cray CCE Debug Build",
"configurePreset": "debug",
"configuration": "Debug"
"inherits": "base-build",
"configurePreset": "debug-cce"
},
{
"name": "debug-nvhpc",
"displayName": "nvidia HPC Debug Build",
"configurePreset": "debug",
"configuration": "Debug"
"inherits": "base-build",
"configurePreset": "debug-nvhpc"
},
{
"name": "debug-nvhpcc",
"displayName": "nvidia HPC Cuda Debug Build",
"inherits": "base-build",
"configurePreset": "debug-nvhpcc"
}
],
"testPresets": [
{
"name": "base-test",
"hidden": true,
"execution": {
"stopOnFailure": false,
"jobs": 0,
"noTestsAction": "error"
},
"output": {
"outputOnFailure": true
}
},
{
"name": "debug-gcc",
"displayName": "GCC Debug Tests",
"inherits": "base-test",
"configurePreset": "debug-gcc"
},
{
"name": "debug-cce",
"displayName": "Cray CCE Debug Tests",
"inherits": "base-test",
"configurePreset": "debug-cce"
},
{
"name": "debug-nvhpc",
"displayName": "nvidia HPC Debug Tests",
"inherits": "base-test",
"configurePreset": "debug-nvhpc"
},
{
"name": "debug-nvhpcc",
"displayName": "nvidia HPC Cuda Debug Tests",
"inherits": "base-test",
"configurePreset": "debug-nvhpcc"
}
]
}
39 changes: 38 additions & 1 deletion cmake/ShumOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,44 @@ endif()

if(BUILD_OPENMP)
# FIXME: this probably needs newer version of cmake on the Cray
find_package(OpenMP 3.0 REQUIRED)
# UPDATE: Doesn't work with cmake 3.31.9
# A little hack to check supported OMP spec on Cray
# ---
if(CMAKE_Fortran_COMPILER_ID MATCHES "Cray" OR CMAKE_C_COMPILER_ID MATCHES "Cray")
# Cray's OpenMP is compiler-managed (no separate runtime library).
# CMake's FindOpenMP fails on Cray because it can't resolve LIB_NAMES.
# Verify the minimum required OpenMP spec date manually instead.
# See OpenMP Spec dates <https://www.openmp.org/specifications/>
include(CheckFortranSourceRuns)
set(CMAKE_REQUIRED_FLAGS "-homp")
check_fortran_source_runs(
"program check\n if (_OPENMP < 200805) stop 1\nend program\n"
CRAY_OMP_MEETS_MINIMUM SRC_EXT F90
)
unset(CMAKE_REQUIRED_FLAGS)
if(NOT CRAY_OMP_MEETS_MINIMUM)
message(FATAL_ERROR "shumlib requires OpenMP >= 3.0 (date 200805); Cray compiler does not meet this.")
endif()

# Create the standard imported targets so downstream consumers work normally
if(NOT TARGET OpenMP::OpenMP_Fortran)
add_library(OpenMP::OpenMP_Fortran INTERFACE IMPORTED)
set_target_properties(OpenMP::OpenMP_Fortran PROPERTIES
INTERFACE_COMPILE_OPTIONS "-homp"
INTERFACE_LINK_OPTIONS "-homp")
endif()
if(NOT TARGET OpenMP::OpenMP_C)
add_library(OpenMP::OpenMP_C INTERFACE IMPORTED)
set_target_properties(OpenMP::OpenMP_C PROPERTIES
INTERFACE_COMPILE_OPTIONS "-fopenmp"
INTERFACE_LINK_OPTIONS "-fopenmp")
endif()
set(OpenMP_FOUND TRUE)
set(OpenMP_Fortran_FOUND TRUE)
set(OpenMP_C_FOUND TRUE)
else()
find_package(OpenMP 3.0 REQUIRED)
endif()

if(BUILD_FTHREADS)
message(VERBOSE "Using shumlib with Fortran OpenMP threading")
Expand Down
14 changes: 14 additions & 0 deletions common/src/c_shum_data_conv_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef C_SHUM_DATA_CONV_VERSION_H
#define C_SHUM_DATA_CONV_VERSION_H

#if !defined(SHUMLIB_VERSION)
#define SHUMLIB_VERSION @SHUMLIB_VERSION@
#endif

#define SHUMLIB_CMAKE 1
#include "shumlib_version.h"
#undef SHUMLIB_CMAKE

#define get_shum_data_conv_version GET_SHUMLIB_VERSION

#endif
20 changes: 20 additions & 0 deletions common/src/c_shum_wgdos_packing_version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef C_SHUM_WGDOS_PACKING_VERSION_H
#define C_SHUM_WGDOS_PACKING_VERSION_H

/* Ensure downstream consumers do not need to define SHUMLIB_VERSION */
#if !defined(SHUMLIB_VERSION)
#define SHUMLIB_VERSION @SHUMLIB_VERSION@
#endif

/*
* Reuse the CMake-mode API in shumlib_version.h and expose the legacy
* function-like name expected by external applications.
*/
#define SHUMLIB_CMAKE 1
#include "shumlib_version.h"
#undef SHUMLIB_CMAKE

/* Legacy compatibility symbol name */
#define get_shum_wgdos_packing_version GET_SHUMLIB_VERSION

#endif
20 changes: 20 additions & 0 deletions shum_byteswap/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,23 @@ target_sources(shum
FILES
c_shum_byteswap.h
c_shum_byteswap_opt.h)

add_library(shum_byteswap)
target_sources(shum_byteswap
PRIVATE
c_shum_byteswap.c
f_shum_byteswap.f90
${PROJECT_SOURCE_DIR}/common/src/shumlib_version.c
${PROJECT_BINARY_DIR}/f_shum_byteswap_version_mod.f90)

target_compile_definitions(shum_byteswap PUBLIC ${SHUM_DEFINES})

set_target_properties(shum_byteswap PROPERTIES
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules_shum_byteswap)

target_include_directories(shum_byteswap
PUBLIC
${PROJECT_BINARY_DIR}/modules_shum_byteswap
${PROJECT_SOURCE_DIR}/common/src)

target_link_libraries(shum_byteswap PUBLIC shum_string_conv)
22 changes: 22 additions & 0 deletions shum_constants/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,25 @@ target_sources(shum
f_shum_ztables.f90
f_shum_rel_mol_mass_mod.f90
f_shum_water_constants_mod.f90)

add_library(shum_constants)
target_sources(shum_constants
PRIVATE
f_shum_chemistry_constants_mod.f90
f_shum_conversions_mod.f90
f_shum_planet_earth_constants_mod.f90
f_shum_ztables.f90
f_shum_rel_mol_mass_mod.f90
f_shum_water_constants_mod.f90
${PROJECT_SOURCE_DIR}/common/src/shumlib_version.c
${PROJECT_BINARY_DIR}/f_shum_constants_version_mod.f90)

target_compile_definitions(shum_constants PUBLIC ${SHUM_DEFINES})

set_target_properties(shum_constants PROPERTIES
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules_shum_constants)

target_include_directories(shum_constants
PUBLIC
${PROJECT_BINARY_DIR}/modules_shum_constants
${PROJECT_SOURCE_DIR}/common/src)
20 changes: 20 additions & 0 deletions shum_data_conv/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@ target_sources(shum
TYPE HEADERS
FILES
c_shum_data_conv.h)

add_library(shum_data_conv)
target_sources(shum_data_conv
PRIVATE
c_shum_data_conv.c
f_shum_data_conv.f90
${PROJECT_SOURCE_DIR}/common/src/shumlib_version.c
${PROJECT_BINARY_DIR}/f_shum_data_conv_version_mod.f90)

target_compile_definitions(shum_data_conv PUBLIC ${SHUM_DEFINES})

set_target_properties(shum_data_conv PROPERTIES
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules_shum_data_conv)

target_include_directories(shum_data_conv
PUBLIC
${PROJECT_BINARY_DIR}/modules_shum_data_conv
${PROJECT_SOURCE_DIR}/common/src)

target_link_libraries(shum_data_conv PUBLIC shum_string_conv)
20 changes: 20 additions & 0 deletions shum_spiral_search/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,23 @@ target_sources(shum
TYPE HEADERS
FILES
c_shum_spiral_search.h)

add_library(shum_spiral_search)
target_sources(shum_spiral_search
PRIVATE
f_shum_spiral_search.f90
c_shum_spiral_search.f90
${PROJECT_SOURCE_DIR}/common/src/shumlib_version.c
${PROJECT_BINARY_DIR}/f_shum_spiral_search_version_mod.f90)

target_compile_definitions(shum_spiral_search PUBLIC ${SHUM_DEFINES})

set_target_properties(shum_spiral_search PROPERTIES
Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/modules_shum_spiral_search)

target_include_directories(shum_spiral_search
PUBLIC
${PROJECT_BINARY_DIR}/modules_shum_spiral_search
${PROJECT_SOURCE_DIR}/common/src)

target_link_libraries(shum_spiral_search PUBLIC shum_constants shum_string_conv)
Loading