diff --git a/VERSION b/VERSION index 9084fa2f..26aaba0e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.2.0 diff --git a/cmake/wgrib2/wgrib2-config-version.cmake b/cmake/wgrib2/wgrib2-config-version.cmake new file mode 100644 index 00000000..3514efaa --- /dev/null +++ b/cmake/wgrib2/wgrib2-config-version.cmake @@ -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() diff --git a/cmake/wgrib2/wgrib2-config.cmake b/cmake/wgrib2/wgrib2-config.cmake new file mode 100644 index 00000000..e01b0b98 --- /dev/null +++ b/cmake/wgrib2/wgrib2-config.cmake @@ -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}") diff --git a/libs/build_wgrib2.sh b/libs/build_wgrib2.sh new file mode 100755 index 00000000..400705ea --- /dev/null +++ b/libs/build_wgrib2.sh @@ -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 diff --git a/modulefiles/compiler/compilerName/compilerVersion/wgrib2/wgrib2.lua b/modulefiles/compiler/compilerName/compilerVersion/wgrib2/wgrib2.lua index b62fa6a4..097d778a 100644 --- a/modulefiles/compiler/compilerName/compilerVersion/wgrib2/wgrib2.lua +++ b/modulefiles/compiler/compilerName/compilerVersion/wgrib2/wgrib2.lua @@ -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) diff --git a/modulefiles/mpi/compilerName/compilerVersion/mpiName/mpiVersion/wgrib2/wgrib2.lua b/modulefiles/mpi/compilerName/compilerVersion/mpiName/mpiVersion/wgrib2/wgrib2.lua deleted file mode 100644 index 47214eb5..00000000 --- a/modulefiles/mpi/compilerName/compilerVersion/mpiName/mpiVersion/wgrib2/wgrib2.lua +++ /dev/null @@ -1,33 +0,0 @@ -help([[ -]]) - -local pkgName = myModuleName() -local pkgVersion = myModuleVersion() -local pkgNameVer = myModuleFullName() - -local hierA = hierarchyA(pkgNameVer,2) -local mpiNameVer = hierA[1] -local compNameVer = hierA[2] -local mpiNameVerD = mpiNameVer:gsub("/","-") -local compNameVerD = compNameVer:gsub("/","-") - -conflict(pkgName) - -load("netcdf") -prereq("netcdf") - -local opt = os.getenv("HPC_OPT") or os.getenv("OPT") or "/opt/modules" - -local base = pathJoin(opt,compNameVerD,mpiNameVerD,pkgName,pkgVersion) - -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")) - -whatis("Name: ".. pkgName) -whatis("Version: " .. pkgVersion) -whatis("Category: library") -whatis("Description: " .. pkgName .. " library") diff --git a/stack/stack_custom.yaml b/stack/stack_custom.yaml index 8fff1e41..181ce39e 100644 --- a/stack/stack_custom.yaml +++ b/stack/stack_custom.yaml @@ -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 diff --git a/stack/stack_gaea.yaml b/stack/stack_gaea.yaml index 21498cc0..8d3d3e70 100644 --- a/stack/stack_gaea.yaml +++ b/stack/stack_gaea.yaml @@ -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 diff --git a/stack/stack_mac.yaml b/stack/stack_mac.yaml index 981a0de0..21181e8f 100644 --- a/stack/stack_mac.yaml +++ b/stack/stack_mac.yaml @@ -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 diff --git a/stack/stack_noaa.yaml b/stack/stack_noaa.yaml index 10adef33..277a6ed5 100644 --- a/stack/stack_noaa.yaml +++ b/stack/stack_noaa.yaml @@ -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