CONFIG: adjust paraview libs, intelmpi handling

- fix overly aggressive match in the API value

- allow `INTELMPI*` generic value, this can be used to specify something
  like INTELMPI_custom and populate the corresponding wmake rule
  manually

STYLE: mention FOAM_BUILDROOT in wmake -help-full output

STYLE: adjust openfoam shell session welcome information

- adjust internal variable names to reduce collision potential

- improve handling of openfoam -etc=...
This commit is contained in:
Mark Olesen
2021-12-07 10:51:09 +01:00
parent 810d0c72ee
commit b25e1486de
9 changed files with 115 additions and 60 deletions

View File

@ -39,16 +39,18 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
if [ -d "$projectDir" ] _com_openfoam_projectDir="$projectDir"
if [ -d "$_com_openfoam_projectDir" ]
then then
_foamSourceBashEnv="$projectDir/etc/bashrc" _com_openfoam_bashrcFile="${_com_openfoam_projectDir}/etc/bashrc"
else else
unset _foamSourceBashEnv unset _com_openfoam_bashrcFile
fi fi
# Source the user bashrc first. # Source the user bashrc first. Improbable they use the following variables:
# Simply hope that they don't unset/reset _foamSourceBashEnv !! # * _com_openfoam_bashrcFile
# * _com_openfoam_projectDir
if [ -f "$HOME/.bashrc" ] if [ -f "$HOME/.bashrc" ]
then then
@ -58,20 +60,46 @@ fi
# Source the OpenFOAM etc/bashrc # Source the OpenFOAM etc/bashrc
if [ -f "$_foamSourceBashEnv" ] if [ -f "$_com_openfoam_bashrcFile" ]
then then
. "$_foamSourceBashEnv" $FOAM_SETTINGS . "$_com_openfoam_bashrcFile" $FOAM_SETTINGS
# Avoid further inheritance # Avoid further inheritance
unset FOAM_SETTINGS unset FOAM_SETTINGS
else
echo "Missing OpenFOAM etc/bashrc in '${_com_openfoam_projectDir}'" 1>&2
fi
unset _com_openfoam_bashrcFile _com_openfoam_projectDir
# Some feedback
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ] # Welcome banner - format somewhat like Ubuntu welcome
#----
## Welcome to Ubuntu VER (GNU/Linux ... x86_64)
##
## * Documentation: ...
#----
if [ -n "$PS1" ] ## Interactive
then
if [ -d "$WM_PROJECT_DIR" ]
then then
_foam_api="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-api 2>/dev/null)" _foam_api="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-api 2>/dev/null)"
_foam_patch="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)" _foam_patch="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
_foam_build="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-build 2>/dev/null)" _foam_build="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-build 2>/dev/null)"
unset _foam_arch1
case "$WM_OPTIONS" in # Or WM_LABEL_SIZE?
(*Int32*) _foam_arch1="label=32" ;;
(*Int64*) _foam_arch1="label=64" ;;
esac
unset _foam_arch2
case "$WM_OPTIONS" in # Or WM_PRECISION_OPTION?
(*SPDPInt*) _foam_arch2="scalar=32;solveScalar=64" ;;
(*SPInt*) _foam_arch2="scalar=32" ;;
(*DPInt*) _foam_arch2="scalar=64" ;;
esac
if [ "${_foam_patch:-0}" = 0 ] if [ "${_foam_patch:-0}" = 0 ]
then then
unset _foam_patch unset _foam_patch
@ -86,15 +114,17 @@ then
_foam_verinfo="${_foam_api}${_foam_patch:+ patch=${_foam_patch}}" _foam_verinfo="${_foam_api}${_foam_patch:+ patch=${_foam_patch}}"
fi fi
echo "Using: OpenFOAM-$WM_PROJECT_VERSION (${_foam_verinfo}) - visit www.openfoam.com" 1>&2 echo "openfoam = $WM_PROJECT_DIR" 1>&2
echo 1>&2
echo " * Using: OpenFOAM-$WM_PROJECT_VERSION (${_foam_verinfo}) - visit www.openfoam.com" 1>&2
if [ -n "$_foam_build" ] if [ -n "$_foam_build" ]
then then
echo "Build: ${_foam_build}" 1>&2 echo " * Build: ${_foam_build}" 1>&2
fi fi
echo "Arch: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
# Arch: LSB;label=32;scalar=64 # Arch: LSB;label=32;scalar=64
echo " * Arch: $_foam_arch1;$_foam_arch2" 1>&2
## echo 1>&2 echo " * Platform: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
echo 1>&2
# Set prompt as reminder that this is a shell session # Set prompt as reminder that this is a shell session
@ -102,18 +132,18 @@ then
# PS1="openfoam${_foam_api}:"'$(foamPwd)\n\u\$ ' # PS1="openfoam${_foam_api}:"'$(foamPwd)\n\u\$ '
PS1="openfoam${_foam_api}:"'\w/\n\u\$ ' PS1="openfoam${_foam_api}:"'\w/\n\u\$ '
unset _foam_arch1 _foam_arch2
unset _foam_api _foam_patch _foam_build _foam_verinfo unset _foam_api _foam_patch _foam_build _foam_verinfo
else
# Adjust prompt if not found - reminder that it is a shell session
PS1="openfoam(not-found):"'\w/\n\u\$ '
fi fi
else
echo "Could not locate OpenFOAM etc/bashrc in '$projectDir'" 1>&2 echo "OpenFOAM shell session - use 'exit' to quit" 1>&2
echo 1>&2
fi fi
echo 1>&2
echo "openfoam = $WM_PROJECT_DIR" 1>&2
echo "OpenFOAM shell session - use exit to quit" 1>&2
echo 1>&2
# Cleanup variables (done as final statement for a clean exit code) # Cleanup variables (done as final statement for a clean exit code)
unset _foamSourceBashEnv projectDir unset projectDir
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -437,10 +437,10 @@ case SGIMPI:
# ---- # ----
# Also support any ending (eg, INTELMPI_custom) to allow custom wmake rules
case intelmpi: case intelmpi:
case intelmpi-[1-9]*: case intelmpi-[1-9]*:
case INTELMPI: case INTELMPI*: ## Also includes (INTELMPI | INTELMPI-[1-9]*)
case INTELMPI-[1-9]*:
setenv FOAM_MPI intelmpi setenv FOAM_MPI intelmpi
## Add version embedded in the naming ## Add version embedded in the naming

View File

@ -99,7 +99,7 @@ case "none":
breaksw breaksw
case "system": case "system":
# Obtain major.minor from `paraview --version` # Obtain (major.minor) from `paraview --version`
set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'` set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ("${pv_api}" == "") then if ("${pv_api}" == "") then
@ -183,7 +183,7 @@ default:
set pvLibDir="${libDir}/paraview-${pv_api}" set pvLibDir="${libDir}/paraview-${pv_api}"
if ( -d "${ParaView_DIR}/${pvLibDir}" ) then if ( -d "${ParaView_DIR}/${pvLibDir}" ) then
switch ("$pv_api") switch ("$pv_api")
case 5.[0-4]*: case 5.[0-4]:
set libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib) set libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
breaksw breaksw
endsw endsw
@ -203,8 +203,8 @@ default:
# Any extra library directories # Any extra library directories
if ( -n "$pv_libdirs" != "" ) then if ( "$pv_libdirs" != "" ) then
switch "WM_ARCH" in switch ("$WM_ARCH")
case darwin*: case darwin*:
setenv DYLD_LIBRARY_PATH "${pv_libdirs}:$DYLD_LIBRARY_PATH" setenv DYLD_LIBRARY_PATH "${pv_libdirs}:$DYLD_LIBRARY_PATH"
breaksw breaksw

View File

@ -442,8 +442,9 @@ SGIMPI)
# ---- # ----
# Also support any ending (eg, INTELMPI_custom) to allow custom wmake rules
intelmpi | intelmpi-[1-9]* |\ intelmpi | intelmpi-[1-9]* |\
INTELMPI | INTELMPI-[1-9]* ) INTELMPI*) # Also includes (INTELMPI | INTELMPI-[1-9]*)
export FOAM_MPI=intelmpi export FOAM_MPI=intelmpi
_foamMpiEmbedVersion intelmpi INTELMPI _foamMpiEmbedVersion intelmpi INTELMPI

View File

@ -118,7 +118,7 @@ case "$ParaView_VERSION" in
;; ;;
([0-9]*) ([0-9]*)
# Extract API from VERSION # Extract API (major.minor) from VERSION
pv_api=$(echo "$ParaView_VERSION" | \ pv_api=$(echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p') sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p')
;; ;;
@ -162,7 +162,7 @@ case "$ParaView_VERSION" in
if [ -d "$ParaView_DIR/$pvLibDir" ] if [ -d "$ParaView_DIR/$pvLibDir" ]
then then
case "$pv_api" in case "$pv_api" in
(5.[0-4]*) (5.[0-4])
libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib) libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
;; ;;
esac esac

View File

@ -264,7 +264,7 @@ GCC_NOT_FOUND
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then then
echo "Using ThirdParty compiler" echo "Using ThirdParty compiler"
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})" echo " ${gccDir##*/} (${gmpDir##*/} ${mpfrDir##*/} ${mpcDir##*/})"
fi fi
;; ;;

View File

@ -130,22 +130,19 @@ then
;; ;;
(*=) (*=)
# name= -> unset name # name= -> unset name
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \ _foamEcho "unset ${foamVar_eval%=}"
&& echo "unset ${foamVar_eval%=}" 1>&2
eval "unset ${foamVar_eval%=}" eval "unset ${foamVar_eval%=}"
;; ;;
(*=*) (*=*)
# name=value -> export name=value # name=value -> export name=value
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \ _foamEcho "export $foamVar_eval"
&& echo "export $foamVar_eval" 1>&2
eval "export $foamVar_eval" eval "export $foamVar_eval"
;; ;;
(*) (*)
# Filename: source it # Filename: source it
if [ -f "$foamVar_eval" ] if [ -f "$foamVar_eval" ]
then then
[ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ] \ _foamEcho "Use file: $foamVar_eval"
&& echo "Using: $foamVar_eval" 1>&2
. "$foamVar_eval" . "$foamVar_eval"
elif [ -n "$foamVar_eval" ] elif [ -n "$foamVar_eval" ]
then then
@ -229,7 +226,7 @@ then
_foamAddMan "$WM_PROJECT_DIR/doc" _foamAddMan "$WM_PROJECT_DIR/doc"
fi fi
# Interactive shell (use PS1, not tty) # Interactive shell
if [ -n "$PS1" ] if [ -n "$PS1" ]
then then
_foamEtc -config aliases _foamEtc -config aliases

View File

@ -107,7 +107,8 @@ getApiInfo()
# - No inheritance of FOAM_SETTINGS # - No inheritance of FOAM_SETTINGS
# - No default verbosity (only as command-line option) # - No default verbosity (only as command-line option)
unset FOAM_CONFIG_ETC FOAM_SETTINGS FOAM_VERBOSE unset FOAM_CONFIG_ETC FOAM_SETTINGS FOAM_VERBOSE
unset _foamEtcDir _foamSettings _foamScriptCommand _foamSourceBashEnv unset _foam_config_etc _foam_bashrcFile
unset _foamSettings _foamScriptCommand
unset optTestTut unset optTestTut
# Parse options # Parse options
@ -162,9 +163,14 @@ do
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}" _foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;; ;;
#TDB: -etc-*)
#TDB: # Define FOAM_CONFIG_ETC for finding files
#TDB: _foam_config_etc="${1#*-}"
#TDB: ;;
-etc=*) -etc=*)
# Define FOAM_CONFIG_ETC for finding files # Define FOAM_CONFIG_ETC for finding files
_foamEtcDir="${1#*=}" _foam_config_etc="${1#*=}"
;; ;;
-prefix=*) -prefix=*)
@ -172,7 +178,7 @@ do
;; ;;
-init=*) -init=*)
_foamSourceBashEnv="${1#*=}" _foam_bashrcFile="${1#*=}"
;; ;;
-verbose) -verbose)
@ -227,28 +233,48 @@ then
interactive=true interactive=true
fi fi
if [ -z "$_foamSourceBashEnv" ] if [ -z "$_foam_bashrcFile" ]
then then
if [ -n "$interactive" ] if [ -n "$interactive" ]
then then
# Interactive shell, chain off via a file # Interactive shell, chain off via a file
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc" _foam_bashrcFile="$projectDir/bin/tools/source-bashrc"
else else
# Default: OPENFOAM etc/bashrc # Default: OPENFOAM etc/bashrc
_foamSourceBashEnv="$projectDir/etc/bashrc" _foam_bashrcFile="$projectDir/etc/bashrc"
fi fi
fi fi
[ -f "$_foamSourceBashEnv" ] || { [ -f "$_foam_bashrcFile" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2 echo "Error: file not found: $_foam_bashrcFile" 1>&2
exit 2 exit 2
} }
if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
# FOAM_CONFIG_ETC: additional etc directory
case "$_foam_config_etc" in
('') # Empty - ignore
;;
(/*) # Absolute
[ -d "$_foam_config_etc" ] || unset _foam_config_etc
;;
(*) # Relative
if [ -d "$_foam_config_etc" ]
then
# Qualify local dir
_foam_config_etc="$PWD/$_foam_config_etc"
else
[ -d "$projectDir/$_foam_config_etc" ] || unset _foam_config_etc
fi
;;
esac
if [ -n "$_foam_config_etc" ]
then then
# Additional etc directory export FOAM_CONFIG_ETC="$_foam_config_etc"
export FOAM_CONFIG_ETC="$_foamEtcDir"
fi fi
if [ -n "$interactive" ] if [ -n "$interactive" ]
@ -266,10 +292,10 @@ then
export FOAM_SETTINGS="$_foamSettings" export FOAM_SETTINGS="$_foamSettings"
fi fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2 ## echo "Source with $_foam_bashrcFile with '$FOAM_SETTINGS'" 1>&2
# Newer bash can use --init-file instead of --rcfile # Newer bash can use --init-file instead of --rcfile
exec bash --rcfile "$_foamSourceBashEnv" -i exec bash --rcfile "$_foam_bashrcFile" -i
exit $? # Safety exit $? # Safety
fi fi
@ -281,7 +307,7 @@ fi
# Suppresses aliases as a side-effect, but non-interactive anyhow. # Suppresses aliases as a side-effect, but non-interactive anyhow.
sourceBashrc() sourceBashrc()
{ {
. "$_foamSourceBashEnv" $_foamSettings . "$_foam_bashrcFile" $_foamSettings
} }

View File

@ -128,15 +128,16 @@ cat<<HELP_TAIL_FULL
Makefile targets: platforms/linux64GccDPInt32Opt/.../fvMesh.o (for example) Makefile targets: platforms/linux64GccDPInt32Opt/.../fvMesh.o (for example)
Special targets: Special targets:
all | queue Same as -all | -queue options all | queue Same as -all | -queue options
exe Compile statically linked executable exe Create executable
lib Compile statically linked archive lib (.a) lib Create statically linked archive lib (.a)
libo Compile statically linked lib (.o) libo Create statically linked lib (.o)
libso Compile dynamically linked lib (.so) libso Create dynamically linked lib (.so)
dep Create lnInclude and dependencies only dep Create lnInclude and dependencies only
updatedep Create dependencies only (in case of broken dependencies) updatedep Create dependencies only (in case of broken dependencies)
objects Compile but not link objects Compile but not link
Environment Environment
FOAM_BUILDROOT
FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS FOAM_EXTRA_CFLAGS FOAM_EXTRA_CXXFLAGS FOAM_EXTRA_LDFLAGS
FOAM_MODULE_PREFIX FOAM_MODULE_PREFIX
@ -146,8 +147,8 @@ cat<<HELP_TAIL_BRIEF
Some special targets (see -help-full for details): Some special targets (see -help-full for details):
all | queue Same as -all | -queue options all | queue Same as -all | -queue options
exe Executables exe Executable
lib libo libso Libraries lib libo libso Libraries (.a .o .so)
HELP_TAIL_BRIEF HELP_TAIL_BRIEF
fi fi