Skip to content

Commit

Permalink
Merge pull request #11 from kgerheiser/master
Browse files Browse the repository at this point in the history
Release 2.3.0
  • Loading branch information
kgerheiser authored Jun 26, 2020
2 parents fc67287 + 4605390 commit 25264a2
Show file tree
Hide file tree
Showing 12 changed files with 366 additions and 190 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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
uses: actions/checkout@v2
with:
path: w3nco
submodules: true

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

*.[ao]
*.mod
*.so

*.swp
.DS_Store
63 changes: 10 additions & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,26 @@ project(
VERSION ${pVersion}
LANGUAGES C Fortran)

include(GNUInstallDirs)

option(ENABLE_TESTS "Build pfunit tests?" OFF)

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")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
message(WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID}")
endif()

if(APPLE)
add_compile_definitions(APPLE)
elseif(UNIX)
add_compile_definitions(LINUX)
endif()

if(CMAKE_C_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_C_FLAGS "-g")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS "-g")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(fortran_d_flags "-r8")
set(fortran_8_flags "-i8 -r8")
elseif(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(CMAKE_C_FLAGS "-ggdb")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_Fortran_FLAGS "-ggdb -fno-range-check -fbacktrace -funroll-loops")
set(CMAKE_Fortran_FLAGS_RELEASE "-O3")
set(fortran_d_flags "-fdefault-real-8")
set(fortran_8_flags "-fdefault-integer-8 -fdefault-real-8")
endif()

add_subdirectory(src)

set_source_files_properties(${c_src} PROPERTIES COMPILE_OPTIONS "${c_flags}")
set_source_files_properties(${c_src} PROPERTIES COMPILE_DEFINITIONS
"${platform_definitions}")

# One target for real32 and one target for real64
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}_f OBJECT ${fortran_src})
set_target_properties(${lib_name}_f PROPERTIES COMPILE_FLAGS
"${fortran_${kind}_flags}")
add_library(${lib_name}_c OBJECT ${c_src})

add_library(${lib_name} STATIC $<TARGET_OBJECTS:${lib_name}_f>
$<TARGET_OBJECTS:${lib_name}_c>)
set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME
${versioned_lib_name})
install(
TARGETS ${lib_name}
EXPORT ${PROJECT_NAME}-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
endforeach()

install(EXPORT ${PROJECT_NAME}-config
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/${PROJECT_NAME})
if(ENABLE_TESTS)
find_package(PFUNIT REQUIRED)
enable_testing()
add_subdirectory(tests)
endif()
48 changes: 37 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,56 @@
# W3NCO

Several utilities from NCO to indicate the types of variables and processor.
This library contains Fortran 90 decoder/encoder
routines for GRIB edition 1.

Code manager: Boi Vuong


### Prerequisites

Compilers: GNU | Intel | Clang | AppleClang


### Installing

#### Installing
```
Download W3NCO Code from GitHub.com
git clone -b w3nco_v2.2.0 --recursive https://github.com/NOAA-EMC/NCEPLIBS-w3nco.git
cd NCEPLIBS-w3nco
```
#### Create a directory where to build W3NCO library
```
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/path/to/install /path/to/NCEPLIBS-w3nco
make
make install
```
#### Load the following modules
```
module load intel/18.0.1.163
module load impi/18.0.1
module load cmake/3.16.2
module use -a /usrx/local/nceplibs/dev/NCEPLIBS/modulefiles
export CC=icc
export CXX=icpc
export FC=ifort
### Version
If the chosen compiler is not the default compiler on the system,
set the environment variables: export CC=..., export CXX=...,
export FC=..., before invoking cmake.
2.2.0
Note: Windows systems is not supported at this time.
```
#### Run cmake
```
cmake .. -DCMAKE_INSTALL_PREFIX=path_to_install (where you want to install W3NCO)
If -DCMAKE_INSTALL_PREFIX= is omitted, the libraries will be installed in directory
install underneath the build directory.
make
make install
```
### Version

2.3.0

### Authors

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0
21 changes: 21 additions & 0 deletions cmake/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@PACKAGE_INIT@

#@[email protected]
#
# Output variables set:
# * @PROJECT_NAME@_FOUND
#
# Imported interface targets provided:
# * @PROJECT_NAME@::@PROJECT_NAME@_4 - real32 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_8 - real64 library target
# * @PROJECT_NAME@::@PROJECT_NAME@_d - mixed library target

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

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@\")")
Loading

0 comments on commit 25264a2

Please sign in to comment.