CONFIG: improve robustness/flexibility for MPI config handling

- use orte-info to determine prefix/libdir for openmpi.
  This removes a run-time dependency on mpicc, which is actually
  only needed for building with MPI (not running with MPI).
  The corresponding openmpi devel package (deb/rpm) will not
  necessarily be installed on a particular system.

- retain mpicc logic if the new logic using orte-info does not
  deliver an answer. Final fallback to using 'orterun' to
  infer prefix/libdir.

- Additional logic for intel and msmpi to make it easier to
  locate these vendor packages within ThirdParty
  (ie, under ThirdParty/opt/...)

CONFIG: improve robustness

- add check for absolute path when adding PATH/LD_LIBRARY_PATH etc.

- prefix more variables with '_foam*' to prevent accidental overwrite
  of userspace shell variables when sourcing
This commit is contained in:
Mark Olesen
2021-10-14 10:18:38 +02:00
parent f61228ae38
commit 16d48ed047
18 changed files with 288 additions and 130 deletions

View File

@ -8,8 +8,7 @@
# Copyright (C) 2016-2018 OpenCFD Ltd. # Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.csh/FFTW # etc/config.csh/FFTW

View File

@ -9,8 +9,7 @@
# Copyright (C) 2017 OpenCFD Ltd. # Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.csh/complete-wrapper # etc/config.csh/complete-wrapper
@ -38,14 +37,14 @@ then
fi fi
# Preload completion cache # Preload completion cache
if [ -f $WM_PROJECT_DIR/etc/config.sh/completion_cache ] if [ -f "$WM_PROJECT_DIR"/etc/config.sh/completion_cache ]
then . $WM_PROJECT_DIR/etc/config.sh/completion_cache then . "$WM_PROJECT_DIR"/etc/config.sh/completion_cache
fi fi
# Use the bash completion function, but retain cache etc. # Use the bash completion function, but retain cache etc.
_of_complete_tcsh=true _of_complete_tcsh=true
if [ -f $WM_PROJECT_DIR/etc/config.sh/bash_completion ] if [ -f "$WM_PROJECT_DIR"/etc/config.sh/bash_completion ]
then . $WM_PROJECT_DIR/etc/config.sh/bash_completion then . "$WM_PROJECT_DIR"/etc/config.sh/bash_completion
else else
# Could warn about missing file, or treat silently # Could warn about missing file, or treat silently
echo echo

View File

@ -8,8 +8,7 @@
# Copyright (C) 2011-2016 OpenFOAM Foundation # Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# config.csh/example/prefs.csh # config.csh/example/prefs.csh

View File

@ -40,7 +40,7 @@
# #
# Environment # Environment
# I_MPI_CC, I_MPI_CXX environment variables define the compiler # I_MPI_CC, I_MPI_CXX environment variables define the compiler
# to be used the Intel mpicc/mpicxx wrappers # to be used by Intel mpiicc/mpiicpc wrappers
# #
# MPI_BUFFER_SIZE overrides 'mpiBufferSize' (controlDict entry). # MPI_BUFFER_SIZE overrides 'mpiBufferSize' (controlDict entry).
# Eg, setenv MPI_BUFFER_SIZE 20000000 # Eg, setenv MPI_BUFFER_SIZE 20000000
@ -73,14 +73,57 @@ case SYSTEMOPENMPI:
if ( -d "$MPI_ARCH_PATH" ) then if ( -d "$MPI_ARCH_PATH" ) then
_foamAddLibAuto "$MPI_ARCH_PATH" _foamAddLibAuto "$MPI_ARCH_PATH"
else else
# Slight hack: strip off 'lib' to get prefix directory setenv MPI_ARCH_PATH
set libDir=`mpicc --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/'`
setenv MPI_ARCH_PATH "${libDir:h}" # prefix from libdir
_foamAddLib "$libDir"
unset libDir
endif endif
# Use <orte-info> (openmpi only command) to query configuration
if ( "$MPI_ARCH_PATH" == "" ) then
set _foamFoundCmd=`which orte-info`
if ($status == 0) then
# prefix
set _foamFoundDir=`orte-info --path prefix --parsable | sed -e 's/^.*:prefix://'`
if ( -d "$_foamFoundDir" ) then
setenv MPI_ARCH_PATH "${_foamFoundDir}"
# libdir
set _foamFoundDir=`orte-info --path libdir --parsable | sed -e 's/^.*:libdir://'`
if ( -d "$_foamFoundDir" ) then
_foamAddLib "$_foamFoundDir"
else if ( "$MPI_ARCH_PATH" != "/usr" ) then
_foamAddLibAuto "$MPI_ARCH_PATH"
endif
endif
endif
endif
# Use <mpicc> to get the link information and (slight hack)
# strip off 'lib' to get the prefix directory
if ( "$MPI_ARCH_PATH" == "" ) then
set _foamFoundCmd=`which mpicc`
if ($status == 0) then
set _foamFoundDir=`mpicc --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/'`
setenv MPI_ARCH_PATH "${_foamFoundDir:h}" # Prefix from libdir
_foamAddLib "$_foamFoundDir"
endif
endif
# Last resort (worse hack):
# Use <orterun> to get ../path/bin/orterun and infer prefix, libdir
if ( "$MPI_ARCH_PATH" == "" ) then
set _foamFoundCmd=`which orterun`
if ($status == 0) then
set _foamFoundDir="${_foamFoundCmd:h}" # The bin dir
setenv MPI_ARCH_PATH "${_foamFoundDir:h}" # The prefix dir
_foamAddLibAuto "$MPI_ARCH_PATH"
endif
endif
if ( "$MPI_ARCH_PATH" == "" ) then
echo "Warn: could not determine prefix for system-openmpi"
endif
unset _foamFoundCmd _foamFoundDir
#- #-
# TBD: extra (major) version qualifier on name? # TBD: extra (major) version qualifier on name?
#- #-
@ -107,9 +150,11 @@ case OPENMPI:
# Inform openmpi where to find its install directory # Inform openmpi where to find its install directory
setenv OPAL_PREFIX "$MPI_ARCH_PATH" setenv OPAL_PREFIX "$MPI_ARCH_PATH"
_foamAddPath "$MPI_ARCH_PATH"/bin if ( "$MPI_ARCH_PATH" != "" ) then
_foamAddMan "$MPI_ARCH_PATH"/share/man _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH" _foamAddMan "$MPI_ARCH_PATH"/share/man
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
endif
breaksw breaksw
@ -179,10 +224,11 @@ case MPICH:
endif endif
setenv MPI_HOME "$MPI_ARCH_PATH" setenv MPI_HOME "$MPI_ARCH_PATH"
if ( "$MPI_ARCH_PATH" != "" ) then
_foamAddPath "$MPI_ARCH_PATH"/bin _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddMan "$MPI_ARCH_PATH"/share/man _foamAddMan "$MPI_ARCH_PATH"/share/man
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH" _foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
endif
breaksw breaksw
@ -198,9 +244,11 @@ case MPICH-GM:
setenv MPICH_PATH "$MPI_ARCH_PATH" setenv MPICH_PATH "$MPI_ARCH_PATH"
setenv GM_LIB_PATH "$MPICH_PATH/lib$WM_COMPILER_LIB_ARCH" setenv GM_LIB_PATH "$MPICH_PATH/lib$WM_COMPILER_LIB_ARCH"
_foamAddPath "$MPI_ARCH_PATH"/bin if ( "$MPI_ARCH_PATH" != "" ) then
_foamAddLib "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$GM_LIB_PATH" _foamAddLib "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
_foamAddLib "$GM_LIB_PATH"
endif
breaksw breaksw
@ -214,9 +262,11 @@ case MVA2MPI:
setenv MPI_ARCH_PATH "$_foamMpiPrefixDir/$FOAM_MPI" setenv MPI_ARCH_PATH "$_foamMpiPrefixDir/$FOAM_MPI"
endif endif
_foamAddPath "$MPI_ARCH_PATH"/bin if ( "$MPI_ARCH_PATH" != "" ) then
_foamAddMan "$MPI_ARCH_PATH"/share/man _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH" _foamAddMan "$MPI_ARCH_PATH"/share/man
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
endif
breaksw breaksw
@ -231,8 +281,10 @@ case CRAY-MPICH:
echo "Please set MPICH_DIR correctly" echo "Please set MPICH_DIR correctly"
endif endif
# _foamAddPath "$MPI_ARCH_PATH"/bin if ( "$MPI_ARCH_PATH" != "" ) then
_foamAddLib "$MPI_ARCH_PATH"/lib # _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH"/lib
endif
breaksw breaksw
@ -241,26 +293,26 @@ case HPMPI:
setenv MPI_HOME /opt/hpmpi setenv MPI_HOME /opt/hpmpi
setenv MPI_ARCH_PATH "$MPI_HOME" setenv MPI_ARCH_PATH "$MPI_HOME"
set libDir="" set _foamFoundDir=""
switch (`uname -m`) switch (`uname -m`)
case x86_64: case x86_64:
set libDir=lib/linux_amd64 set _foamFoundDir=lib/linux_amd64
breaksw breaksw
case i686: case i686:
set libDir=lib/linux_ia32 set _foamFoundDir=lib/linux_ia32
breaksw breaksw
case ia64: case ia64:
set libDir=lib/linux_ia64 set _foamFoundDir=lib/linux_ia64
breaksw breaksw
endsw endsw
if ( "${libDir}" != "" ) then if ( "${_foamFoundDir}" != "" ) then
_foamAddPath "$MPI_ARCH_PATH"/bin _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH/$libDir" _foamAddLib "$MPI_ARCH_PATH/$_foamFoundDir"
else else
echo "openfoam: (`uname -m`) - unsupported HP-MPI processor type" echo "openfoam: (`uname -m`) - unsupported HP-MPI processor type"
endif endif
unset libDir unset _foamFoundDir
breaksw breaksw
@ -335,7 +387,20 @@ case INTELMPI*:
else if ( "$MPI_ARCH_PATH" != "" ) then else if ( "$MPI_ARCH_PATH" != "" ) then
# MPI_ARCH_PATH: Set I_MPI_ROOT accordingly # MPI_ARCH_PATH: Set I_MPI_ROOT accordingly
setenv I_MPI_ROOT "$MPI_ARCH_PATH" setenv I_MPI_ROOT "$MPI_ARCH_PATH"
else
# Final effort - check ThirdParty opt/intel locations for 'latest'
foreach _foamFoundDir (\
"$WM_THIRD_PARTY_DIR/opt/intel/oneapi/mpi/latest" \
"$WM_THIRD_PARTY_DIR/opt/intel/mpi/latest" \
)
if ( -d "$_foamFoundDir" ) then
setenv MPI_ARCH_PATH "$_foamFoundDir"
setenv I_MPI_ROOT "$MPI_ARCH_PATH"
break
endif
end
endif endif
unset _foamFoundDir
if ( -d "$MPI_ARCH_PATH" ) then if ( -d "$MPI_ARCH_PATH" ) then
# Remove trailing slash # Remove trailing slash
@ -364,7 +429,7 @@ case INTELMPI*:
# With/without "intel64/" directory - handled here and in mpi rules # With/without "intel64/" directory - handled here and in mpi rules
# Path, lib-path may have been set prior to call # Path, lib-path may have been set prior to call
if (1) then if ( -d "$MPI_ARCH_PATH" ) then
if ( -d "$MPI_ARCH_PATH"/intel64/lib ) then if ( -d "$MPI_ARCH_PATH"/intel64/lib ) then
_foamAddPath "$MPI_ARCH_PATH"/intel64/bin _foamAddPath "$MPI_ARCH_PATH"/intel64/bin
_foamAddLib "$MPI_ARCH_PATH"/intel64/lib _foamAddLib "$MPI_ARCH_PATH"/intel64/lib
@ -375,6 +440,34 @@ case INTELMPI*:
_foamAddLib "$MPI_ARCH_PATH"/lib/release _foamAddLib "$MPI_ARCH_PATH"/lib/release
endif endif
endif endif
breaksw
case MSMPI:
setenv FOAM_MPI msmpi
_foamEtc -config prefs.msmpi ## Optional adjustments
# MPI_ARCH_PATH (prefs) if a valid dir, or ThirdParty location
# Also consider ThirdParty 'opt/' directory (binary package)
if ( ! -d "$MPI_ARCH_PATH" ) then
foreach _foamFoundDir (\
"$_foamMpiPrefixDir/$FOAM_MPI" \
"$WM_THIRD_PARTY_DIR/opt/$FOAM_MPI" \
)
if ( -d "$_foamFoundDir" ) then
setenv MPI_ARCH_PATH "$_foamFoundDir"
break
endif
end
endif
unset _foamFoundDir
if ( -d "$MPI_ARCH_PATH" ) then
# _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH"/lib/x64
endif
breaksw
endsw endsw

View File

@ -96,7 +96,7 @@ case MSYS*:
if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Mingw if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Mingw
setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw
echo "openfoam: windows support (mingw64) is runtime only" echo "openfoam: windows support (mingw64) is runtime only"
;; breaksw
case SunOS*: case SunOS*:
setenv WM_ARCH solaris64 setenv WM_ARCH solaris64
@ -146,12 +146,12 @@ setenv FOAM_USER_APPBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin"
setenv FOAM_USER_LIBBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib" setenv FOAM_USER_LIBBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib"
# Prepend wmake to the path - not required for runtime-only environment # Prepend wmake to the path - not required for runtime-only environment
set foundDir="${WM_PROJECT_DIR}/wmake" set _foamFoundDir="${WM_PROJECT_DIR}/wmake"
if ( $?WM_DIR ) then if ( $?WM_DIR ) then
if ( -d "${WM_DIR}" ) set foundDir="${WM_DIR}" if ( -d "${WM_DIR}" ) set _foamFoundDir="${WM_DIR}"
endif endif
if ( -d "$foundDir" ) then if ( -d "$_foamFoundDir" ) then
setenv PATH "${foundDir}:${PATH}" setenv PATH "${_foamFoundDir}:${PATH}"
else else
unsetenv WM_DIR unsetenv WM_DIR
endif endif
@ -317,7 +317,7 @@ endsw
# Cleanup # Cleanup
# ~~~~~~~ # ~~~~~~~
unset archDir siteDir foundDir archOption unset archOption archDir siteDir _foamFoundDir
unset gcc_version gccDir unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir unset clang_version clangDir

View File

@ -30,7 +30,7 @@
setenv FOAM_API `$WM_PROJECT_DIR/bin/foamEtcFile -show-api` setenv FOAM_API `$WM_PROJECT_DIR/bin/foamEtcFile -show-api`
# The installation parent directory # The installation parent directory
set prefixDir="${WM_PROJECT_DIR:h}" set _foamPrefixDir="${WM_PROJECT_DIR:h}"
# Load shell "functions" (actually aliases) # Load shell "functions" (actually aliases)
source "$WM_PROJECT_DIR/etc/config.csh/functions" source "$WM_PROJECT_DIR/etc/config.csh/functions"
@ -52,16 +52,16 @@ if ( -e "$WM_PROJECT_DIR/ThirdParty" ) then
setenv WM_THIRD_PARTY_DIR "$WM_PROJECT_DIR/ThirdParty" setenv WM_THIRD_PARTY_DIR "$WM_PROJECT_DIR/ThirdParty"
else else
_foamEcho "Locating ThirdParty directory" _foamEcho "Locating ThirdParty directory"
foreach foundDir (\ foreach _foamFoundDir (\
"$prefixDir/ThirdParty-$WM_PROJECT_VERSION" \ "$_foamPrefixDir/ThirdParty-$WM_PROJECT_VERSION" \
"$prefixDir/ThirdParty-v$FOAM_API" \ "$_foamPrefixDir/ThirdParty-v$FOAM_API" \
"$prefixDir/ThirdParty-$FOAM_API" \ "$_foamPrefixDir/ThirdParty-$FOAM_API" \
"$prefixDir/ThirdParty-common" \ "$_foamPrefixDir/ThirdParty-common" \
) )
_foamEcho "... $foundDir" _foamEcho "... $_foamFoundDir"
if ( -d "$foundDir" ) then if ( -d "$_foamFoundDir" ) then
if ( -f "$foundDir/Allwmake" || -d "$foundDir/platforms" ) then if ( -f "$_foamFoundDir/Allwmake" || -d "$_foamFoundDir/platforms" ) then
setenv WM_THIRD_PARTY_DIR "$foundDir" setenv WM_THIRD_PARTY_DIR "$_foamFoundDir"
break break
else else
_foamEcho " does not have Allwmake or platforms/" _foamEcho " does not have Allwmake or platforms/"
@ -239,6 +239,6 @@ unalias _foamAddLib
unalias _foamAddLibAuto unalias _foamAddLibAuto
# Variables (done as final statement for a clean exit code) # Variables (done as final statement for a clean exit code)
unset cleaned foamOldDirs foundDir prefixDir unset cleaned foamOldDirs _foamFoundDir _foamPrefixDir
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -8,8 +8,7 @@
# Copyright (C) 2017 OpenCFD Ltd. # Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.csh/tcsh_completion # etc/config.csh/tcsh_completion

View File

@ -8,8 +8,7 @@
# Copyright (C) 2016-2019 OpenCFD Ltd. # Copyright (C) 2016-2019 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.csh/vtk # etc/config.csh/vtk

View File

@ -8,8 +8,7 @@
# Copyright (C) 2016-2018 OpenCFD Ltd. # Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/FFTW # etc/config.sh/FFTW

View File

@ -8,8 +8,7 @@
# Copyright (C) 2016 OpenCFD Ltd. # Copyright (C) 2016 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/ccmio # etc/config.sh/ccmio

View File

@ -50,35 +50,31 @@ then
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
_foamEcho() { echo "$@" 1>&2; } _foamEcho() { echo "$@" 1>&2; }
_foamEtc() { _foamEtc() { eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh-verbose "$@")"; }
eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh-verbose "$@")";
}
else else
_foamEcho() { true; } _foamEcho() { true; }
_foamEtc() { _foamEtc() { eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh "$@")"; }
eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh "$@")";
}
fi fi
# Prepend PATH # Prepend PATH
unset -f _foamAddPath 2>/dev/null unset -f _foamAddPath 2>/dev/null
_foamAddPath() _foamAddPath()
{ {
[ -n "$1" ] && export PATH="$1:$PATH" case "$1" in (/?*) export PATH="$1:$PATH" ;; esac
} }
# Prepend MANPATH # Prepend MANPATH
unset -f _foamAddMan 2>/dev/null unset -f _foamAddMan 2>/dev/null
_foamAddMan() _foamAddMan()
{ {
[ -n "$1" ] && export MANPATH="$1:$MANPATH" case "$1" in (/?*) export MANPATH="$1:$MANPATH" ;; esac
} }
# Prepend LD_LIBRARY_PATH # Prepend LD_LIBRARY_PATH
unset -f _foamAddLib 2>/dev/null unset -f _foamAddLib 2>/dev/null
_foamAddLib() _foamAddLib()
{ {
[ -n "$1" ] && export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH" case "$1" in (/?*) export LD_LIBRARY_PATH="$1:$LD_LIBRARY_PATH" ;; esac
} }
# Prepend to LD_LIBRARY_PATH with additional checking # Prepend to LD_LIBRARY_PATH with additional checking
@ -118,11 +114,11 @@ then
fi fi
# Use fallback. Add without checking existence of the directory # Use fallback. Add without checking existence of the directory
foamVar_end=$2 foamVar_end="$2"
if [ -n "$foamVar_end" ] if [ -n "$foamVar_end" ]
then then
case "$foamVar_end" in case "$foamVar_end" in
/*) # An absolute path (/*) # Absolute path
export LD_LIBRARY_PATH="$foamVar_end:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH="$foamVar_end:$LD_LIBRARY_PATH"
;; ;;
(*) # Relative to prefix (*) # Relative to prefix
@ -147,7 +143,7 @@ then
# Prepend DYLD_LIBRARY_PATH # Prepend DYLD_LIBRARY_PATH
_foamAddLib() _foamAddLib()
{ {
[ -n "$1" ] && export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH" case "$1" in (/?*) export DYLD_LIBRARY_PATH="$1:$DYLD_LIBRARY_PATH" ;; esac
} }
# Prepend to DYLD_LIBRARY_PATH with additional checking # Prepend to DYLD_LIBRARY_PATH with additional checking

View File

@ -8,8 +8,7 @@
# Copyright (C) 2017-2019 OpenCFD Ltd. # Copyright (C) 2017-2019 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/kahip # etc/config.sh/kahip

View File

@ -9,8 +9,7 @@
# Copyright (C) 2016-2017 OpenCFD Ltd. # Copyright (C) 2016-2017 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/metis # etc/config.sh/metis

View File

@ -8,8 +8,7 @@
# Copyright (C) 2017 OpenCFD Ltd. # Copyright (C) 2017 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/mgridgen # etc/config.sh/mgridgen

View File

@ -38,7 +38,7 @@
# #
# Environment # Environment
# I_MPI_CC, I_MPI_CXX environment variables define the compiler # I_MPI_CC, I_MPI_CXX environment variables define the compiler
# to be used the Intel mpicc/mpicxx wrappers # to be used by Intel mpiicc/mpiicpc wrappers
# #
# MPI_BUFFER_SIZE overrides 'mpiBufferSize' (controlDict entry). # MPI_BUFFER_SIZE overrides 'mpiBufferSize' (controlDict entry).
# Eg, export MPI_BUFFER_SIZE=20000000 # Eg, export MPI_BUFFER_SIZE=20000000
@ -71,19 +71,63 @@ SYSTEMOPENMPI | SYSTEMOPENMPI[1-9])
fi fi
_foamEtc -config prefs.sys-openmpi ## Optional adjustments _foamEtc -config prefs.sys-openmpi ## Optional adjustments
# MPI_ARCH_PATH (prefs) if a valid dir, or discover via <mpicc> unset _foamFoundCmd
# MPI_ARCH_PATH (prefs) if a valid dir, or need to discover
if [ -d "$MPI_ARCH_PATH" ] if [ -d "$MPI_ARCH_PATH" ]
then then
_foamAddLibAuto "$MPI_ARCH_PATH" _foamAddLibAuto "$MPI_ARCH_PATH"
else else
# Slight hack: strip off 'lib' to get prefix directory unset MPI_ARCH_PATH
libDir=$(mpicc --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/')
export MPI_ARCH_PATH="${libDir%/*}" # prefix from libdir
_foamAddLib "$libDir"
unset libDir
fi fi
# Use <orte-info> (openmpi only command) to query configuration
if [ -z "$MPI_ARCH_PATH" ] && _foamFoundCmd="$(command -v orte-info)"
then
# prefix
_foamFoundDir="$("$_foamFoundCmd" --path prefix --parsable | sed -e 's/^.*:prefix://')"
if [ -d "$_foamFoundDir" ]
then
MPI_ARCH_PATH="${_foamFoundDir}"
# libdir
_foamFoundDir="$("$_foamFoundCmd" --path libdir --parsable | sed -e 's/^.*:libdir://')"
if [ -d "$_foamFoundDir" ]
then
_foamAddLib "$_foamFoundDir"
elif [ "$MPI_ARCH_PATH" != /usr ]
then
_foamAddLibAuto "$MPI_ARCH_PATH"
fi
fi
fi
# Use <mpicc> to get the link information and (slight hack)
# strip off 'lib' to get the prefix directory
if [ -z "$MPI_ARCH_PATH" ] && _foamFoundCmd="$(command -v mpicc)"
then
_foamFoundDir="$("$_foamFoundCmd" --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/')"
MPI_ARCH_PATH="${_foamFoundDir%/*}" # Prefix from libdir
_foamAddLib "$_foamFoundDir"
fi
# Last resort (worse hack):
# Use <orterun> to get ../path/bin/orterun and infer prefix, libdir
if [ -z "$MPI_ARCH_PATH" ] && _foamFoundCmd="$(command -v orterun)"
then
_foamFoundDir="${_foamFoundCmd%/*}" # The bin dir
MPI_ARCH_PATH="${_foamFoundDir%/*}" # The prefix dir
_foamAddLibAuto "$MPI_ARCH_PATH"
fi
if [ -z "$MPI_ARCH_PATH" ]
then
echo "Warn: could not determine prefix for system-openmpi" 1>&2
fi
unset _foamFoundCmd _foamFoundDir
#- #-
# TBD: extra (major) version qualifier on name? # TBD: extra (major) version qualifier on name?
#- #-
@ -113,7 +157,7 @@ OPENMPI)
export OPAL_PREFIX="$MPI_ARCH_PATH" export OPAL_PREFIX="$MPI_ARCH_PATH"
# Could be sourced from ThirdParty with incomplete environment # Could be sourced from ThirdParty with incomplete environment
if command -v _foamAddLibAuto >/dev/null # Normal sourcing if [ -n "$MPI_ARCH_PATH" ] && command -v _foamAddLibAuto >/dev/null
then then
_foamAddPath "$MPI_ARCH_PATH"/bin _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddMan "$MPI_ARCH_PATH"/share/man _foamAddMan "$MPI_ARCH_PATH"/share/man
@ -197,7 +241,7 @@ MPICH)
export MPI_HOME="$MPI_ARCH_PATH" export MPI_HOME="$MPI_ARCH_PATH"
# Could be sourced from ThirdParty with incomplete environment # Could be sourced from ThirdParty with incomplete environment
if command -v _foamAddLibAuto >/dev/null # Normal sourcing if [ -n "$MPI_ARCH_PATH" ] && command -v _foamAddLibAuto >/dev/null
then then
_foamAddPath "$MPI_ARCH_PATH"/bin _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddMan "$MPI_ARCH_PATH"/share/man _foamAddMan "$MPI_ARCH_PATH"/share/man
@ -219,9 +263,12 @@ MPICH-GM)
export MPICH_PATH="$MPI_ARCH_PATH" export MPICH_PATH="$MPI_ARCH_PATH"
export GM_LIB_PATH="$MPICH_PATH/lib$WM_COMPILER_LIB_ARCH" export GM_LIB_PATH="$MPICH_PATH/lib$WM_COMPILER_LIB_ARCH"
_foamAddPath "$MPI_ARCH_PATH"/bin if [ -n "$MPI_ARCH_PATH" ]
_foamAddLib "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH" then
_foamAddLib "$GM_LIB_PATH" _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
_foamAddLib "$GM_LIB_PATH"
fi
;; ;;
@ -237,7 +284,7 @@ MVA2MPI)
fi fi
# Could be sourced from ThirdParty with incomplete environment # Could be sourced from ThirdParty with incomplete environment
if command -v _foamAddLibAuto >/dev/null # Normal sourcing if [ -n "$MPI_ARCH_PATH" ] && command -v _foamAddLibAuto >/dev/null
then then
_foamAddPath "$MPI_ARCH_PATH"/bin _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddMan "$MPI_ARCH_PATH"/share/man _foamAddMan "$MPI_ARCH_PATH"/share/man
@ -256,8 +303,11 @@ CRAY-MPICH)
echo "Please set MPICH_DIR correctly" 1>&2 echo "Please set MPICH_DIR correctly" 1>&2
} }
# _foamAddPath "$MPI_ARCH_PATH"/bin if [ -n "$MPI_ARCH_PATH" ]
_foamAddLib "$MPI_ARCH_PATH"/lib then
# _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH"/lib
fi
;; ;;
@ -266,21 +316,21 @@ HPMPI)
export MPI_HOME=/opt/hpmpi export MPI_HOME=/opt/hpmpi
export MPI_ARCH_PATH="$MPI_HOME" export MPI_ARCH_PATH="$MPI_HOME"
unset libDir
case "$(uname -m)" in case "$(uname -m)" in
x86_64) libDir=lib/linux_amd64 ;; x86_64) _foamFoundDir=lib/linux_amd64 ;;
i686) libDir=lib/linux_ia32 ;; i686) _foamFoundDir=lib/linux_ia32 ;;
ia64) libDir=lib/linux_ia64 ;; ia64) _foamFoundDir=lib/linux_ia64 ;;
*) unset _foamFoundDir ;;
esac esac
if [ -n "$libDir" ] if [ -n "$_foamFoundDir" ]
then then
_foamAddPath "$MPI_ARCH_PATH"/bin _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH/$libDir" _foamAddLib "$MPI_ARCH_PATH/$_foamFoundDir"
else else
echo "openfoam: ($(uname -m)) - unsupported HP-MPI processor type" 1>&2 echo "openfoam: ($(uname -m)) - unsupported HP-MPI processor type" 1>&2
fi fi
unset libDir unset _foamFoundDir
;; ;;
@ -361,8 +411,23 @@ INTELMPI*)
then then
# MPI_ARCH_PATH: Set I_MPI_ROOT accordingly # MPI_ARCH_PATH: Set I_MPI_ROOT accordingly
export I_MPI_ROOT="$MPI_ARCH_PATH" export I_MPI_ROOT="$MPI_ARCH_PATH"
fi
else
# Final effort - check ThirdParty opt/intel locations for 'latest'
for _foamFoundDir in \
"$WM_THIRD_PARTY_DIR/opt/intel/oneapi/mpi/latest" \
"$WM_THIRD_PARTY_DIR/opt/intel/mpi/latest" \
;
do
if [ -d "$_foamFoundDir" ]
then
MPI_ARCH_PATH="$_foamFoundDir"
export I_MPI_ROOT="$MPI_ARCH_PATH"
break
fi
done
fi
unset _foamFoundDir
if [ -d "$MPI_ARCH_PATH" ] if [ -d "$MPI_ARCH_PATH" ]
then then
@ -391,7 +456,7 @@ INTELMPI*)
# With/without "intel64/" directory - handled here and in mpi rules # With/without "intel64/" directory - handled here and in mpi rules
# Path, lib-path may have been set prior to call # Path, lib-path may have been set prior to call
if true if [ -d "$MPI_ARCH_PATH" ]
then then
if [ -d "$MPI_ARCH_PATH"/intel64/bin ] \ if [ -d "$MPI_ARCH_PATH"/intel64/bin ] \
&& [ -d "$MPI_ARCH_PATH"/intel64/lib ] && [ -d "$MPI_ARCH_PATH"/intel64/lib ]
@ -416,13 +481,28 @@ MSMPI)
_foamEtc -config prefs.msmpi ## Optional adjustments _foamEtc -config prefs.msmpi ## Optional adjustments
# MPI_ARCH_PATH (prefs) if a valid dir, or ThirdParty location # MPI_ARCH_PATH (prefs) if a valid dir, or ThirdParty location
# Also consider ThirdParty 'opt/' directory (binary package)
if [ ! -d "$MPI_ARCH_PATH" ] if [ ! -d "$MPI_ARCH_PATH" ]
then then
export MPI_ARCH_PATH="$_foamMpiPrefixDir/$FOAM_MPI" for _foamFoundDir in \
"$_foamMpiPrefixDir/$FOAM_MPI" \
"$WM_THIRD_PARTY_DIR/opt/$FOAM_MPI" \
;
do
if [ -d "$_foamFoundDir" ]
then
MPI_ARCH_PATH="$_foamFoundDir"
break
fi
done
fi fi
unset _foamFoundDir
# _foamAddPath "$MPI_ARCH_PATH"/bin if [ -d "$MPI_ARCH_PATH" ]
_foamAddLib "$MPI_ARCH_PATH"/lib/x64 then
# _foamAddPath "$MPI_ARCH_PATH"/bin
_foamAddLib "$MPI_ARCH_PATH"/lib/x64
fi
;; ;;
esac esac

View File

@ -143,14 +143,14 @@ export FOAM_USER_LIBBIN="$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib"
# Prepend wmake to the path - not required for runtime-only environment # Prepend wmake to the path - not required for runtime-only environment
foundDir="$WM_PROJECT_DIR/wmake" _foamFoundDir="$WM_PROJECT_DIR/wmake"
if [ -d "$WM_DIR" ] if [ -d "$WM_DIR" ]
then then
foundDir="${WM_DIR}" _foamFoundDir="${WM_DIR}"
fi fi
if [ -d "$foundDir" ] if [ -d "$_foamFoundDir" ]
then then
PATH="$foundDir:$PATH" PATH="$_foamFoundDir:$PATH"
else else
unset WM_DIR unset WM_DIR
fi fi
@ -308,7 +308,7 @@ esac
# Cleanup # Cleanup
# ~~~~~~~ # ~~~~~~~
unset archDir siteDir foundDir archOption unset archOption archDir siteDir _foamFoundDir
unset gcc_version gccDir unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir unset clang_version clangDir

View File

@ -30,7 +30,7 @@
export FOAM_API=$("$WM_PROJECT_DIR/bin/foamEtcFile" -show-api) export FOAM_API=$("$WM_PROJECT_DIR/bin/foamEtcFile" -show-api)
# The installation parent directory # The installation parent directory
prefixDir="${WM_PROJECT_DIR%/*}" _foamPrefixDir="${WM_PROJECT_DIR%/*}"
# Load shell functions # Load shell functions
unset WM_SHELL_FUNCTIONS unset WM_SHELL_FUNCTIONS
@ -54,20 +54,20 @@ then
WM_THIRD_PARTY_DIR="$WM_PROJECT_DIR/ThirdParty" WM_THIRD_PARTY_DIR="$WM_PROJECT_DIR/ThirdParty"
else else
_foamEcho "Locating ThirdParty directory" _foamEcho "Locating ThirdParty directory"
for foundDir in \ for _foamFoundDir in \
"$prefixDir/ThirdParty-$WM_PROJECT_VERSION" \ "$_foamPrefixDir/ThirdParty-$WM_PROJECT_VERSION" \
"$prefixDir/ThirdParty-v$FOAM_API" \ "$_foamPrefixDir/ThirdParty-v$FOAM_API" \
"$prefixDir/ThirdParty-$FOAM_API" \ "$_foamPrefixDir/ThirdParty-$FOAM_API" \
"$prefixDir/ThirdParty-common" \ "$_foamPrefixDir/ThirdParty-common" \
; ;
do do
_foamEcho "... $foundDir" _foamEcho "... $_foamFoundDir"
if [ -d "$foundDir" ] if [ -d "$_foamFoundDir" ]
then then
if [ -f "$foundDir/Allwmake" ] || \ if [ -f "$_foamFoundDir/Allwmake" ] || \
[ -d "$foundDir/platforms" ] [ -d "$_foamFoundDir/platforms" ]
then then
WM_THIRD_PARTY_DIR="$foundDir" WM_THIRD_PARTY_DIR="$_foamFoundDir"
break break
else else
_foamEcho " does not have Allwmake or platforms/" _foamEcho " does not have Allwmake or platforms/"
@ -259,6 +259,6 @@ fi
. "$WM_PROJECT_DIR/etc/config.sh/functions" . "$WM_PROJECT_DIR/etc/config.sh/functions"
# Variables (done as the last statement for a clean exit code) # Variables (done as the last statement for a clean exit code)
unset cleaned foamOldDirs foundDir prefixDir unset cleaned foamOldDirs _foamFoundDir _foamPrefixDir
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -8,8 +8,7 @@
# Copyright (C) 2016-2019 OpenCFD Ltd. # Copyright (C) 2016-2019 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, licensed under GNU General Public License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
# <http://www.gnu.org/licenses/>.
# #
# File # File
# etc/config.sh/vtk # etc/config.sh/vtk