find_mpi() { # for MPI, we try to detect system MPI variant if (command -v mpiexec > /dev/null 2>&1); then export MPI_ENABLED = true # check if we are dealing with openmpi, mpich or intelmpi if (mpiexec --version 2>&1 | grep -s -q "HYDRA"); then echo "MPI is detected and it appears to be MPICH" export MPI_MODE="mpich" # check openmpi version as reported by mpiexec export MPI_VERSION=$(mpiexec --version | grep "Version:" | awk '{print $2}') with_mpich="__SYSTEM__" elif (mpiexec --version 2>&1 | grep -s -q "OpenRTE"); then echo "MPI is detected and it appears to be OpenMPI" export MPI_MODE="openmpi" # check openmpi version as reported by mpiexec export MPI_VERSION=$(mpiexec --version 2>&1 | grep "(Open MPI)" | awk '{print $4}') with_openmpi="__SYSTEM__" elif (mpiexec --version 2>&1 | grep -s -q "Intel"); then echo "MPI is detected and it appears to be Intel MPI" export MPI_MODE="intelmpi" # check intelmpi version as reported by mpiicc export MPI_VERSION=$(mpiexec --version | grep "Version" | awk '{print $8"."$10}') with_intelmpi="__SYSTEM__" else # default to mpich echo "MPI is detected and defaults to MPICH" export MPI_MODE="mpich" with_mpich="__SYSTEM__" fi else report_warning $LINENO "No MPI installation detected (ignore this message in Cray Linux Environment or when MPI installation was requested)." export MPI_MODE="" fi } # helper routine to check integrity of downloaded files checksum() { local __filename=$1 local __sha256=$2 local __shasum_command='sha256sum' # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 command -v "$__shasum_command" > /dev/null 2>&1 || __shasum_command="shasum -a 256" if echo "$__sha256 $__filename" | ${__shasum_command} --check; then echo "Checksum of $__filename Ok" else rm -v ${__filename} report_error "Checksum of $__filename could not be verified, abort." return 1 fi } # verify the checksums inside the given checksum file verify_checksums() { local __checksum_file=$1 local __shasum_command='sha256sum' # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 command -v "$__shasum_command" > /dev/null 2>&1 || __shasum_command="shasum -a 256" ${__shasum_command} --check "${__checksum_file}" > /dev/null 2>&1 } # write a checksum file $1 containing checksums for each given file $2, $3, ... (plus the $VERSION_FILE) write_checksums() { local __checksum_file=$1 shift # remove output file from arguments to be able to pass them along properly quoted local __shasum_command='sha256sum' # check if we have sha256sum command, Mac OS X does not have # sha256sum, but has an equivalent with shasum -a 256 command -v "$__shasum_command" > /dev/null 2>&1 || __shasum_command="shasum -a 256" ${__shasum_command} "${VERSION_FILE}" "$@" > "${__checksum_file}" } # generate a filtered toolchain.env write_toolchain_env() { local __installdir=$1 # run the following in a subshell to not affect the currently running shell # we do not need to achieve complete filtering, it is sufficient to # remove problematic variables (TERM/TERMCAP/COLORTERM) which may trigger # 'too many arguments' (since the environment vars are stored in the same memory block as command line arguments) # or which may not be valid anymore the next time the user runs the toolchain scripts, # like the proxy vars which may affect fetching tarballs ( unset COLORTERM DISPLAY EDITOR LESS LESSOPEN LOGNAME LS_COLORS PAGER unset TERM TERMCAP USER unset ftp_proxy http_proxy no_proxy unset GPG_AGENT_INFO SSH_AGENT_PID SSH_AUTH_SOCK SSH_CLIENT SSH_CONNECTION SSH_TTY unset LS_COLORS LS_OPTIONS unset STY WINDOW XAUTHORITY unset XDG_CURRENT_DESKTOP XDG_RUNTIME_DIR XDG_SEAT XDG_SESSION_CLASS XDG_SESSION_DESKTOP XDG_SESSION_ID XDG_SESSION_TYPE XDG_VTNR XDG_CONFIG_DIRS XDG_DATA_DIRS unset DBUS_SESSION_BUS_ADDRESS export -p ) > "${__installdir}/toolchain.env" }