Skip to content

Commit

Permalink
Merge pull request #10 from kgerheiser/master
Browse files Browse the repository at this point in the history
Release 1.3.0
  • Loading branch information
kgerheiser authored Jun 26, 2020
2 parents 582e6aa + 5625a60 commit bebb32c
Show file tree
Hide file tree
Showing 25 changed files with 2,560 additions and 54 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: gfsio
submodules: true

- name: build
run: |
cd gfsio
mkdir build
cd build
cmake .. -DENABLE_TESTS=ON -DCMAKE_PREFIX_PATH="~/pfunit;~/"
make -j2
- name: test
run: |
cd $GITHUB_WORKSPACE/gfsio/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
77 changes: 23 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,63 +1,32 @@
cmake_minimum_required(VERSION 3.15)
project(gfsio VERSION 1.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(
gfsio
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)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
option(ENABLE_TESTS "Enable tests" OFF)

if( (BUILD_RELEASE) OR (BUILD_PRODUCTION) )
if(IntelComp)
set(fortran_flags "-free" "-traceback" "-g" "-xHOST" "-convert" "big_endian" "-assume" "byterecl")
elseif(GNUComp)
set(fortran_flags "-ffree-form" "-fbacktrace" "-g" "-O2" "-fconvert=big-endian")
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()

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

set(lib_name ${PROJECT_NAME}_4)
set(versioned_lib_name ${PROJECT_NAME}_v${PROJECT_VERSION}_4)


file(GLOB fortran_src ${CMAKE_CURRENT_SOURCE_DIR}/src/*.f)
add_library(${lib_name} STATIC ${fortran_src})

set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME "${versioned_lib_name}")
target_compile_options(${lib_name} PRIVATE ${fortran_flags})


set(module_dir "${CMAKE_CURRENT_BINARY_DIR}/include_4")
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_4>)
add_subdirectory(src)

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})
install(EXPORT ${PROJECT_NAME}-config DESTINATION ${CMAKE_INSTALL_PREFIX})
if (ENABLE_TESTS)
find_package(PFUNIT REQUIRED)
enable_testing()
add_subdirectory(tests)
endif()
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# GFSIO

API to convert GFS Gaussian output into grib output

Code Manager: George Vandenberghe

### Prerequisites

Compilers: GNU | Intel | Clang | AppleClang


### Installing

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


### Version
1.3.0


### Authors

* **[NCEP/EMC](mailto:NCEP.List.EMC.nceplibs.Developers@noaa.gov)**
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.3.0
16 changes: 16 additions & 0 deletions cmake/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@PACKAGE_INIT@

#@PROJECT_NAME@-config.cmake
#
# Imported interface targets provided:
# * @PROJECT_NAME@::@PROJECT_NAME@ - library target

# Include targets file. This will create IMPORTED target @PROJECT_NAME@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")

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

check_required_components("@PROJECT_NAME@")

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

if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS
"-g -traceback -free -xHOST -convert big_endian -assume byterecl")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$")
set(CMAKE_Fortran_FLAGS "-g -fbacktrace -fconvert=big-endian -ffree-form")
set(CMAKE_Fortran_RELEASE "-O2")
endif()

set(fortran_src gfsio_module.f)

set(lib_name ${PROJECT_NAME})
set(module_dir ${CMAKE_CURRENT_BINARY_DIR}/include)

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

set_target_properties(${lib_name} PROPERTIES Fortran_MODULE_DIRECTORY ${module_dir})
target_include_directories(${lib_name} PUBLIC
$<BUILD_INTERFACE:${module_dir}>
$<INSTALL_INTERFACE:include>)

list(APPEND LIB_TARGETS ${lib_name})

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

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})
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

add_pfunit_ctest (gfsio_test
TEST_SOURCES test_mod.pf
LINK_LIBRARIES gfsio::gfsio
)

39 changes: 39 additions & 0 deletions tests/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

6. Test plan

The test plan for g2tmpl_v1.6.0 files are in gitHub repository:
https://svnemc.ncep.noaa.gov/projects/nceplibs/g2tmpl/branches/v1.6.0/unit_test/

These unit_test programs need to compile with g2tmpl v1.6.0 as follows:

cd to ./v1.6.0/unit_test
run script compile_all_unit_test_g2tmpl_lib.sh

Then, run all executable on WCOSS or CRAY or DELL or Hera:
run script run_all_test.sh

or

Run individual executable
1. test_g2tmpl_table_233
2. test_g2tmpl_pdt4_1
3. test_g2tmpl_pdt4_11
4. Test_g2tmpl_pdt4_12
6. Test_g2tmpl_pdt4_8
6. Test_params_grib2_tbl_new

The result of all tests g2tmpl v1.6.0 as belows:

Running test g2tmpl_pdt4_1... done ---> PASS
--> Please view /global/save/Boi.Vuong/g2tmpl/v1.6.0/unit_test/output/g2tmpl_pdt4_1.log
Running test g2tmpl_pdt4_11... done ---> PASS
--> Please view /global/save/Boi.Vuong/g2tmpl/v1.6.0/unit_test/output/g2tmpl_pdt4_11.log
Running test g2tmpl_pdt4_12... done ---> PASS
--> Please view /global/save/Boi.Vuong/g2tmpl/v1.6.0/unit_test/output/g2tmpl_pdt4_12.log
Running test g2tmpl_pdt4_8... done ---> PASS
--> Please view /global/save/Boi.Vuong/g2tmpl/v1.6.0/unit_test/output/g2tmpl_pdt4_8.log
Running test g2tmpl_table_233... done ---> PASS
--> Please view /global/save/Boi.Vuong/g2tmpl/v1.6.0/unit_test/output/g2tmpl_table_233.log
Running test params_grib2_tbl_new... done ---> PASS
--> Please view /global/save/Boi.Vuong/g2tmpl/v1.6.0/unit_test/output/params_grib2_tbl_new.log

60 changes: 60 additions & 0 deletions tests/compile_all_unit_test_g2tmpl_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
SHELL=/bin/sh

module purge

mac=$(hostname | cut -c1-1)
mac2=$(hostname | cut -c1-2)

if [ $mac2 = hf ] ; then # For Hera
machine=hera
. /etc/profile
. /etc/profile.d/modules.sh
module load intel/18.0.5.274
module load impi/2018.0.4
elif [ $mac = v -o $mac = m ] ; then # For Dell (i.e. Mars and Venus)
machine=wcoss_dell_p3
. $MODULESHOME/init/bash
module load ips/18.0.1.163
module use -a /usrx/local/nceplibs/dev/NCEPLIBS/modulefiles
module load g2tmpl/1.6.0
elif [ $mac = l -o $mac = s ] ; then # for wcoss (i.e. luna and surge)
export machine=cray-intel
module switch intel intel/16.3.210
module load craype/2.3.0
module use -a /usrx/local/nceplibs/NCEPLIBS/modulefiles
module load g2tmpl/1.6.0
fi

#
module list

set -x

BASE=`pwd`

#####################################
cd ${BASE}
for file in pdt4_1 pdt4_11 pdt4_12 pdt4_8 table_233 params_table
do

echo " "
module list 2>compile_all_unit_test_g2tmpl_lib-$machine.log
module list
echo " "
echo " PLEASE WAIT FOR WRITING to LOG file "
echo " "

make -f makefile_$file &>>compile_all_unit_test_g2tmpl_lib-$machine.log
# make -f makefile_$file
make -f makefile_$file clean
done

if [ $? -eq 0 ]; then
echo " "
echo " Installation completed. Please refer to log file (unit_test/compile-g2tmpl-$machine.log) for details."
else
echo " "
echo " Installation encountered an error. Please refer to log file (unit_test/compile-g2tmpl-$machine.log) for details."
fi

echo " "
Loading

0 comments on commit bebb32c

Please sign in to comment.