Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'set -u' to all shell scripts #7

Merged
merged 4 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# build_stack.sh -p "prefix" -c "config.sh" -y "stack.yaml" -m
# build_stack.sh -h

set -e
set -eu

# root directory for the repository
HPC_BUILDSCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
Expand Down Expand Up @@ -120,9 +120,9 @@ fi
#----------------------
# Compiler and MPI
build_lib gnu
$MODULES || { [[ ${STACK_gnu_build} =~ [yYtT] ]] && export PATH="$PREFIX/bin:$PATH"; }
$MODULES || { [[ ${STACK_gnu_build:-} =~ [yYtT] ]] && export PATH="$PREFIX/bin:$PATH"; }
build_lib mpi
$MODULES || { [[ ${STACK_mpi_build} =~ [yYtT] ]] && export PATH="$PREFIX/bin:$PATH"; }
$MODULES || { [[ ${STACK_mpi_build:-} =~ [yYtT] ]] && export PATH="$PREFIX/bin:$PATH"; }

# ==============================================================================
#----------------------
Expand Down
2 changes: 1 addition & 1 deletion libs/build_boost.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -x
set -eux

name="boost"
version=${1:-${STACK_boost_version}}
Expand Down
2 changes: 1 addition & 1 deletion libs/build_cgal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#
#

set -ex
set -eux

name="cgal"
version=${1:-${STACK_cgal_version}}
Expand Down
2 changes: 1 addition & 1 deletion libs/build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# allows you to place it into a module context so you can experiment
# with different versions

set -ex
set -eux

name="cmake"
version=${1:-${STACK_cmake_version}}
Expand Down
2 changes: 1 addition & 1 deletion libs/build_eigen.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="eigen"
version=${1:-${STACK_eigen_version}}
Expand Down
8 changes: 4 additions & 4 deletions libs/build_esmf.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="esmf"
version=${1:-${STACK_esmf_version}}
Expand Down Expand Up @@ -54,9 +54,9 @@ else
fi

export F9X=$FC
export FFLAGS="${STACK_esmf_FFLAGS} -fPIC"
export CFLAGS="${STACK_esmf_CFLAGS} -fPIC"
export CXXFLAGS="${STACK_esmf_CXXFLAGS} -fPIC"
export FFLAGS="${STACK_esmf_FFLAGS:-} -fPIC"
export CFLAGS="${STACK_esmf_CFLAGS:-} -fPIC"
export CXXFLAGS="${STACK_esmf_CXXFLAGS:-} -fPIC"
export FCFLAGS="$FFLAGS"

gitURL="https://github.com/esmf-org/esmf"
Expand Down
2 changes: 1 addition & 1 deletion libs/build_fftw.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="fftw"
version=${1:-${STACK_fftw_version}}
Expand Down
2 changes: 1 addition & 1 deletion libs/build_gnu.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="gnu"
version=${1:-${STACK_gnu_version}}
Expand Down
2 changes: 1 addition & 1 deletion libs/build_gptl.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="gptl"
version=${1:-${STACK_gptl_version}}
Expand Down
16 changes: 8 additions & 8 deletions libs/build_hdf5.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="hdf5"
version=${1:-${STACK_hdf5_version}}
Expand All @@ -9,9 +9,9 @@ version=${1:-${STACK_hdf5_version}}
compiler=$(echo $HPC_COMPILER | sed 's/\//-/g')
mpi=$(echo $HPC_MPI | sed 's/\//-/g')

[[ ${STACK_hdf5_enable_szip} =~ [yYtT] ]] && enable_szip=YES || enable_szip=NO
[[ ${STACK_hdf5_enable_zlib} =~ [yYtT] ]] && enable_zlib=YES || enable_zlib=NO
[[ ${STACK_hdf5_shared} =~ [yYtT] ]] && enable_shared=YES || enable_shared=NO
[[ ${STACK_hdf5_enable_szip:-} =~ [yYtT] ]] && enable_szip=YES || enable_szip=NO
[[ ${STACK_hdf5_enable_zlib:-} =~ [yYtT] ]] && enable_zlib=YES || enable_zlib=NO
[[ ${STACK_hdf5_shared:-} =~ [yYtT] ]] && enable_shared=YES || enable_shared=NO

if $MODULES; then
set +x
Expand Down Expand Up @@ -44,9 +44,9 @@ else
fi

export F9X=$FC
export FFLAGS="${STACK_hdf5_FFLAGS} -fPIC -w"
export CFLAGS="${STACK_hdf5_CFLAGS} -fPIC -w"
export CXXFLAGS="${STACK_hdf5_CXXFLAGS} -fPIC -w"
export FFLAGS="${STACK_hdf5_FFLAGS:-} -fPIC -w"
export CFLAGS="${STACK_hdf5_CFLAGS:-} -fPIC -w"
export CXXFLAGS="${STACK_hdf5_CXXFLAGS:-} -fPIC -w"
export FCFLAGS="$FFLAGS"

gitURL="https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git"
Expand All @@ -68,7 +68,7 @@ mkdir -p build && cd build

../configure --prefix=$prefix \
--enable-fortran --enable-cxx \
$szip_flags $zlib_flags $shared_flags $extra_conf
${szip_flags:-} ${zlib_flags:-} ${shared_flags:-} ${extra_conf:-}

VERBOSE=$MAKE_VERBOSE make -j${NTHREADS:-4}
[[ $MAKE_CHECK =~ [yYtT] ]] && make check
Expand Down
8 changes: 4 additions & 4 deletions libs/build_jasper.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

set -ex
set -eux

name="jasper"
version=${1:-${STACK_jasper_version}}

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

[[ ${STACK_jasper_shared} =~ [yYtT] ]] && enable_shared=YES || enable_shared=NO
[[ ${STACK_jasper_shared:-} =~ [yYtT] ]] && enable_shared=YES || enable_shared=NO

if $MODULES; then
set +x
Expand All @@ -30,8 +30,8 @@ export CC=$SERIAL_CC
export CXX=$SERIAL_CXX

export F77=$FC
export FFLAGS="${STACK_jasper_FFLAGS} -fPIC"
export CFLAGS="${STACK_jasper_CFLAGS} -fPIC"
export FFLAGS="${STACK_jasper_FFLAGS:-} -fPIC"
export CFLAGS="${STACK_jasper_CFLAGS:-} -fPIC"

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

Expand Down
4 changes: 2 additions & 2 deletions libs/build_jpeg.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="jpeg"
version=${1:-${STACK_jpeg_version}}
Expand All @@ -27,7 +27,7 @@ else
fi

export CC=$SERIAL_CC
export CFLAGS="${STACK_jpeg_CFLAGS} -fPIC"
export CFLAGS="${STACK_jpeg_CFLAGS:-} -fPIC"

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

Expand Down
2 changes: 1 addition & 1 deletion libs/build_lapack.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="lapack"
version=${1:-${STACK_lapack_version}}
Expand Down
2 changes: 1 addition & 1 deletion libs/build_lmod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# usage:
# build_lmod.sh <prefix>

set -ex
set -eux

if [[ $# -lt 1 ]]; then
mods_path=/opt
Expand Down
2 changes: 1 addition & 1 deletion libs/build_mpi.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name=${1:-${STACK_mpi_flavor}}
version=${2:-${STACK_mpi_version}}
Expand Down
12 changes: 6 additions & 6 deletions libs/build_nccmp.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="nccmp"
version=${1:-${STACK_nccmp_version}}
Expand Down Expand Up @@ -52,19 +52,19 @@ else
export CXX=$SERIAL_CXX
fi

export CFLAGS="${STACK_nccmp_CFLAGS} -fPIC"
export CFLAGS="${STACK_nccmp_CFLAGS:-} -fPIC"
LDFLAGS1="-L$HDF5_ROOT/lib -lhdf5_hl -lhdf5"
LDFLAGS2=$(cat $HDF5_ROOT/lib/libhdf5.settings | grep AM_LDFLAGS | cut -d: -f2)
LDFLAGS3=$(cat $HDF5_ROOT/lib/libhdf5.settings | grep "Extra libraries" | cut -d: -f2)
if [[ ! -z $mpi ]]; then
[[ $enable_pnetcdf =~ [yYtT] ]] && LDFLAGS4="-L$PNETCDF_ROOT/lib -lpnetcdf"
fi
LDFLAGS5="-L$NETCDF_ROOT/lib -lnetcdf"
export LDFLAGS="$LDFLAGS1 $LDFLAGS2 $LDFLAGS3 $LDFLAGS4 $LDFLAGS5"
export LDFLAGS="${LDFLAGS1:-} ${LDFLAGS2:-} ${LDFLAGS3:-} ${LDFLAGS4:-} ${LDFLAGS5:-}"

# Enable header pad comparison, if netcdf-c src directory exists!
[[ -d "netcdf-c-$NETCDF_VERSION" ]] && netcdf_src="$PWD/netcdf-c-$NETCDF_VERSION"
[[ -d "netcdf-c-$NETCDF_VERSION" ]] && extra_confs="--with-netcdf=$netcdf_src"
[[ -d "netcdf-c-${NETCDF_VERSION:-}" ]] && netcdf_src="$PWD/netcdf-c-$NETCDF_VERSION"
[[ -d "netcdf-c-${NETCDF_VERSION:-}" ]] && extra_confs="--with-netcdf=$netcdf_src"

[[ -d $software ]] && cd $software || ( echo "$software does not exist, ABORT!"; exit 1 )
[[ -d build ]] && rm -rf build
Expand All @@ -79,7 +79,7 @@ cmake .. \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DNETCDF_INC_DIR=$NETCDF_ROOT/include \
-DNETCDF_LIB_PATH=$NETCDF_ROOT/lib/libnetcdf.a \
-DWITH_NETCDF=$netcdf_src
-DWITH_NETCDF=${netcdf_src:-}

make -j${NTHREADS:-4}
[[ $MAKE_CHECK =~ [yYtT] ]] && make check
Expand Down
15 changes: 8 additions & 7 deletions libs/build_nceplibs.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name=$1
eval s_version="\${STACK_${name}_version}"
Expand All @@ -13,6 +13,7 @@ openmp=${4:-${s_openmp:-"OFF"}}
# Hyphenated version used for install prefix
compiler=$(echo $HPC_COMPILER | sed 's/\//-/g')
mpi_check=$(echo $HPC_MPI | sed 's/\//-/g')
mpi=''

if $MODULES; then
set +x
Expand Down Expand Up @@ -121,9 +122,9 @@ else
export CXX=$SERIAL_CXX
fi

eval fflags="\${STACK_${name}_FFLAGS}"
eval cflags="\${STACK_${name}_CFLAGS}"
eval cxxflags="\${STACK_${name}_CXXFLAGS}"
eval fflags="\${STACK_${name}_FFLAGS:-}"
eval cflags="\${STACK_${name}_CFLAGS:-}"
eval cxxflags="\${STACK_${name}_CXXFLAGS:-}"

export F9X=$FC
export FFLAGS="$fflags -fPIC -w"
Expand All @@ -143,8 +144,8 @@ case $name in
gitURL="https://github.com/noaa-emc/emc_crtm"
;;
wgrib2)
[[ -z $STACK_wgrib2_ipolates ]] && ipolates=0 || ipolates=$STACK_wgrib2_ipolates
[[ -z $STACK_wgrib2_spectral ]] && spectral=OFF || spectral=$STACK_wgrib2_spectral
[[ -z ${STACK_wgrib2_ipolates:-} ]] && ipolates=0 || ipolates=$STACK_wgrib2_ipolates
[[ -z ${STACK_wgrib2_spectral:-} ]] && spectral=OFF || spectral=$STACK_wgrib2_spectral
extraCMakeFlags="-DUSE_SPECTRAL=$spectral -DUSE_IPOLATES=$ipolates"
;;
esac
Expand All @@ -168,7 +169,7 @@ mkdir -p build && cd build
cmake .. \
-DCMAKE_INSTALL_PREFIX=$prefix \
-DENABLE_TESTS=OFF \
$extraCMakeFlags \
${extraCMakeFlags:-} \
-DOPENMP=${openmp}

VERBOSE=$MAKE_VERBOSE make -j${NTHREADS:-4}
Expand Down
8 changes: 4 additions & 4 deletions libs/build_nco.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="nco"
version=${1:-${STACK_nco_version}}
Expand Down Expand Up @@ -47,9 +47,9 @@ else
export CXX=$SERIAL_CXX
fi

export FFLAGS="${STACK_nco_FFLAGS} -fPIC"
export CFLAGS="${STACK_nco_CFLAGS} -fPIC"
export CXXFLAGS="${STACK_nco_CXXFLAGS} -fPIC"
export FFLAGS="${STACK_nco_FFLAGS:-} -fPIC"
export CFLAGS="${STACK_nco_CFLAGS:-} -fPIC"
export CXXFLAGS="${STACK_nco_CXXFLAGS:-} -fPIC"

export F77=$FC
export FCFLAGS=$FFLAGS
Expand Down
20 changes: 10 additions & 10 deletions libs/build_netcdf.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

set -ex
set -eux

name="netcdf"
c_version=${1:-${STACK_netcdf_version_c}}
Expand All @@ -11,7 +11,7 @@ cxx_version=${3:-${STACK_netcdf_version_cxx}}
compiler=$(echo $HPC_COMPILER | sed 's/\//-/g')
mpi=$(echo $HPC_MPI | sed 's/\//-/g')

[[ ${STACK_netcdf_enable_pnetcdf} =~ [yYtT] ]] && enable_pnetcdf=YES || enable_pnetcdf=NO
[[ ${STACK_netcdf_enable_pnetcdf:-} =~ [yYtT] ]] && enable_pnetcdf=YES || enable_pnetcdf=NO

if $MODULES; then
set +x
Expand Down Expand Up @@ -48,9 +48,9 @@ fi

export F77=$FC
export F9X=$FC
export FFLAGS="${STACK_netcdf_FFLAGS} -fPIC"
export CFLAGS="${STACK_netcdf_CFLAGS} -fPIC"
export CXXFLAGS="${STACK_netcdf_CXXFLAGS} -fPIC -std=c++11"
export FFLAGS="${STACK_netcdf_FFLAGS:-} -fPIC"
export CFLAGS="${STACK_netcdf_CFLAGS:-} -fPIC"
export CXXFLAGS="${STACK_netcdf_CXXFLAGS:-} -fPIC -std=c++11"
export FCFLAGS="$FFLAGS"

gitURLroot="https://github.com/Unidata"
Expand All @@ -61,12 +61,12 @@ curr_dir=$(pwd)
LDFLAGS1="-L$HDF5_ROOT/lib"
LDFLAGS2=$(cat $HDF5_ROOT/lib/libhdf5.settings | grep AM_LDFLAGS | cut -d: -f2)
[[ $enable_pnetcdf =~ [yYtT] ]] && LDFLAGS4="-L$PNETCDF_ROOT/lib"
if [[ ${STACK_netcdf_shared} != [yYtT] ]]; then
if [[ ${STACK_netcdf_shared:-} != [yYtT] ]]; then
LDFLAGS1+=" -lhdf5_hl -lhdf5"
LDFLAGS3=$(cat $HDF5_ROOT/lib/libhdf5.settings | grep "Extra libraries" | cut -d: -f2)
[[ $enable_pnetcdf =~ [yYtT] ]] && LDFLAGS4+=" -lpnetcdf"
fi
export LDFLAGS="$LDFLAGS1 $LDFLAGS2 $LDFLAGS3 $LDFLAGS4"
export LDFLAGS="${LDFLAGS1:-} ${LDFLAGS2:-} ${LDFLAGS3:-} ${LDFLAGS4:-}"

export CFLAGS+=" -I$HDF5_ROOT/include"
export CPPFLAGS+=" -I$HDF5_ROOT/include"
Expand Down Expand Up @@ -118,7 +118,7 @@ mkdir -p build && cd build
--disable-dap \
--enable-netcdf-4 \
--disable-doxygen \
$shared_flags $pnetcdf_conf $extra_conf
${shared_flags:-} ${pnetcdf_conf:-} ${extra_conf:-}

VERBOSE=$MAKE_VERBOSE make -j${NTHREADS:-4}
[[ $MAKE_CHECK =~ [yYtT] ]] && make check
Expand Down Expand Up @@ -167,7 +167,7 @@ software=$name-"fortran"-$version
mkdir -p build && cd build

../configure --prefix=$prefix \
$shared_flags
${shared_flags:-}

#VERBOSE=$MAKE_VERBOSE make -j${NTHREADS:-4}
VERBOSE=$MAKE_VERBOSE make -j1 #NetCDF-Fortran-4.5.2 & intel/20 have a linker bug if built with j>1
Expand All @@ -192,7 +192,7 @@ software=$name-"cxx4"-$version
mkdir -p build && cd build

../configure --prefix=$prefix \
$shared_flags
${shared_flags:-}

VERBOSE=$MAKE_VERBOSE make -j${NTHREADS:-4}
[[ $MAKE_CHECK =~ [yYtT] ]] && make check
Expand Down
Loading