Skip to content

Commit 5b9b758

Browse files
authored
Merge pull request #11 from kgerheiser/master
Release 1.3.0
2 parents 27cb8b7 + 3a14ee1 commit 5b9b758

File tree

9 files changed

+206
-51
lines changed

9 files changed

+206
-51
lines changed

.github/workflows/main.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and Test
2+
on: [push, pull_request]
3+
4+
jobs:
5+
build:
6+
runs-on: ubuntu-20.04
7+
env:
8+
FC: gfortran-9
9+
CC: gcc-9
10+
11+
steps:
12+
13+
- name: checkout-pfunit
14+
uses: actions/checkout@v2
15+
with:
16+
repository: Goddard-Fortran-Ecosystem/pFUnit
17+
path: pfunit
18+
19+
- name: cache-pfunit
20+
id: cache-pfunit
21+
uses: actions/cache@v2
22+
with:
23+
path: ~/pfunit
24+
key: pfunit-${{ runner.os }}-${{ hashFiles('pfunit/VERSION') }}
25+
26+
- name: build-pfunit
27+
if: steps.cache-pfunit.outputs.cache-hit != 'true'
28+
run: |
29+
cd pfunit
30+
mkdir build
31+
cd build
32+
cmake .. -DSKIP_MPI=YES -DSKIP_ESMF=YES -DSKIP_FHAMCREST=YES -DCMAKE_INSTALL_PREFIX=~/pfunit
33+
make -j2
34+
make install
35+
36+
- name: checkout
37+
uses: actions/checkout@v2
38+
with:
39+
path: sfcio
40+
submodules: true
41+
42+
- name: build
43+
run: |
44+
cd sfcio
45+
mkdir build
46+
cd build
47+
cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit;~/"
48+
make -j2
49+
50+
- name: test
51+
run: |
52+
cd $GITHUB_WORKSPACE/sfcio/build
53+
make test

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build/
2+
install/
3+
4+
*.[ao]
5+
*.mod
6+
*.so
7+
8+
*.swp

CMakeLists.txt

Lines changed: 20 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,29 @@
11
cmake_minimum_required(VERSION 3.15)
2-
project(sfcio VERSION 1.1.0)
3-
enable_language (Fortran)
42

5-
if (NOT CMAKE_BUILD_TYPE)
6-
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
7-
"Choose the type of build, options are: PRODUCTION Debug Release."
8-
FORCE)
9-
endif()
3+
file(STRINGS "VERSION" pVersion)
104

11-
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
12-
set(IntelComp true )
13-
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU*" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang*")
14-
set(GNUComp true )
15-
elseif(CMAKE_CXX_COMPILER_ID MATCHES "pgc*")
16-
set(PGIComp true )
17-
endif()
5+
project(sfcio VERSION ${pVersion} LANGUAGES Fortran)
186

19-
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE)
20-
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE)
21-
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION)
22-
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "DEBUG" BUILD_DEBUG)
7+
option(ENABLE_TESTS "Enable tests" OFF)
238

24-
if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) )
25-
if(IntelComp)
26-
set(fortran_flags "-O2" "-g" "-xHOST" "-traceback" "-free" "-convert" "big_endian"
27-
"-assume" "byterecl")
28-
elseif(GNUComp)
29-
set(fortran_flags "-O2" "-ggdb" "-fbacktrace" "-ffree-form"
30-
"-fconvert=big-endian" "-funroll-loops" "-Wall")
31-
else()
32-
message("unknown compiler!")
33-
exit()
34-
endif()
9+
if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release|RelWithDebInfo|MinSizeRel)$")
10+
message(STATUS "Setting build type to 'Release' as none was specified.")
11+
set(CMAKE_BUILD_TYPE
12+
"Release"
13+
CACHE STRING "Choose the type of build." FORCE)
14+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
15+
"MinSizeRel" "RelWithDebInfo")
3516
endif()
3617

37-
set(lib_name ${PROJECT_NAME})
38-
set(versioned_lib_name ${PROJECT_NAME}_v${PROJECT_VERSION})
39-
40-
file(GLOB fortran_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f)
41-
add_library(${lib_name} STATIC ${fortran_src})
42-
set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME "${versioned_lib_name}")
43-
44-
target_compile_options(${lib_name} PRIVATE ${fortran_flags})
45-
46-
set(module_dir "${PROJECT_BINARY_DIR}/include_4")
47-
set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir})
48-
49-
target_include_directories(${lib_name} PUBLIC
50-
$<BUILD_INTERFACE:${module_dir}>
51-
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include_4>)
18+
if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
19+
message(
20+
WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
21+
endif()
5222

53-
install(TARGETS ${lib_name}
54-
EXPORT ${PROJECT_NAME}-config
55-
RUNTIME DESTINATION bin
56-
LIBRARY DESTINATION lib
57-
ARCHIVE DESTINATION lib)
58-
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
59-
install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_PREFIX})
23+
add_subdirectory(src)
6024

25+
if (ENABLE_TESTS)
26+
find_package(PFUNIT REQUIRED)
27+
enable_testing()
28+
add_subdirectory(tests)
29+
endif()

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SFCIO
2+
3+
API for surface files I/O
4+
5+
Code manager: George Vandenberghe
6+
7+
8+
### Prerequisites
9+
10+
Compilers: GNU | Intel | Clang | AppleClang
11+
12+
13+
### Installing
14+
15+
```
16+
mkdir build
17+
cd build
18+
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install /path/to/NCEPLIBS-sfcio
19+
make -j2
20+
make install
21+
```
22+
23+
24+
### Version
25+
1.3.0
26+
27+
28+
### Authors
29+
30+
* **[NCEP/EMC](mailto:NCEP.List.EMC.nceplibs.Developers@noaa.gov)**

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.3.0

cmake/PackageConfig.cmake.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@PACKAGE_INIT@
2+
3+
#@PROJECT_NAME@-config.cmake
4+
# Imported interface targets provided:
5+
# * @PROJECT_NAME@::@PROJECT_NAME@
6+
7+
# Include targets file. This will create IMPORTED target @PROJECT_NAME@
8+
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
9+
10+
get_target_property(@PROJECT_NAME@_BUILD_TYPES @PROJECT_NAME@::@PROJECT_NAME@ IMPORTED_CONFIGURATIONS)
11+
12+
check_required_components("@PROJECT_NAME@")
13+
14+
get_target_property(location @PROJECT_NAME@::@PROJECT_NAME@ LOCATION)
15+
message(STATUS "Found @PROJECT_NAME@: ${location} (found version \"@PROJECT_VERSION@\")")

src/CMakeLists.txt

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
3+
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
4+
set(CMAKE_Fortran_FLAGS
5+
"-g -xHOST -traceback -free -convert big_endian -assume byterecl")
6+
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
7+
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
8+
set(CMAKE_Fortran_FLAGS
9+
"-g -fbacktrace -ffree-form -fconvert=big-endian -funroll-loops")
10+
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
11+
set(CMAKE_Fortran_FLAGS_DEBUG "-ggdb -Wall")
12+
endif()
13+
14+
set(fortran_src sfcio_module.f)
15+
16+
set(lib_name ${PROJECT_NAME})
17+
set(module_dir ${CMAKE_CURRENT_BINARY_DIR}/include)
18+
19+
add_library(${lib_name} STATIC ${fortran_src})
20+
add_library(${PROJECT_NAME}::${lib_name} ALIAS ${lib_name})
21+
22+
set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir})
23+
target_include_directories(${lib_name} PUBLIC
24+
$<BUILD_INTERFACE:${module_dir}>
25+
$<INSTALL_INTERFACE:include>)
26+
27+
list(APPEND LIB_TARGETS ${lib_name})
28+
29+
install(DIRECTORY ${module_dir} DESTINATION ${CMAKE_INSTALL_PREFIX})
30+
31+
install(
32+
TARGETS ${LIB_TARGETS}
33+
EXPORT ${PROJECT_NAME}Exports
34+
RUNTIME DESTINATION bin
35+
LIBRARY DESTINATION lib
36+
ARCHIVE DESTINATION lib)
37+
38+
### Package config
39+
include(CMakePackageConfigHelpers)
40+
set(CONFIG_INSTALL_DESTINATION lib/cmake/${PROJECT_NAME})
41+
42+
export(EXPORT ${PROJECT_NAME}Exports
43+
NAMESPACE ${PROJECT_NAME}::
44+
FILE ${PROJECT_NAME}-targets.cmake)
45+
46+
configure_package_config_file(
47+
${CMAKE_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
48+
INSTALL_DESTINATION ${CONFIG_INSTALL_DESTINATION})
49+
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config.cmake
50+
DESTINATION ${CONFIG_INSTALL_DESTINATION})
51+
52+
write_basic_package_version_file(
53+
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
54+
VERSION ${PROJECT_VERSION}
55+
COMPATIBILITY AnyNewerVersion)
56+
install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
57+
DESTINATION ${CONFIG_INSTALL_DESTINATION})
58+
59+
install(EXPORT ${PROJECT_NAME}Exports
60+
NAMESPACE ${PROJECT_NAME}::
61+
FILE ${PROJECT_NAME}-targets.cmake
62+
DESTINATION ${CONFIG_INSTALL_DESTINATION})

tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
add_pfunit_ctest (sfcio_test
3+
TEST_SOURCES test_mod.pf
4+
LINK_LIBRARIES sfcio::sfcio
5+
)

tests/test_mod.pf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module test_mod
2+
use funit
3+
use iso_fortran_env, only: real32, real64
4+
5+
contains
6+
7+
@test
8+
subroutine test_sigio()
9+
@assertTrue(.true., "true is true")
10+
end subroutine test_sigio
11+
12+
end module test_mod

0 commit comments

Comments
 (0)