Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/ncio-version
Browse files Browse the repository at this point in the history
  • Loading branch information
kgerheiser authored Aug 12, 2021
2 parents 05f80a9 + 0953042 commit 6f7a15c
Show file tree
Hide file tree
Showing 10 changed files with 196 additions and 53 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.2.0
36 changes: 36 additions & 0 deletions cmake/wgrib2/wgrib2-config-version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().

set(PACKAGE_VERSION @WGRIB2_VERSION@)

if (PACKAGE_FIND_VERSION_RANGE)
# Package version must be in the requested version range
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
else()
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
endif()


# if the installed project requested no architecture check, don't perform the check
if("FALSE")
return()
endif()
21 changes: 21 additions & 0 deletions cmake/wgrib2/wgrib2-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
find_path (WGRIB2_INCLUDES
wgrib2api.mod
HINTS $ENV{wgrib2_ROOT}/include)

find_library (WGRIB2_LIBRARIES
names libwgrib2.a
HINTS $ENV{wgrib2_ROOT}/lib)

if(EXISTS ${WGRIB2_INCLUDES} AND EXISTS ${WGRIB2_LIBRARIES})
message(STATUS "Found WGRIB2: include directory ${WGRIB2_INCLUDES}, library ${WGRIB2_LIBRARIES}")
else()
message(STATUS "Unable to locate WGRIB2 library and/or Fortran modules")
endif()

mark_as_advanced (WGRIB2_INCLUDES WGRIB2_LIBRARIES)

add_library(wgrib2::wgrib2 UNKNOWN IMPORTED)
set_target_properties(wgrib2::wgrib2 PROPERTIES
IMPORTED_LOCATION "${WGRIB2_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${WGRIB2_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${WGRIB2_LIBRARIES}")
124 changes: 124 additions & 0 deletions libs/build_wgrib2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#!/bin/bash

set -eux

name="wgrib2"
version=${1:-${STACK_wgrib2_version}}

software=$name-$version

# Hyphenated version used for install prefix
compiler=$(echo $HPC_COMPILER | sed 's/\//-/g')
install_as=${STACK_wgrib2_install_as:-${version}}

if $MODULES; then
set +x
source $MODULESHOME/init/bash
module load hpc-$HPC_COMPILER
module list
set -x
prefix="${PREFIX:-"/opt/modules"}/$compiler/$name/$install_as"
if [[ -d $prefix ]]; then
[[ $OVERWRITE =~ [yYtT] ]] && ( echo "WARNING: $prefix EXISTS: OVERWRITING!";$SUDO rm -rf $prefix ) \
|| ( echo "WARNING: $prefix EXISTS, SKIPPING"; exit 1 )
fi
else
prefix=${WGRIB2_ROOT:-"/usr/local"}
fi

export FC=$SERIAL_FC
export CC=$SERIAL_CC
export CXX=$SERIAL_CXX

cd ${HPC_STACK_ROOT}/${PKGDIR:-"pkg"}

URL="https://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v${version}"

[[ -d $software ]] || ( $WGET $URL; tar -xf wgrib2.tgz.v${version} )
# wgrib2 is untarred as 'grib2'. Give a name with version.
[[ -d $software ]] || mkdir $software && tar -xf wgrib2.tgz.v${version} -C $software --strip-components 1
[[ ${DOWNLOAD_ONLY} =~ [yYtT] ]] && exit 0

[[ -d $software ]] && cd $software || ( echo "$software does not exist, ABORT!"; exit 1 )

# The Jasper inside of wgrib2 does not build with Clang on macOS
# Implicit function declaration error and no way to pass flags to suppress it.
host=$(uname -s)
if [[ "$host" == "Darwin" ]]; then
if [[ `$CC --version` == *"clang"* ]]; then
echo "Warning: The Jasper contained in wgrib2 does not build with Clang on macOS"
export STACK_wgrib2_jasper=0
fi
fi

if [[ $($CC --version | grep Intel) ]]; then
export COMP_SYS=intel_linux
fi

# Wgrib2 uses an in-source build. Clean before starting.
make clean
make deep-clean

# Edit makefile with options or defaults
sed -i'.backup' "s:^USE_NETCDF3=.*:USE_NETCDF3=${STACK_wgrib2_netcdf3:-1}:" makefile
sed -i'.backup' "s:^USE_NETCDF4=.*:USE_NETCDF4=${STACK_wgrib2_netcdf4:-0}:" makefile
sed -i'.backup' "s:^USE_REGEX=.*:USE_REGEX=${STACK_wgrib2_negex:-1}:" makefile
sed -i'.backup' "s:^USE_TIGGE=.*:USE_TIGGE=${STACK_wgrib2_tigge:-1}:" makefile
sed -i'.backup' "s:^USE_IPOLATES=.*:USE_IPOLATES=${STACK_wgrib2_ipolates:-3}:" makefile
sed -i'.backup' "s:^USE_SPECTRAL=.*:USE_SPECTRAL=${STACK_wgrib2_spectral:-0}:" makefile
sed -i'.backup' "s:^USE_UDF=.*:USE_AEC=${STACK_wgrib2_udf:-0}:" makefile
sed -i'.backup' "s:^USE_JASPER=.*:USE_JASPER=${STACK_wgrib2_jasper:-1}:" makefile
sed -i'.backup' "s:^USE_OPENMP=.*:USE_OPENMP=${STACK_wgrib2_openmp:-1}:" makefile
sed -i'.backup' "s:^MAKE_FTN_API=.*:MAKE_FTN_API=${STACK_wgrib2_ftn_api:-1}:" makefile
sed -i'.backup' "s:^USE_G2CLIB=.*:USE_G2CLIB=${STACK_wgrib2_g2clib:-0}:" makefile
sed -i'.backup' "s:^USE_PNG=.*:USE_PNG=${STACK_wgrib2_png:-1}:" makefile
sed -i'.backup' "s:^USE_AEC=.*:USE_AEC=${STACK_wgrib2_aec:-1}:" makefile

make

# Wgrib2 does not provide a 'make install'
$SUDO mkdir -p ${prefix}
$SUDO mkdir -p ${prefix}/bin

$SUDO cp wgrib2/wgrib2 $prefix/bin

# Build wgrib2 library with all settings off
if [[ ${STACK_wgrib2_lib:-n} =~ [yYtT] ]]; then
make clean
make deep-clean

$SUDO mkdir -p ${prefix}/lib
$SUDO mkdir -p ${prefix}/include

sed -i'.backup' "s:^USE_NETCDF3=.*:USE_NETCDF3=0:" makefile
sed -i'.backup' "s:^USE_NETCDF4=.*:USE_NETCDF4=0:" makefile
sed -i'.backup' "s:^USE_REGEX=.*:USE_REGEX=1:" makefile
sed -i'.backup' "s:^USE_TIGGE=.*:USE_TIGGE=1:" makefile
sed -i'.backup' "s:^USE_IPOLATES=.*:USE_IPOLATES=0:" makefile
sed -i'.backup' "s:^USE_SPECTRAL=.*:USE_SPECTRAL=0:" makefile
sed -i'.backup' "s:^USE_UDF=.*:USE_AEC=0:" makefile
sed -i'.backup' "s:^USE_JASPER=.*:USE_JASPER=0:" makefile
sed -i'.backup' "s:^USE_OPENMP=.*:USE_OPENMP=0:" makefile
sed -i'.backup' "s:^MAKE_FTN_API=.*:MAKE_FTN_API=1:" makefile
sed -i'.backup' "s:^USE_G2CLIB=.*:USE_G2CLIB=0:" makefile
sed -i'.backup' "s:^USE_PNG=.*:USE_PNG=0:" makefile
sed -i'.backup' "s:^USE_AEC=.*:USE_AEC=0:" makefile

make lib

$SUDO cp lib/libwgrib2.a ${prefix}/lib
$SUDO cp lib/wgrib2api.mod lib/wgrib2lowapi.mod ${prefix}/include

# Stage CMake package config, fill-in the version, and install
rm -rf cmake
mkdir cmake
cp -r ${HPC_STACK_ROOT}/cmake/wgrib2 ./cmake
sed -i'.backup' -e "s:@WGRIB2_VERSION@:${version}:" ./cmake/wgrib2/wgrib2-config-version.cmake
rm ./cmake/wgrib2/wgrib2-config-version.cmake.backup
$SUDO cp -r cmake ${prefix}/lib
fi

# generate modulefile from template
modpath=compiler
$MODULES && update_modules $modpath $name $install_as
echo $name $version $URL >> ${HPC_STACK_ROOT}/hpc-stack-contents.log
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ prepend_path("PATH", pathJoin(base,"bin"))
setenv("wgrib2_ROOT", base)
setenv("wgrib2_VERSION", pkgVersion)
setenv("WGRIB2_INC", pathJoin(base,"include"))
setenv("WGRIB_LIB", pathJoin(base,"${CMAKE_INSTALL_LIBDIR}","libwgrib2.a"))
setenv("WGRIB2_LIBAPI", pathJoin(base,"${CMAKE_INSTALL_LIBDIR}","libwgrib2_api.a"))
setenv("WGRIB2_LIB", pathJoin(base,"lib","libwgrib2.a"))

whatis("Name: ".. pkgName)
whatis("Version: " .. pkgVersion)
Expand Down

This file was deleted.

7 changes: 3 additions & 4 deletions stack/stack_custom.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,10 @@ bufr:

wgrib2:
build: YES
version: v2.0.8-cmake-v6
version: 2.0.8
install_as: 2.0.8
openmp: ON
cmake_opts: "-DUSE_SPECTRAL=ON -DUSE_IPOLATES=3 -DUSE_NETCDF4=ON"
is_nceplib: YES
lib: YES
ipolates: 3

prod_util:
build: YES
Expand Down
9 changes: 4 additions & 5 deletions stack/stack_gaea.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,11 @@ bufr:

wgrib2:
build: YES
version: v2.0.8-cmake-v6
version: 2.0.8
install_as: 2.0.8
openmp: ON
cmake_opts: "-DUSE_SPECTRAL=ON -DUSE_IPOLATES=3 -DUSE_NETCDF4=ON"
is_nceplib: YES

lib: YES
ipolates: 3

prod_util:
build: YES
version: v1.2.2
Expand Down
7 changes: 3 additions & 4 deletions stack/stack_mac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,10 @@ bufr:

wgrib2:
build: YES
version: v2.0.8-cmake-v6
version: 2.0.8
install_as: 2.0.8
openmp: OFF
cmake_opts: "-DUSE_SPECTRAL=ON -DUSE_IPOLATES=3 -DUSE_NETCDF4=ON"
is_nceplib: YES
lib: YES
ipolates: 3

prod_util:
build: YES
Expand Down
7 changes: 3 additions & 4 deletions stack/stack_noaa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,10 @@ bufr:

wgrib2:
build: YES
version: v2.0.8-cmake-v6
version: 2.0.8
install_as: 2.0.8
openmp: ON
cmake_opts: "-DUSE_SPECTRAL=ON -DUSE_IPOLATES=3 -DUSE_NETCDF4=ON"
is_nceplib: YES
lib: YES
ipolates: 3

prod_util:
build: YES
Expand Down

0 comments on commit 6f7a15c

Please sign in to comment.