mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
CONFIG: additional packaging helpers, tutorial test helper
- bin/tools/create-mpi-config to query/write values for system openmpi. In some cases this can be used to avoid an mpicc requirement at runtime. - adjust openfoam session to include -test-tutorial forwarding to the tutorials/AutoTest. This helps with writing installation tests. - adjust foamConfigurePaths to latest version - removal of gperftools default config, as per develop
This commit is contained in:
272
bin/tools/create-mpi-config
Executable file
272
bin/tools/create-mpi-config
Executable file
@ -0,0 +1,272 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2020 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Script
|
||||
# bin/tools/create-mpi-config
|
||||
#
|
||||
# Description
|
||||
# Define hard-coded packaging settings for MPI flavours,
|
||||
# primarily for system openmpi.
|
||||
# This eliminates a runtime dependency on mpicc, for example.
|
||||
#
|
||||
# Instead of querying/parsing 'mpicc --showme:link' each time,
|
||||
# it is done once during packaging.
|
||||
#
|
||||
# Environment
|
||||
# FOAM_MPI, MPI_ARCH_PATH, DEB_TARGET_MULTIARCH
|
||||
#
|
||||
# Possible Dependencies
|
||||
# - dpkg-architecture
|
||||
# - mpicc
|
||||
#
|
||||
# Notes
|
||||
# Run from top-level directory when creating config files
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
printHelp() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
|
||||
usage: ${0##*/} options
|
||||
|
||||
options:
|
||||
-dry-run Report but do not write config files
|
||||
-no-mpicc Bypass any use of mpicc
|
||||
-query-openmpi Report installation directory for system openmpi
|
||||
-write-openmpi Query system openmpi and write config files
|
||||
-write Write config files using FOAM_MPI, MPI_ARCH_PATH
|
||||
|
||||
Define hard-coded packaging settings for MPI flavours.
|
||||
|
||||
Equivalent options:
|
||||
-write-system-openmpi | -write-openmpi
|
||||
-query-system-openmpi | -query-openmpi
|
||||
|
||||
USAGE
|
||||
exit 0 # A clean exit
|
||||
}
|
||||
|
||||
|
||||
# Report error and exit
|
||||
die()
|
||||
{
|
||||
exec 1>&2
|
||||
echo
|
||||
echo "Error encountered:"
|
||||
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||
echo
|
||||
echo "See '${0##*/} -help' for usage"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Options
|
||||
unset optDryRun
|
||||
useMpicc=true
|
||||
|
||||
# Get installation directory for system openmpi
|
||||
# - from "mpicc --showme:link"
|
||||
# - manual fallback
|
||||
#
|
||||
# The mpicc content looks like this:
|
||||
# ----
|
||||
# -pthread -L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi
|
||||
# ----
|
||||
|
||||
query_system_openmpi()
|
||||
{
|
||||
unset arch_path
|
||||
|
||||
if [ "$useMpicc" = true ]
|
||||
then
|
||||
arch_path=$(mpicc --showme:link 2>/dev/null | sed -e 's#^.*-L\([^ ]*\).*#\1#')
|
||||
arch_path="${arch_path%/*}"
|
||||
|
||||
if [ -n "$arch_path" ]
|
||||
then
|
||||
echo "$arch_path"
|
||||
return 0 # Clean exit
|
||||
fi
|
||||
|
||||
echo "No mpicc found. Attempt manually" 1>&2
|
||||
fi
|
||||
|
||||
|
||||
# Manual discovery
|
||||
if [ -z "$DEB_TARGET_MULTIARCH" ]
|
||||
then
|
||||
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
|
||||
fi
|
||||
|
||||
# Include is under /usr/lib... (eg, debian, openSUSE)
|
||||
for testdir in \
|
||||
/usr/lib/"${DEB_TARGET_MULTIARCH:+${DEB_TARGET_MULTIARCH}/}"openmpi/include \
|
||||
/usr/lib64/mpi/gcc/openmpi/include \
|
||||
;
|
||||
do
|
||||
if [ -e "$testdir/mpi.h" ]
|
||||
then
|
||||
echo "${testdir%/*}"
|
||||
return 0 # Clean exit
|
||||
fi
|
||||
done
|
||||
|
||||
# Include is under /usr/include (eg, RedHat)
|
||||
for testdir in \
|
||||
/usr/include/openmpi-"$(uname -m)" \
|
||||
/usr/include/openmpi \
|
||||
;
|
||||
do
|
||||
if [ -e "$testdir/mpi.h" ]
|
||||
then
|
||||
echo "/usr"
|
||||
return 0 # Clean exit
|
||||
fi
|
||||
done
|
||||
|
||||
# Failed (should not happen)
|
||||
# - report '/usr', but with error code 2
|
||||
echo "/usr"
|
||||
return 2
|
||||
}
|
||||
|
||||
|
||||
# Generate etc/config.{csh,sh}/MPI-TYPE files
|
||||
# based on the values for FOAM_MPI and MPI_ARCH_PATH
|
||||
|
||||
create_files()
|
||||
{
|
||||
[ -n "$FOAM_MPI" ] || die "FOAM_MPI not set"
|
||||
|
||||
if [ -d "$MPI_ARCH_PATH" ]
|
||||
then
|
||||
echo "Define $FOAM_MPI with $MPI_ARCH_PATH" 1>&2
|
||||
|
||||
case "$FOAM_MPI" in
|
||||
(openmpi-system)
|
||||
configDir="etc/config.sh"
|
||||
if [ "$optDryRun" = true ]
|
||||
then
|
||||
cat << CONTENT 1>&2
|
||||
dry-run: $configDir/$FOAM_MPI
|
||||
#
|
||||
# Packaging configured value for $FOAM_MPI
|
||||
export MPI_ARCH_PATH="$MPI_ARCH_PATH"
|
||||
|
||||
CONTENT
|
||||
elif [ -d "$configDir" ]
|
||||
then
|
||||
echo "Write $configDir/$FOAM_MPI" 1>&2
|
||||
cat << CONTENT > "$configDir/$FOAM_MPI"
|
||||
# $configDir/$FOAM_MPI
|
||||
#
|
||||
# Packaging configured value for $FOAM_MPI
|
||||
|
||||
export MPI_ARCH_PATH="$MPI_ARCH_PATH"
|
||||
#----
|
||||
CONTENT
|
||||
else
|
||||
echo "Cannot write $configDir/$FOAM_MPI - no directory" 1>&2
|
||||
fi
|
||||
|
||||
configDir="etc/config.csh"
|
||||
if [ "$optDryRun" = true ]
|
||||
then
|
||||
cat << CONTENT 1>&2
|
||||
dry-run: $configDir/$FOAM_MPI
|
||||
#
|
||||
# Packaging configured value for $FOAM_MPI
|
||||
setenv MPI_ARCH_PATH "$MPI_ARCH_PATH"
|
||||
|
||||
CONTENT
|
||||
elif [ -d "$configDir" ]
|
||||
then
|
||||
echo "Write $configDir/$FOAM_MPI" 1>&2
|
||||
cat << CONTENT > "$configDir/$FOAM_MPI"
|
||||
# $configDir/$FOAM_MPI
|
||||
#
|
||||
# Packaging configured value for $FOAM_MPI
|
||||
|
||||
setenv MPI_ARCH_PATH "$MPI_ARCH_PATH"
|
||||
#----
|
||||
CONTENT
|
||||
else
|
||||
echo "Cannot write $configDir/$FOAM_MPI - no directory" 1>&2
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "Warning: $FOAM_MPI with bad MPI_ARCH_PATH: $MPI_ARCH_PATH" 1>&2
|
||||
# TBD - remove old/bad entries?
|
||||
#
|
||||
# for file in "etc/config.sh/$FOAM_MPI" "etc/config.csh/$FOAM_MPI"
|
||||
# do
|
||||
# [ -f "$file" ] && rm -f "$file"
|
||||
# done
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help* | --help*)
|
||||
printHelp
|
||||
;;
|
||||
'')
|
||||
# Discard empty arguments
|
||||
;;
|
||||
|
||||
-dry-run)
|
||||
optDryRun=true
|
||||
;;
|
||||
|
||||
-no-mpicc)
|
||||
unset useMpicc
|
||||
;;
|
||||
|
||||
-query-openmpi | -query-system-openmpi)
|
||||
query_system_openmpi
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-write-openmpi | -write-system-openmpi)
|
||||
if MPI_ARCH_PATH=$(query_system_openmpi)
|
||||
then
|
||||
FOAM_MPI="openmpi-system"
|
||||
create_files
|
||||
else
|
||||
die "Failed query for system openmpi"
|
||||
fi
|
||||
;;
|
||||
|
||||
-write)
|
||||
create_files
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Ignore unknown option/argument: '$1'" 1>&2
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
exit 0 # A clean exit, if we get this far
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -29,18 +29,49 @@
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
printHelp() {
|
||||
cat<<USAGE
|
||||
|
||||
case "$1" in
|
||||
(*compat*)
|
||||
cat<<HELP_COMPAT
|
||||
Obsolete options:
|
||||
-foamInstall DIR [obsolete]
|
||||
-projectName NAME [obsolete]
|
||||
-sigfpe|-no-sigfpe [obsolete - now under etc/controlDict]
|
||||
-archOption 32|64 [obsolete setting of 'WM_ARCH_OPTION' - edit manually]
|
||||
|
||||
Equivalent options:
|
||||
-version -foamVersion --projectVersion
|
||||
-archOption --archOption
|
||||
-third -ThirdParty
|
||||
-paraview --paraviewVersion | -paraviewVersion
|
||||
-paraview-path --paraviewInstall | -paraviewInstall
|
||||
-scotch --scotchVersion | -scotchVersion
|
||||
-scotch-path --scotchArchPath | -scotchArchPath
|
||||
-system-compiler -system
|
||||
-third-compiler -third
|
||||
|
||||
HELP_COMPAT
|
||||
exit 0 # A clean exit
|
||||
;;
|
||||
esac
|
||||
|
||||
cat<<HELP_HEAD
|
||||
|
||||
usage: $0 options
|
||||
|
||||
Options
|
||||
-h | -help Display short help and exit
|
||||
-help-compat Display compatibility options and exit
|
||||
-help-full Display full help and exit
|
||||
|
||||
Basic
|
||||
-etc=DIR set FOAM_CONFIG_ETC for alternative project files
|
||||
-project-path DIR specify 'WM_PROJECT_DIR' (eg, /opt/openfoam1806-patch1)
|
||||
-version VER specify project version (eg, v1806)
|
||||
-sp | -SP | -float32 single precision (WM_PRECISION_OPTION)
|
||||
-dp | -DP | -float64 double precision (WM_PRECISION_OPTION)
|
||||
-spdp | -SPDP mixed single/double precision
|
||||
-int32 | -int64 the 'WM_LABEL_SIZE'
|
||||
-spdp | -SPDP mixed precision (WM_PRECISION_OPTION)
|
||||
-int32 | -int64 label-size (WM_LABEL_SIZE)
|
||||
|
||||
Compiler
|
||||
-system-compiler NAME The 'system' compiler to use (eg, Gcc, Clang, Icc,...)
|
||||
@ -57,16 +88,21 @@ MPI
|
||||
-openmpi-system use system openmpi
|
||||
-openmpi-third use ThirdParty openmpi (using default version)
|
||||
|
||||
ThirdParty versions
|
||||
Components versions (ThirdParty)
|
||||
-adios VER specify 'adios2_version'
|
||||
-boost VER specify 'boost_version'
|
||||
-cgal ver specify 'cgal_version'
|
||||
-cgal VER specify 'cgal_version'
|
||||
-cmake VER specify 'cmake_version'
|
||||
-fftw VER specify 'fffw_version'
|
||||
-kahip VER specify 'KAHIP_VERSION'
|
||||
-metis ver specify 'METIS_VERSION'
|
||||
-metis VER specify 'METIS_VERSION'
|
||||
-scotch VER specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)
|
||||
|
||||
HELP_HEAD
|
||||
|
||||
case "$1" in
|
||||
(*full*)
|
||||
cat<<HELP_FULL
|
||||
Components specified by absolute path
|
||||
-adios-path DIR Path for 'ADIOS2_ARCH_PATH' (overrides -adios)
|
||||
-boost-path DIR Path for 'BOOST_ARCH_PATH' (overrides -boost)
|
||||
@ -80,32 +116,24 @@ Graphics
|
||||
-paraview VER specify 'ParaView_VERSION' (eg, 5.4.1 or system)
|
||||
-paraview-qt VER specify 'ParaView_QT' (eg, qt-system)
|
||||
-paraview-path DIR specify 'ParaView_DIR' (eg, /opt/ParaView-5.4.1)
|
||||
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
|
||||
-llvm VER specify 'mesa_llvm'
|
||||
-mesa VER specify 'mesa_version' (eg, mesa-13.0.1)
|
||||
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
|
||||
-llvm-path DIR Path for 'LLVM_ARCH_PATH' (overrides -llvm)
|
||||
-mesa-path DIR Path for 'MESA_ARCH_PATH' (overrides -mesa)
|
||||
-vtk-path DIR Path for 'VTK_DIR' (overrides -vtk)
|
||||
|
||||
Misc
|
||||
-foamInstall DIR [obsolete]
|
||||
-projectName NAME [obsolete]
|
||||
-sigfpe|-no-sigfpe [obsolete - now under etc/controlDict]
|
||||
-archOption 32|64 [obsolete setting of 'WM_ARCH_OPTION' - edit manually]
|
||||
HELP_FULL
|
||||
;;
|
||||
esac
|
||||
|
||||
cat<<HELP_TAIL_COMMON
|
||||
Adjusts hardcoded versions and installation paths (POSIX and C-shell)
|
||||
for OpenFOAM.
|
||||
|
||||
Adjusts hardcoded versions and installation paths (POSIX and C-shell).
|
||||
HELP_TAIL_COMMON
|
||||
|
||||
|
||||
Equivalent options:
|
||||
-version -foamVersion --projectVersion
|
||||
-archOption --archOption
|
||||
-third -ThirdParty
|
||||
-paraview --paraviewVersion | -paraviewVersion
|
||||
-paraview-path --paraviewInstall | -paraviewInstall
|
||||
-scotch --scotchVersion | -scotchVersion
|
||||
-scotch-path --scotchArchPath | -scotchArchPath
|
||||
-system-compiler -system
|
||||
-third-compiler -third
|
||||
|
||||
USAGE
|
||||
exit 0 # clean exit
|
||||
exit 0 # A clean exit
|
||||
}
|
||||
|
||||
|
||||
@ -123,11 +151,12 @@ die()
|
||||
}
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
projectDir="$(\pwd -L)" # Project dir
|
||||
|
||||
# Check that it appears to be an OpenFOAM installation
|
||||
if [ -f etc/bashrc ] && [ -d "META-INFO" ]
|
||||
then
|
||||
echo "Configuring OpenFOAM" 1>&2
|
||||
echo "Configuring OpenFOAM ($projectDir)" 1>&2
|
||||
else
|
||||
die "Please run from the OpenFOAM top-level installation directory" \
|
||||
"No etc/bashrc or META-INFO/ found"
|
||||
@ -172,18 +201,22 @@ _inlineSed()
|
||||
local replacement="$3"
|
||||
local msg="$4"
|
||||
local cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
|
||||
local localFile
|
||||
|
||||
[ -f "$file" ] || {
|
||||
echo "Missing file: $file"
|
||||
exit 2 # Fatal
|
||||
}
|
||||
|
||||
# Local filename (for reporting)
|
||||
localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
|
||||
|
||||
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
|
||||
echo "Failed: ${msg:-replacement} in $file"
|
||||
echo "Failed: ${msg:-replacement} in $localFile"
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -n "$msg" ] && echo " $msg ($file)"
|
||||
[ -n "$msg" ] && echo " $msg ($localFile)"
|
||||
|
||||
return 0
|
||||
}
|
||||
@ -209,7 +242,7 @@ replace()
|
||||
"$file" \
|
||||
"$key=.*" \
|
||||
"$key=$val" \
|
||||
"Replaced $key setting by '$val'"
|
||||
"Replaced $key by '$val'"
|
||||
done
|
||||
}
|
||||
|
||||
@ -232,9 +265,9 @@ replaceCsh()
|
||||
|
||||
_inlineSed \
|
||||
"$file" \
|
||||
"setenv *$key [^ #]*" \
|
||||
"setenv [ ]*$key [^ #]*" \
|
||||
"setenv $key $val" \
|
||||
"Replaced $key setenv by '$val'"
|
||||
"Replaced $key by '$val'"
|
||||
done
|
||||
}
|
||||
|
||||
@ -323,7 +356,13 @@ unset adjusted optMpi
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help* | --help*)
|
||||
-help-c*) # Compat help
|
||||
printHelp -compat
|
||||
;;
|
||||
-help-f*) # Full help
|
||||
printHelp -full
|
||||
;;
|
||||
-h | -help*) # Short help
|
||||
printHelp
|
||||
;;
|
||||
'')
|
||||
@ -516,12 +555,12 @@ CONFIG_CSH
|
||||
_inlineSed $(_foamEtc config.sh/mpi) \
|
||||
"FOAM_MPI=$expected" \
|
||||
"FOAM_MPI=$optMpi" \
|
||||
"Replaced 'FOAM_MPI=$expected' setting by 'FOAM_MPI=$optMpi'"
|
||||
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
|
||||
|
||||
_inlineSed $(_foamEtc config.csh/mpi) \
|
||||
"FOAM_MPI $expected" \
|
||||
"FOAM_MPI $optMpi" \
|
||||
"Replaced 'FOAM_MPI $expected' setting by 'FOAM_MPI $optMpi'"
|
||||
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
|
||||
|
||||
replaceEtc bashrc WM_MPLIB OPENMPI
|
||||
replaceEtcCsh cshrc WM_MPLIB OPENMPI
|
||||
@ -711,11 +750,11 @@ CONFIG_CSH
|
||||
shift
|
||||
;;
|
||||
|
||||
-vtk)
|
||||
# Replace vtk_version=...
|
||||
-llvm)
|
||||
# Replace mesa_llvm=...
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk vtk_version "$optionValue"
|
||||
replaceEtc config.csh/vtk vtk_version "$optionValue"
|
||||
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
|
||||
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
@ -729,6 +768,42 @@ CONFIG_CSH
|
||||
shift
|
||||
;;
|
||||
|
||||
-vtk)
|
||||
# Replace vtk_version=...
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk vtk_version "$optionValue"
|
||||
replaceEtc config.csh/vtk vtk_version "$optionValue"
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-llvm-path)
|
||||
# Replace LLVM_ARCH_PATH=...
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
|
||||
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-mesa-path)
|
||||
# Replace MESA_ARCH_PATH...
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
|
||||
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
-vtk-path)
|
||||
# Replace VTK_DIR...
|
||||
optionValue=$(getOptionValue "$@")
|
||||
replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
|
||||
replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
|
||||
adjusted=true
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
## Misc ##
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
exec "@PROJECT_DIR@"/etc/openfoam "$@"
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
@ -11,16 +12,8 @@
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
#
|
||||
# Script
|
||||
# openfoam [options] [args]
|
||||
#
|
||||
# Description
|
||||
# Forwarding to the OpenFOAM etc/openfoam bash session script.
|
||||
# Forwarding to OpenFOAM etc/openfoam bash session script.
|
||||
# Uses a hard-code directory path (eg, generated with autoconfig).
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# Hard-coded directory path (eg, autoconfig)
|
||||
projectDir="@PROJECT_DIR@"
|
||||
|
||||
exec "$projectDir"/etc/openfoam "$@"
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user