Skip to content

Commit

Permalink
Merge pull request #14 from kgerheiser/master
Browse files Browse the repository at this point in the history
Release 3.2.0
  • Loading branch information
kgerheiser authored Jun 26, 2020
2 parents 2d46417 + 47cb10e commit 2cb7b9f
Show file tree
Hide file tree
Showing 107 changed files with 795 additions and 81 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build and Test
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-20.04
env:
FC: gfortran-9
CC: gcc-9

steps:

- name: checkout-pfunit
uses: actions/checkout@v2
with:
repository: Goddard-Fortran-Ecosystem/pFUnit
path: pfunit

- name: cache-pfunit
id: cache-pfunit
uses: actions/cache@v2
with:
path: ~/pfunit
key: pfunit-${{ runner.os }}-${{ hashFiles('pfunit/VERSION') }}

- name: build-pfunit
if: steps.cache-pfunit.outputs.cache-hit != 'true'
run: |
cd pfunit
mkdir build
cd build
cmake .. -DSKIP_MPI=YES -DSKIP_ESMF=YES -DSKIP_FHAMCREST=YES -DCMAKE_INSTALL_PREFIX=~/pfunit
make -j2
make install
- name: checkout-sp
uses: actions/checkout@v2
with:
repository: NOAA-EMC/NCEPLIBS-sp
path: sp
ref: develop

- name: build-sp
run: |
cd sp
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/sp
make -j2
make install
- name: checkout
uses: actions/checkout@v2
with:
path: ip
submodules: true

- name: build
run: |
cd ip
mkdir build
cd build
cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit;~/"
make -j2
- name: test
run: |
cd $GITHUB_WORKSPACE/ip/build
make test
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
install/

*.[ao]
*.mod
*.so

*.swp
96 changes: 27 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,79 +1,37 @@
cmake_minimum_required(VERSION 3.15)
project(ip VERSION 3.0.0)
set(${PROJECT_NAME}_VERSION ${PROJECT_VERSION} CACHE INTERNAL "${PROJECT_NAME} version number")
enable_language (Fortran)

if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: PRODUCTION Debug Release."
FORCE)
endif()
file(STRINGS "VERSION" pVersion)

if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(IntelComp true )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU*" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang*")
set(GNUComp true )
elseif(CMAKE_CXX_COMPILER_ID MATCHES "pgc*")
set(PGIComp true )
endif()
project(
ip
VERSION ${pVersion}
LANGUAGES Fortran)

STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE)
if(NOT BUILD_RELEASE )
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE)
endif()
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION)
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "DEBUG" BUILD_DEBUG)
option(OPENMP "use OpenMP threading" OFF)
option(ENABLE_TESTS "Build pfunit tests?" OFF)

if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) )
if(IntelComp)
set(shared_fortran_flags "-auto" "-qopenmp" "-convert" "big_endian" "-assume" "byterecl"
"-fp-model" "strict" "-fpp")
set(fortran_4_flags "-i4")
set(fortran_d_flags "-i4" "-r8")
set(fortran_8_flags "-i8" "-r8")
elseif(GNUComp)
set(shared_fortran_flags "-fconvert=big-endian" "-cpp")
set(fortran_4_flags)
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8" "-fdefault-real-8")
else()
message("unknown compiler!")
exit()
endif()
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE
"Release"
CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()

file(GLOB fortran_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f90 ${CMAKE_CURRENT_SOURCE_DIR}/src/*.F)

set(kinds "4" "8" "d")
foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(versioned_lib_name ${PROJECT_NAME}_v${PROJECT_VERSION}_${kind})
add_library(${lib_name} STATIC ${fortran_src})

set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME "${versioned_lib_name}")

# Compiled with preprocessor definition LSIZE=D, not d
string(TOUPPER ${kind} kind_definition)
target_compile_definitions(${lib_name} PRIVATE "LSIZE=${kind_definition}")

set(flags ${shared_fortran_flags} ${fortran_${kind}_flags})

target_compile_options(${lib_name} PRIVATE ${flags})

set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")
set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}")

target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include_${kind}>)
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
message(
WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
endif()

install(TARGETS ${lib_name}
EXPORT ${PROJECT_NAME}-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
endforeach()
if(OPENMP)
find_package(OpenMP REQUIRED COMPONENTS Fortran)
endif()

install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_PREFIX})
add_subdirectory(src)

if (ENABLE_TESTS)
find_package(PFUNIT REQUIRED)
enable_testing()
add_subdirectory(tests)
endif()
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Interpolation Library

The NCEP general interpolation library (iplib) contains Fortran 90 subprograms
to be used for interpolating between nearly all (rectilinear) grids used at NCEP.
For more detailed documentation see [README.iplib](README.iplib).

### Prerequisites

Compilers: GNU | Intel | Clang | AppleClang | PGI


### Installing

```
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install /path/to/NCEPLIBS-ip
make -j2
make install
```

### Testing

Testing requires [pFUnit](https://github.com/Goddard-Fortran-Ecosystem/pFUnit).

```
cmake -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="/path/to/pfunit;/path/to/NCEPLIBS" /path/to/NCEPLIBS-ip
make -j2
make test
```

### Version
3.2.0


### Authors

* **[NCEP/EMC]([email protected])**
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.0
20 changes: 20 additions & 0 deletions cmake/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@PACKAGE_INIT@

# * @PROJECT_NAME@::@PROJECT_NAME@_4 - real32 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_8 - real64 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_d - mixed precision library target

# Include targets file. This will create IMPORTED target @PROJECT_NAME@
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")

# ON/OFF implies ip was compiled with/without OPENMP
if(@OPENMP@)
find_dependency(OpenMP)
endif()

get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@_4 IMPORTED_CONFIGURATIONS)

check_required_components("@PROJECT_NAME@")

get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@_4 LOCATION)
message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"@PROJECT_VERSION@\")")
78 changes: 78 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
include("list_of_files.cmake")

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS
"-g -auto -convert big_endian -assume byterecl -fp-model strict -fpp"
)
set(fortran_d_flags "-i4 -r8")
set(fortran_8_flags "-i8 -r8")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(CMAKE_Fortran_FLAGS "-g -fconvert=big-endian -cpp")
set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -Wall")
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8 -fdefault-real-8")
endif()

set(kinds "4" "8" "d")
foreach(kind ${kinds})
set(lib_name ${PROJECT_NAME}_${kind})
set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_${kind}")

# Compiled with preprocessor definition LSIZE=D, not d
string(TOUPPER ${kind} kind_definition)

set(BUILD_FLAGS "${fortran_${kind}_flags}")

add_library(${lib_name} STATIC ${fortran_src})
add_library(${PROJECT_NAME}::${lib_name} ALIAS ${lib_name})

if(OpenMP_Fortran_FOUND)
target_link_libraries(${lib_name} OpenMP::OpenMP_Fortran)
endif()

target_compile_definitions(${lib_name} PRIVATE "LSIZE=${kind_definition}")
set_target_properties(${lib_name} PROPERTIES COMPILE_FLAGS "${BUILD_FLAGS}")
set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY "${module_dir}")
set_target_properties(${lib_name} PROPERTIES INTERFACE_LINK_LIBRARIES ${lib_name})
target_include_directories(${lib_name}
PUBLIC $<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:include_${kind}>)

list(APPEND LIB_TARGETS ${lib_name})

install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
endforeach()

install(
TARGETS ${LIB_TARGETS}
EXPORT ${PROJECT_NAME}Exports
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

### Package config
include(CMakePackageConfigHelpers)
set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})

export(EXPORT ${PROJECT_NAME}Exports
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-targets.cmake)

configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION})
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})

write_basic_package_version_file(
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})

install(EXPORT ${PROJECT_NAME}Exports
NAMESPACE ${PROJECT_NAME}::
FILE ${PROJECT_NAME}-targets.cmake
DESTINATION ${CONFIG_INSTALL_DESTINATION})

33 changes: 33 additions & 0 deletions src/list_of_files.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
set(fortran_src
gausslat.f90
gdswzd00_mod.f90
gdswzd01_mod.f90
gdswzd03_mod.f90
gdswzd04_mod.f90
gdswzd05_mod.f90
gdswzd_mod.f90
gdswzdcb_mod.f90
gdswzdcd_mod.f90
ijkgds0.f90
ijkgds1.f90
ipolates.f90
ipolatev.f90
ipxwafs.f90
ipxwafs2.f90
ipxwafs3.f90
makgds.f90
movect.f90
polates0.f90
polates1.f90
polates2.f90
polates3.f90
polates4.f90
polates6.f90
polatev0.f90
polatev1.f90
polatev2.f90
polatev3.f90
polatev4.f90
polatev6.f90
polfixs.f90
polfixv.f90)
10 changes: 10 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")

file(COPY data/ DESTINATION data)

find_package(sp REQUIRED)

add_pfunit_ctest (interp_test
TEST_SOURCES test_mod.pf
LINK_LIBRARIES ip::ip_4 sp::sp_4
)
Loading

0 comments on commit 2cb7b9f

Please sign in to comment.