diff --git a/.gitignore b/.gitignore index f738173..815c880 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ # Default build directory _build/ +build/ # Virtual environment .venv/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4e7cf12 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,111 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +# +# This is the top-level CMake build file for the Shared Unified Model +# Library +# +cmake_minimum_required(VERSION 3.20 FATAL_ERROR) + +# Shumlib version numbers are the 4-digit year followed by 2-digit +# month and an additional digit signifying the release count within +# that specified month. This should be specified in major.minor.patch +# format used by CMake and then recombined to allow it to be passed to +# shumlib via a pre-processor definition +project(shumlib LANGUAGES C Fortran + VERSION 2026.01.1 + DESCRIPTION "Met Office Shared Unifed Model Library" + HOMEPAGE_URL "https://github.com/MetOffice/shumlib") + +string(CONCAT SHUMLIB_VERSION + ${PROJECT_VERSION_MAJOR} + ${PROJECT_VERSION_MINOR} + ${PROJECT_VERSION_PATCH}) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules) + +# Include helper and setup routines +include(GNUInstallDirs) +include(cmake/PreventInSourceBuilds.cmake) +include(cmake/ShumAddSublibrary.cmake) +include(cmake/ShumFruit.cmake) +include(cmake/ShumOptions.cmake) +include(cmake/ShumVersions.cmake) + + +# Build rules for shumlib +add_library(shum) + +add_shum_sublibraries(shum + TARGETS + shum_byteswap + shum_constants + shum_data_conv + shum_fieldsfile + shum_fieldsfile_class + shum_horizontal_field_interp + shum_kinds + shum_latlon_eq_grids + shum_number_tools + shum_spiral_search + shum_string_conv + shum_thread_utils + shum_wgdos_packing) + +configure_shum_versions() + +target_compile_definitions(shum + PUBLIC + ${SHUM_DEFINES}) + +# Install shumlib and the C header files for the sub-libraries that +# have them +install(TARGETS shum + FILE_SET byteswap_headers + FILE_SET data_conv_headers + FILE_SET spiral_search_headers + FILE_SET thread_utils_headers + FILE_SET wgdos_packing_headers +) + +# Install the Fortran module files +install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# Unit tests and framework +if(BUILD_TESTS) + enable_testing() + add_library(fruit) + + # Set a relative RPATH to ensure that the unit tests continue to + # work even after being installed + list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN") + list(APPEND CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + add_executable(shumlib-tests) + + target_compile_definitions(shumlib-tests + PUBLIC + ${SHUM_DEFINES}) + + target_include_directories(shumlib-tests + PUBLIC ${CMAKE_Fortran_MODULE_DIRECTORY}) + target_link_libraries(shumlib-tests PUBLIC fruit shum) + + add_subdirectory(fruit) + setup_shum_fruit() + + install(TARGETS fruit) + install(TARGETS shumlib-tests) + + add_test(NAME shumlib-tests + COMMAND $) + + # Always set the shumlib directory to /tmp + set_property(TEST shumlib-tests + APPEND PROPERTY + ENVIRONMENT SHUM_TMPDIR=/tmp) + +endif() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..fe7e172 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "debug", + "displayName": "Debug", + "generator": "Unix Makefiles", + "binaryDir": "build/debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "debug-gcc", + "displayName": "GCC Debug", + "inherits": "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_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", + "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", + "CMAKE_Fortran_FLAGS_INIT": "-g -M E287,E5001,1077" + } + }, + { + "name": "debug-nvhpc", + "displayName": "nvidia HPC Debug", + "inherits": "debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "nvcc", + "CMAKE_Fortran_COMPILER": "nvfortran", + "CMAKE_C_FLAGS_INIT": "-g", + "CMAKE_Fortran_FLAGS_INIT": "-g" + } + } + ], + "buildPresets": [ + { + "name": "debug-gcc", + "displayName": "GCC Debug Build", + "configurePreset": "debug", + "configuration": "Debug" + }, + { + "name": "debug-cce", + "displayName": "Cray CCE Debug Build", + "configurePreset": "debug", + "configuration": "Debug" + }, + { + "name": "debug-nvhpc", + "displayName": "nvidia HPC Debug Build", + "configurePreset": "debug", + "configuration": "Debug" + } + ] +} diff --git a/cmake/PreventInSourceBuilds.cmake b/cmake/PreventInSourceBuilds.cmake new file mode 100644 index 0000000..7d1c50c --- /dev/null +++ b/cmake/PreventInSourceBuilds.cmake @@ -0,0 +1,23 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +# This function will prevent in-source builds +function(AssureOutOfSourceBuilds) + # Make sure the user doesn't perform in-source builds by tricking + # the build system through the use of symlinks + get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH) + get_filename_component(bindir "${CMAKE_BINARY_DIR}" REALPATH) + + # Disallow in-source builds + if ("${srcdir}" STREQUAL "${bindir}") + message("######################################################") + message("Warning: in-source builds are disabled") + message("Please create a separate build directory and run cmake from there") + message("######################################################") + message(FATAL_ERROR "Quitting configuration") + endif () +endfunction() + +AssureOutOfSourceBuilds() diff --git a/cmake/ShumAddSublibrary.cmake b/cmake/ShumAddSublibrary.cmake new file mode 100644 index 0000000..3acfc95 --- /dev/null +++ b/cmake/ShumAddSublibrary.cmake @@ -0,0 +1,29 @@ +# Add shumlib sublibraries +# +# Each section of shumlib is in its own subdiretory with its own +# CMakeLists.txt file in its src/ directory. Add each src directory +# and add the name of the sublibrary to a list for subsequnt use with +# the regression testing framework. +macro(add_shum_sublibraries libname) + + set(multiValueArgs TARGETS) + cmake_parse_arguments(arg_sublibs + "" "" "${multiValueArgs}" + ${ARGN}) + + set(CMAKE_SHUM_SUBLIBS "") + + message(STATUS "Adding shublib sub-libraries to ${libname}") + + foreach(sublib IN LISTS arg_sublibs_TARGETS) + if(EXISTS ${sublib}/src/CMakeLists.txt) + message(VERBOSE "Including ${sublib}") + add_subdirectory(${sublib}/src) + list(APPEND CMAKE_SHUM_SUBLIBS ${sublib}) + else() + message(FATAL_ERROR "Unaable to add ${sublib}") + endif() + + endforeach() + +endmacro() diff --git a/cmake/ShumFruit.cmake b/cmake/ShumFruit.cmake new file mode 100644 index 0000000..e59b54d --- /dev/null +++ b/cmake/ShumFruit.cmake @@ -0,0 +1,41 @@ +# Setup fruit unit testing for shumlib +# +# Take the accumluted list of shumlib subdirectories and use it to +# generate the top-level driver for the regression suite. +# +macro(setup_shum_fruit) + + message(STATUS "Creating shumlib regression tests") + + list(LENGTH CMAKE_SHUM_SUBLIBS fruit_count) + if(${fruit_count} EQUAL 0) + message(FATAL_ERROR "No regression tests set") + endif() + unset(fruit_count) + + set(SHUM_FRUIT_USE "! Use shumlib modules") + set(SHUM_FRUIT_CALLS "! Call shumlib unit tests") + + foreach(SHUM_LIBNAME IN LISTS CMAKE_SHUM_SUBLIBS) + # Build the variables that pull in each of the test modules ready + # to process the driver template + + if(EXISTS ${SHUM_LIBNAME}/test/CMakeLists.txt) + message(VERBOSE "Adding ${SHUM_LIBNAME} unit tests") + + set(SHUM_FRUIT_USE "${SHUM_FRUIT_USE}\nUSE fruit_test_${SHUM_LIBNAME}_mod") + set(SHUM_FRUIT_CALLS "${SHUM_FRUIT_CALLS}\nCALL fruit_test_${SHUM_LIBNAME}") + + # FIXME: deal with relative path + add_subdirectory(${SHUM_LIBNAME}/test) + endif() + + endforeach() + + configure_file(fruit/fruit_driver.f90.in + fruit_driver.f90) + + target_sources(shumlib-tests PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/fruit_driver.f90") + +endmacro() diff --git a/cmake/ShumOptions.cmake b/cmake/ShumOptions.cmake new file mode 100644 index 0000000..d69255a --- /dev/null +++ b/cmake/ShumOptions.cmake @@ -0,0 +1,42 @@ +# Library type options +option(BUILD_SHARED_LIBS "Build using shared libraries" ON) + +# Data options +option(IEEE_ARITHMETIC "Use Fortran intrinsic IEEE features" OFF) +option(NAN_BY_BITS "Check NaNs by bitwise inspection" OFF) +option(DENORMAL_BY_BITS "Check denormals by bitwise inspect" OFF) + +# Build options +option(BUILD_OPENMP "Build with OpenMP parallelisation" ON) +option(BUILD_FTHREADS "Build with Fortran OpenMP everywhere" OFF) +option(BUILD_TESTS "Build fruit unit tests" ON) + +# Build a list of preprocessor settings based on options +set(SHUM_DEFINES "SHUMLIB_VERSION=${SHUMLIB_VERSION}") + +if(IEEE_ARITHMETIC) + message(VERBOSE "Enabling shumlib IEEE arithmetic") + list(APPEND SHUM_DEFINES "HAS_IEEE_ARITHMETIC") +endif() + +if(NAN_BY_BITS) + message(VERBOSE "Enabling shumlib evaluate NaNs by bits") + list(APPEND SHUM_DEFINES "EVAL_NAN_BY_BITS") +endif() + +if(DENORMAL_BY_BITS) + message(VERBOSE "Enabling shumlib evaluate denormals by bits") + list(APPEND SHUM_DEFINES "EVAL_DENORMAL_BY_BITS") +endif() + +if(BUILD_OPENMP) + # FIXME: this probably needs newer version of cmake on the Cray + find_package(OpenMP 3.0 REQUIRED) + + if(BUILD_FTHREADS) + message(VERBOSE "Using shumlib with Fortran OpenMP threading") + list(APPEND SHUM_DEFINES + SHUM_USE_C_OPENMP_VIA_THREAD_UTILS="shum_use_c_openmp_via_thread_util") + endif() + +endif() diff --git a/cmake/ShumVersions.cmake b/cmake/ShumVersions.cmake new file mode 100644 index 0000000..75eef9f --- /dev/null +++ b/cmake/ShumVersions.cmake @@ -0,0 +1,30 @@ +# Create shumlib version files from templates +# +# Replace the previous versioning which used preprocessor macros and +# pure Makefiles with templating of the module file. +macro(configure_shum_versions) + + message(STATUS "Creating shumlib version functions") + + foreach(SHUM_LIBNAME IN LISTS CMAKE_SHUM_SUBLIBS) + message(VERBOSE "Versioning ${SHUM_LIBNAME}") + configure_file(common/src/f_version_mod.f90.in + "f_${SHUM_LIBNAME}_version_mod.f90") + + target_sources(shum PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/f_${SHUM_LIBNAME}_version_mod.f90") + + endforeach() + + # FIXME: remove hardwiring? + target_include_directories(shum + PUBLIC + common/src) + + target_sources(shum PRIVATE + common/src/shumlib_version.c) + + unset(SHUM_LIBNAME) + unset(SHUM_VERSION_DEFINES) + +endmacro() diff --git a/common/src/f_version_mod.f90.in b/common/src/f_version_mod.f90.in new file mode 100644 index 0000000..3877e08 --- /dev/null +++ b/common/src/f_version_mod.f90.in @@ -0,0 +1,12 @@ +MODULE f_@SHUM_LIBNAME@_version_mod +USE, INTRINSIC :: ISO_C_BINDING +IMPLICIT NONE +INTERFACE + FUNCTION get_@SHUM_LIBNAME@_version() RESULT(version) & + BIND(C, name='GET_SHUMLIB_VERSION') + IMPORT :: C_INT64_T + IMPLICIT NONE + INTEGER(KIND=C_INT64_T) :: version + END FUNCTION get_@SHUM_LIBNAME@_version +END INTERFACE +END MODULE f_@SHUM_LIBNAME@_version_mod diff --git a/common/src/shumlib_version.c b/common/src/shumlib_version.c index ecc804f..232045c 100644 --- a/common/src/shumlib_version.c +++ b/common/src/shumlib_version.c @@ -32,5 +32,6 @@ #include "precision_bomb.h" #include "shumlib_version.h" -int64_t GET_SHUMLIB_VERSION(SHUMLIB_LIBNAME) { - return SHUMLIB_VERSION;} +int64_t GET_SHUMLIB_VERSION(void) { + return SHUMLIB_VERSION; +} diff --git a/common/src/shumlib_version.h b/common/src/shumlib_version.h index 2661127..9f31236 100644 --- a/common/src/shumlib_version.h +++ b/common/src/shumlib_version.h @@ -23,14 +23,6 @@ /* Version inclusion header; */ /******************************************************************************/ -/* Check the macro we need is defined. - * This should happen outside the include guard, else only the top level library - * is validated - */ -#if !defined(SHUMLIB_LIBNAME) -#error "Please define 'SHUMLIB_LIBNAME' when including this header" -#endif - /* Include guard to prevent including this file multiple times */ #if !defined(SHUMLIB_VERSION_H) #define SHUMLIB_VERSION_H @@ -41,19 +33,9 @@ * where "X" is the release number in month "MM" of year "YYYY" */ #if !defined(SHUMLIB_VERSION) -#define SHUMLIB_VERSION 2025101 +#error Need to define SHUMLIB_VERSION macro #endif -/* 2-stage expansion which will replace in the including code: - * GET_SHUMLIB_VERSION(my_name) -> get_my_name_version() - * to allow each library to create its own unique version function - */ -#define SHUMLIB_XSTRING_EXPANSION(str) get_##str##_version -#define GET_SHUMLIB_VERSION(libname) SHUMLIB_XSTRING_EXPANSION(libname)(void) +extern int64_t GET_SHUMLIB_VERSION(void); #endif - -/* The prototype should be OUTSIDE the include guard, because it is preprocessed - * to a different function in every include instance. - */ -extern int64_t GET_SHUMLIB_VERSION(SHUMLIB_LIBNAME); diff --git a/fruit/CMakeLists.txt b/fruit/CMakeLists.txt new file mode 100644 index 0000000..37ee5ef --- /dev/null +++ b/fruit/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(fruit + PRIVATE + fruit.f90) diff --git a/fruit/fruit_driver.f90.in b/fruit/fruit_driver.f90.in new file mode 100644 index 0000000..571b51e --- /dev/null +++ b/fruit/fruit_driver.f90.in @@ -0,0 +1,21 @@ +PROGRAM fruit_driver +USE iso_c_binding +USE fruit +@SHUM_FRUIT_USE@ +IMPLICIT NONE +INTERFACE +SUBROUTINE c_exit(status) BIND(c,NAME="exit") +IMPORT :: C_INT +IMPLICIT NONE +INTEGER(KIND=C_INT), VALUE, INTENT(IN) :: status +END SUBROUTINE +END INTERFACE +INTEGER :: status +CALL init_fruit +@SHUM_FRUIT_CALLS@ +CALL fruit_summary +CALL fruit_finalize +CALL get_failed_count(status) +CALL c_exit(INT(status,KIND=C_INT)) +END PROGRAM fruit_driver + diff --git a/shum_byteswap/src/CMakeLists.txt b/shum_byteswap/src/CMakeLists.txt new file mode 100644 index 0000000..3e2df18 --- /dev/null +++ b/shum_byteswap/src/CMakeLists.txt @@ -0,0 +1,17 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + c_shum_byteswap.c + f_shum_byteswap.f90) + +target_sources(shum + PUBLIC + FILE_SET byteswap_headers + TYPE HEADERS + FILES + c_shum_byteswap.h + c_shum_byteswap_opt.h) diff --git a/shum_byteswap/test/CMakeLists.txt b/shum_byteswap/test/CMakeLists.txt new file mode 100644 index 0000000..11df039 --- /dev/null +++ b/shum_byteswap/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_byteswap.f90) diff --git a/shum_constants/src/CMakeLists.txt b/shum_constants/src/CMakeLists.txt new file mode 100644 index 0000000..d0356bc --- /dev/null +++ b/shum_constants/src/CMakeLists.txt @@ -0,0 +1,13 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + 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) diff --git a/shum_constants/test/CMakeLists.txt b/shum_constants/test/CMakeLists.txt new file mode 100644 index 0000000..87e2694 --- /dev/null +++ b/shum_constants/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_constants.f90) diff --git a/shum_data_conv/src/CMakeLists.txt b/shum_data_conv/src/CMakeLists.txt new file mode 100644 index 0000000..ca3eee1 --- /dev/null +++ b/shum_data_conv/src/CMakeLists.txt @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + c_shum_data_conv.c + f_shum_data_conv.f90) + +target_sources(shum + PUBLIC + FILE_SET data_conv_headers + TYPE HEADERS + FILES + c_shum_data_conv.h) diff --git a/shum_fieldsfile/src/CMakeLists.txt b/shum_fieldsfile/src/CMakeLists.txt new file mode 100644 index 0000000..1fe08c3 --- /dev/null +++ b/shum_fieldsfile/src/CMakeLists.txt @@ -0,0 +1,11 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_fieldsfile.f90 + f_shum_stashmaster.f90 + f_shum_fixed_length_header_indices.f90 + f_shum_lookup_indices.f90) diff --git a/shum_fieldsfile/test/CMakeLists.txt b/shum_fieldsfile/test/CMakeLists.txt new file mode 100644 index 0000000..8ff6e5c --- /dev/null +++ b/shum_fieldsfile/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_fieldsfile.f90) diff --git a/shum_fieldsfile_class/src/CMakeLists.txt b/shum_fieldsfile_class/src/CMakeLists.txt new file mode 100644 index 0000000..41532f1 --- /dev/null +++ b/shum_fieldsfile_class/src/CMakeLists.txt @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_ff_status.f90 + f_shum_field.f90 + f_shum_file.f90) diff --git a/shum_fieldsfile_class/test/CMakeLists.txt b/shum_fieldsfile_class/test/CMakeLists.txt new file mode 100644 index 0000000..26189eb --- /dev/null +++ b/shum_fieldsfile_class/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_fieldsfile_class.f90) diff --git a/shum_horizontal_field_interp/src/CMakeLists.txt b/shum_horizontal_field_interp/src/CMakeLists.txt new file mode 100644 index 0000000..a910f25 --- /dev/null +++ b/shum_horizontal_field_interp/src/CMakeLists.txt @@ -0,0 +1,8 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_horizontal_field_interp.f90) diff --git a/shum_horizontal_field_interp/test/CMakeLists.txt b/shum_horizontal_field_interp/test/CMakeLists.txt new file mode 100644 index 0000000..244b63a --- /dev/null +++ b/shum_horizontal_field_interp/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_horizontal_field_interp.f90) diff --git a/shum_kinds/src/CMakeLists.txt b/shum_kinds/src/CMakeLists.txt new file mode 100644 index 0000000..976ab5d --- /dev/null +++ b/shum_kinds/src/CMakeLists.txt @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_kinds.F90) + +set_source_files_properties( + f_shum_kinds.F90 + PROPERTIES Fortran_PREPROCESS ON) diff --git a/shum_kinds/test/CMakeLists.txt b/shum_kinds/test/CMakeLists.txt new file mode 100644 index 0000000..4c60f93 --- /dev/null +++ b/shum_kinds/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_kinds.f90) diff --git a/shum_latlon_eq_grids/src/CMakeLists.txt b/shum_latlon_eq_grids/src/CMakeLists.txt new file mode 100644 index 0000000..56c4ba6 --- /dev/null +++ b/shum_latlon_eq_grids/src/CMakeLists.txt @@ -0,0 +1,8 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_latlon_eq_grids.f90) diff --git a/shum_latlon_eq_grids/test/CMakeLists.txt b/shum_latlon_eq_grids/test/CMakeLists.txt new file mode 100644 index 0000000..d74da9e --- /dev/null +++ b/shum_latlon_eq_grids/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_latlon_eq_grids.f90) diff --git a/shum_number_tools/src/CMakeLists.txt b/shum_number_tools/src/CMakeLists.txt new file mode 100644 index 0000000..eb99cde --- /dev/null +++ b/shum_number_tools/src/CMakeLists.txt @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_is_inf.F90 + f_shum_is_nan.F90 + f_shum_is_denormal.F90) + +set_source_files_properties( + f_shum_is_inf.F90 + f_shum_is_nan.F90 + f_shum_is_denormal.F90 + PROPERTIES Fortran_PREPROCESS ON) diff --git a/shum_number_tools/test/CMakeLists.txt b/shum_number_tools/test/CMakeLists.txt new file mode 100644 index 0000000..01b0047 --- /dev/null +++ b/shum_number_tools/test/CMakeLists.txt @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE + c_fruit_test_shum_number_tools.c + fruit_test_shum_number_tools.F90) + +set_source_files_properties( + fruit_test_shum_number_tools.F90 + PROPERTIES Fortran_PREPROCESS ON) + +target_include_directories(shumlib-tests + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/shum_spiral_search/src/CMakeLists.txt b/shum_spiral_search/src/CMakeLists.txt new file mode 100644 index 0000000..e6b01c2 --- /dev/null +++ b/shum_spiral_search/src/CMakeLists.txt @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_spiral_search.f90 + c_shum_spiral_search.f90) + +target_sources(shum + PUBLIC + FILE_SET spiral_search_headers + TYPE HEADERS + FILES + c_shum_spiral_search.h) diff --git a/shum_spiral_search/test/CMakeLists.txt b/shum_spiral_search/test/CMakeLists.txt new file mode 100644 index 0000000..84aa571 --- /dev/null +++ b/shum_spiral_search/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_spiral_search.f90) diff --git a/shum_string_conv/src/CMakeLists.txt b/shum_string_conv/src/CMakeLists.txt new file mode 100644 index 0000000..1253803 --- /dev/null +++ b/shum_string_conv/src/CMakeLists.txt @@ -0,0 +1,8 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_string_conv.f90) diff --git a/shum_string_conv/test/CMakeLists.txt b/shum_string_conv/test/CMakeLists.txt new file mode 100644 index 0000000..07e2419 --- /dev/null +++ b/shum_string_conv/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_string_conv.f90) diff --git a/shum_thread_utils/src/CMakeLists.txt b/shum_thread_utils/src/CMakeLists.txt new file mode 100644 index 0000000..a68418b --- /dev/null +++ b/shum_thread_utils/src/CMakeLists.txt @@ -0,0 +1,15 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + f_shum_thread_utils.f90) + +target_sources(shum + PUBLIC + FILE_SET thread_utils_headers + TYPE HEADERS + FILES + c_shum_thread_utils.h) diff --git a/shum_thread_utils/test/CMakeLists.txt b/shum_thread_utils/test/CMakeLists.txt new file mode 100644 index 0000000..3b966ef --- /dev/null +++ b/shum_thread_utils/test/CMakeLists.txt @@ -0,0 +1,12 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE + fruit_test_shum_thread_utils.f90 + c_fruit_test_shum_thread_utils.c) + +target_include_directories(shumlib-tests + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/shum_wgdos_packing/src/CMakeLists.txt b/shum_wgdos_packing/src/CMakeLists.txt new file mode 100644 index 0000000..b8f6743 --- /dev/null +++ b/shum_wgdos_packing/src/CMakeLists.txt @@ -0,0 +1,16 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shum + PRIVATE + c_shum_wgdos_packing.f90 + f_shum_wgdos_packing.f90) + +target_sources(shum + PUBLIC + FILE_SET wgdos_packing_headers + TYPE HEADERS + FILES + c_shum_wgdos_packing.h) diff --git a/shum_wgdos_packing/test/CMakeLists.txt b/shum_wgdos_packing/test/CMakeLists.txt new file mode 100644 index 0000000..d71c79a --- /dev/null +++ b/shum_wgdos_packing/test/CMakeLists.txt @@ -0,0 +1,6 @@ +# ------------------------------------------------------------------------------ +# (c) Crown copyright Met Office. All rights reserved. +# The file LICENCE, distributed with this code, contains details of the terms +# under which the code may be used. +# ------------------------------------------------------------------------------ +target_sources(shumlib-tests PRIVATE fruit_test_shum_wgdos_packing.f90)