Skip to content

Commit

Permalink
Merge pull request #15 from kgerheiser/master
Browse files Browse the repository at this point in the history
Version 3.3.0
  • Loading branch information
kgerheiser authored Jun 26, 2020
2 parents 233ffa1 + 50a50a1 commit 15e7a4f
Show file tree
Hide file tree
Showing 49 changed files with 679 additions and 485 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build and Test
on: [push, pull_request]

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

steps:

- name: install-dependencies
run: |
sudo apt-get install libpng-dev zlib1g-dev libjpeg-dev
- name: checkout-jasper
uses: actions/checkout@v2
with:
repository: mdadams/jasper
path: jasper
ref: version-2.0.16

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

- name: build-jasper
if: steps.cache-jasper.outputs.cache-hit != 'true'
run: |
cd jasper
mkdir cmake_build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=~/Jasper
make -j2
make install
- 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: g2
submodules: true

- name: build
run: |
cd g2
mkdir build
cd build
cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit;~/" -DJasper_ROOT=~/Jasper
make -j2
- name: test
run: |
cd $GITHUB_WORKSPACE/g2/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
.DS_Store

*.swp
105 changes: 22 additions & 83 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,95 +1,34 @@
cmake_minimum_required(VERSION 3.15)
project(g2 VERSION 3.1.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(
g2
VERSION ${pVersion}
LANGUAGES C Fortran)

include(GNUInstallDirs)

STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RelWithDebInfo" BUILD_RELEASE)
if( NOT BUILD_RELEASE )
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "RELEASE" BUILD_RELEASE)
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()
STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "PRODUCTION" BUILD_PRODUCTION)

STRING(COMPARE EQUAL ${CMAKE_BUILD_TYPE} "DEBUG" BUILD_DEBUG)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU|Clang|AppleClang)$")
message(WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID}")
endif()

find_package(Jasper REQUIRED)
find_package(PNG REQUIRED)
find_package(ZLIB REQUIRED)

if(APPLE)
set(c_definitions "APPLE" "__64bit__")
else()
set(c_definitions "LINUX" "__64bit__")
endif()
add_subdirectory(src)

if(IntelComp)
set(c_flags "-O3" "-g")
set(c_definitions "LINUX" "__64BIT__")
set(shared_fortran_flags "-g" "-assume" "noold_ldout_format")
set(fortran_d_flags "-r8")
set(fortran_4_flags)
elseif(GNUComp)
set(c_flags "-ggdb" "-Wall")
set(shared_fortran_flags "-ggdb" "-Wall" "-fno-range-check" "-funroll-loops")
set(fortran_d_flags "-fdefault-real-8")
set(fortran_4_flags)
elseif(PGIComp)
set(c_flags "-g" "-fast")
set(c_definitions ${c_definitions} "UNDERSCORE")
set(shared_fortran_flags "-g" "-fast")
set(fortran_d_flags "-i8" "-r8")
set(fortran_4_flags)
else()
message("unknown compiler!")
exit()
if(ENABLE_TESTS)
find_package(PFUNIT REQUIRED)
enable_testing()
add_subdirectory(tests)
endif()

file(GLOB fortran_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f)
file(GLOB c_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.c)
set_source_files_properties(${c_src} PROPERTIES COMPILE_OPTIONS "${c_flags}")
set_source_files_properties(${c_src} PROPERTIES COMPILE_DEFINITIONS "${c_definitions}")

set(kinds "4" "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} ${c_src})

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

set_source_files_properties(${fortran_src} PROPERTIES
COMPILE_OPTIONS "${shared_fortran_flags};${fortran_${kind}_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} PRIVATE
${ZLIB_INCLUDE_DIRS} ${PNG_INCLUDE_DIRS} ${JASPER_INCLUDE_DIR})

target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include_${kind}>)

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()

install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_PREFIX})
97 changes: 0 additions & 97 deletions README

This file was deleted.

60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
### NCEPLIBS G2 Library

Utilities for coding/decoding GRIB2 messages. This library
contains Fortran 90 decoder/encoder routines for GRIB edition 2,
as well as indexing/searching utility routines.
For more detailed documentation see (grib2.doc).

Code Manager : Boi Vuong

#### Prerequisites

Compilers: GNU | Intel | Clang | AppleClang

#### Installing
```
Download G2 Code from GitHub.com
git clone -b g2_v3.2.0 --recursive https://github.com/NOAA-EMC/NCEPLIBS-g2.git
cd NCEPLIBS-g2
```
#### Create a directory where to build G2 library
```
mkdir build
cd build
```
#### Load the following modules
```
module load ips/18.0.1.163
module load impi/18.0.1
module load cmake/3.16.3
module load jasper/1.900.1
module load libpng/1.2.44
module load zlib/1.2.11
export CC=icc
export CXX=icpc
export FC=ifort
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.
Note: Windows systems is not supported at this time.
```
#### Run cmake
```
cmake .. -DCMAKE_INSTALL_PREFIX=myg2 -DCMAKE_PREFIX_PATH="${PNG_LIBDIR};${PNG_INC};${JASPER_LIBDIR};${JASPER_INC}"
If -DCMAKE_INSTALL_PREFIX= is omitted, the libraries will be installed in directory
install underneath the build directory.
make
make install
```
#### Version
3.3.0

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

#@[email protected]
#
# Imported interface targets provided:
# * @PROJECT_NAME@::@PROJECT_NAME@_4 - real32 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]")

include(CMakeFindDependencyMacro)

find_dependency(PNG)
find_dependency(bacio)

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 15e7a4f

Please sign in to comment.