mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -8,8 +8,7 @@
|
||||
# Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# etc/config.csh/FFTW
|
||||
|
||||
@ -9,8 +9,7 @@
|
||||
# Copyright (C) 2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# etc/config.csh/complete-wrapper
|
||||
@ -38,14 +37,14 @@ then
|
||||
fi
|
||||
|
||||
# Preload completion cache
|
||||
if [ -f $WM_PROJECT_DIR/etc/config.sh/completion_cache ]
|
||||
then . $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
|
||||
fi
|
||||
|
||||
# Use the bash completion function, but retain cache etc.
|
||||
_of_complete_tcsh=true
|
||||
if [ -f $WM_PROJECT_DIR/etc/config.sh/bash_completion ]
|
||||
then . $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
|
||||
else
|
||||
# Could warn about missing file, or treat silently
|
||||
echo
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# config.csh/example/prefs.csh
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#
|
||||
# Environment
|
||||
# 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).
|
||||
# Eg, setenv MPI_BUFFER_SIZE 20000000
|
||||
@ -73,14 +73,57 @@ case SYSTEMOPENMPI:
|
||||
if ( -d "$MPI_ARCH_PATH" ) then
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH"
|
||||
else
|
||||
# Slight hack: strip off 'lib' to get prefix directory
|
||||
set libDir=`mpicc --showme:link | sed -e 's/.*-L\([^ ]*\).*/\1/'`
|
||||
|
||||
setenv MPI_ARCH_PATH "${libDir:h}" # prefix from libdir
|
||||
_foamAddLib "$libDir"
|
||||
unset libDir
|
||||
setenv MPI_ARCH_PATH
|
||||
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?
|
||||
#-
|
||||
@ -107,9 +150,11 @@ case OPENMPI:
|
||||
# Inform openmpi where to find its install directory
|
||||
setenv OPAL_PREFIX "$MPI_ARCH_PATH"
|
||||
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddMan "$MPI_ARCH_PATH"/share/man
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
|
||||
if ( "$MPI_ARCH_PATH" != "" ) then
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddMan "$MPI_ARCH_PATH"/share/man
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
|
||||
endif
|
||||
breaksw
|
||||
|
||||
|
||||
@ -179,10 +224,11 @@ case MPICH:
|
||||
endif
|
||||
|
||||
setenv MPI_HOME "$MPI_ARCH_PATH"
|
||||
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddMan "$MPI_ARCH_PATH"/share/man
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
|
||||
if ( "$MPI_ARCH_PATH" != "" ) then
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddMan "$MPI_ARCH_PATH"/share/man
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
|
||||
endif
|
||||
breaksw
|
||||
|
||||
|
||||
@ -198,9 +244,11 @@ case MPICH-GM:
|
||||
setenv MPICH_PATH "$MPI_ARCH_PATH"
|
||||
setenv GM_LIB_PATH "$MPICH_PATH/lib$WM_COMPILER_LIB_ARCH"
|
||||
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddLib "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
|
||||
_foamAddLib "$GM_LIB_PATH"
|
||||
if ( "$MPI_ARCH_PATH" != "" ) then
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddLib "$MPI_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH"
|
||||
_foamAddLib "$GM_LIB_PATH"
|
||||
endif
|
||||
breaksw
|
||||
|
||||
|
||||
@ -214,9 +262,11 @@ case MVA2MPI:
|
||||
setenv MPI_ARCH_PATH "$_foamMpiPrefixDir/$FOAM_MPI"
|
||||
endif
|
||||
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddMan "$MPI_ARCH_PATH"/share/man
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
|
||||
if ( "$MPI_ARCH_PATH" != "" ) then
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddMan "$MPI_ARCH_PATH"/share/man
|
||||
_foamAddLibAuto "$MPI_ARCH_PATH" "lib$WM_COMPILER_LIB_ARCH"
|
||||
endif
|
||||
breaksw
|
||||
|
||||
|
||||
@ -231,8 +281,10 @@ case CRAY-MPICH:
|
||||
echo "Please set MPICH_DIR correctly"
|
||||
endif
|
||||
|
||||
# _foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddLib "$MPI_ARCH_PATH"/lib
|
||||
if ( "$MPI_ARCH_PATH" != "" ) then
|
||||
# _foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddLib "$MPI_ARCH_PATH"/lib
|
||||
endif
|
||||
breaksw
|
||||
|
||||
|
||||
@ -241,26 +293,26 @@ case HPMPI:
|
||||
setenv MPI_HOME /opt/hpmpi
|
||||
setenv MPI_ARCH_PATH "$MPI_HOME"
|
||||
|
||||
set libDir=""
|
||||
set _foamFoundDir=""
|
||||
switch (`uname -m`)
|
||||
case x86_64:
|
||||
set libDir=lib/linux_amd64
|
||||
set _foamFoundDir=lib/linux_amd64
|
||||
breaksw
|
||||
case i686:
|
||||
set libDir=lib/linux_ia32
|
||||
set _foamFoundDir=lib/linux_ia32
|
||||
breaksw
|
||||
case ia64:
|
||||
set libDir=lib/linux_ia64
|
||||
set _foamFoundDir=lib/linux_ia64
|
||||
breaksw
|
||||
endsw
|
||||
|
||||
if ( "${libDir}" != "" ) then
|
||||
if ( "${_foamFoundDir}" != "" ) then
|
||||
_foamAddPath "$MPI_ARCH_PATH"/bin
|
||||
_foamAddLib "$MPI_ARCH_PATH/$libDir"
|
||||
_foamAddLib "$MPI_ARCH_PATH/$_foamFoundDir"
|
||||
else
|
||||
echo "openfoam: (`uname -m`) - unsupported HP-MPI processor type"
|
||||
endif
|
||||
unset libDir
|
||||
unset _foamFoundDir
|
||||
breaksw
|
||||
|
||||
|
||||
@ -335,7 +387,20 @@ case INTELMPI*:
|
||||
else if ( "$MPI_ARCH_PATH" != "" ) then
|
||||
# MPI_ARCH_PATH: Set I_MPI_ROOT accordingly
|
||||
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
|
||||
unset _foamFoundDir
|
||||
|
||||
if ( -d "$MPI_ARCH_PATH" ) then
|
||||
# Remove trailing slash
|
||||
@ -364,7 +429,7 @@ case INTELMPI*:
|
||||
# With/without "intel64/" directory - handled here and in mpi rules
|
||||
|
||||
# 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
|
||||
_foamAddPath "$MPI_ARCH_PATH"/intel64/bin
|
||||
_foamAddLib "$MPI_ARCH_PATH"/intel64/lib
|
||||
@ -375,6 +440,34 @@ case INTELMPI*:
|
||||
_foamAddLib "$MPI_ARCH_PATH"/lib/release
|
||||
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
|
||||
|
||||
|
||||
|
||||
@ -96,7 +96,7 @@ case MSYS*:
|
||||
if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Mingw
|
||||
setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw
|
||||
echo "openfoam: windows support (mingw64) is runtime only"
|
||||
;;
|
||||
breaksw
|
||||
|
||||
case SunOS*:
|
||||
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"
|
||||
|
||||
# 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 ( -d "${WM_DIR}" ) set foundDir="${WM_DIR}"
|
||||
if ( -d "${WM_DIR}" ) set _foamFoundDir="${WM_DIR}"
|
||||
endif
|
||||
if ( -d "$foundDir" ) then
|
||||
setenv PATH "${foundDir}:${PATH}"
|
||||
if ( -d "$_foamFoundDir" ) then
|
||||
setenv PATH "${_foamFoundDir}:${PATH}"
|
||||
else
|
||||
unsetenv WM_DIR
|
||||
endif
|
||||
@ -317,7 +317,7 @@ endsw
|
||||
|
||||
# Cleanup
|
||||
# ~~~~~~~
|
||||
unset archDir siteDir foundDir archOption
|
||||
unset archOption archDir siteDir _foamFoundDir
|
||||
unset gcc_version gccDir
|
||||
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
|
||||
unset clang_version clangDir
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
setenv FOAM_API `$WM_PROJECT_DIR/bin/foamEtcFile -show-api`
|
||||
|
||||
# The installation parent directory
|
||||
set prefixDir="${WM_PROJECT_DIR:h}"
|
||||
set _foamPrefixDir="${WM_PROJECT_DIR:h}"
|
||||
|
||||
# Load shell "functions" (actually aliases)
|
||||
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"
|
||||
else
|
||||
_foamEcho "Locating ThirdParty directory"
|
||||
foreach foundDir (\
|
||||
"$prefixDir/ThirdParty-$WM_PROJECT_VERSION" \
|
||||
"$prefixDir/ThirdParty-v$FOAM_API" \
|
||||
"$prefixDir/ThirdParty-$FOAM_API" \
|
||||
"$prefixDir/ThirdParty-common" \
|
||||
foreach _foamFoundDir (\
|
||||
"$_foamPrefixDir/ThirdParty-$WM_PROJECT_VERSION" \
|
||||
"$_foamPrefixDir/ThirdParty-v$FOAM_API" \
|
||||
"$_foamPrefixDir/ThirdParty-$FOAM_API" \
|
||||
"$_foamPrefixDir/ThirdParty-common" \
|
||||
)
|
||||
_foamEcho "... $foundDir"
|
||||
if ( -d "$foundDir" ) then
|
||||
if ( -f "$foundDir/Allwmake" || -d "$foundDir/platforms" ) then
|
||||
setenv WM_THIRD_PARTY_DIR "$foundDir"
|
||||
_foamEcho "... $_foamFoundDir"
|
||||
if ( -d "$_foamFoundDir" ) then
|
||||
if ( -f "$_foamFoundDir/Allwmake" || -d "$_foamFoundDir/platforms" ) then
|
||||
setenv WM_THIRD_PARTY_DIR "$_foamFoundDir"
|
||||
break
|
||||
else
|
||||
_foamEcho " does not have Allwmake or platforms/"
|
||||
@ -239,6 +239,6 @@ unalias _foamAddLib
|
||||
unalias _foamAddLibAuto
|
||||
|
||||
# Variables (done as final statement for a clean exit code)
|
||||
unset cleaned foamOldDirs foundDir prefixDir
|
||||
unset cleaned foamOldDirs _foamFoundDir _foamPrefixDir
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
# Copyright (C) 2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# etc/config.csh/tcsh_completion
|
||||
|
||||
@ -8,8 +8,7 @@
|
||||
# Copyright (C) 2016-2019 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# File
|
||||
# etc/config.csh/vtk
|
||||
|
||||
Reference in New Issue
Block a user