Commit 01292a9a authored by Mark OLESEN's avatar Mark OLESEN
Browse files

BUG: failed check for scotch headers on ubuntu (closes #543)

- installed under /usr/include/scotch/scotch.h

ENH: obtain fallback value for SCOTCH_VERSION from the header

COMP: add support for metis, scotch static libraries (eg, EasyBuild)
parent b85457fc
......@@ -7,11 +7,30 @@ cd ${0%/*} || exit 1 # Run from this directory
: ${FOAM_EXT_LIBBIN:=/usr/lib$WM_COMPILER_LIB_ARCH} # Extra safety
export FOAM_EXT_LIBBIN
# Check for the existence of any of the files
# On success, echoes the file found and returns 0, otherwise returns 2
findFirstFile()
{
local file
for file
do
if [ -f "$file" -a -r "$file" ]
then
echo "$file"
return 0
fi
done
return 2
}
# Test for metis.
# - return 0 and export METIS_ARCH_PATH on success
hasMetis()
{
local warning="==> skip metis"
local header label settings
unset METIS_ARCH_PATH METIS_VERSION
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis) || {
......@@ -27,28 +46,30 @@ hasMetis()
fi
# Header
local header=$METIS_ARCH_PATH/include/metis.h
if [ "${METIS_ARCH_PATH##*-}" = system ]
then
[ -f "$header" ] || header=/usr/include/metis.h
fi
[ -f "$header" ] || {
header=$(findFirstFile \
$METIS_ARCH_PATH/include/metis.h \
/usr/include/metis.h \
) || {
echo "$warning (no header)"
return 2 # file not found
}
# Library
[ -r $FOAM_EXT_LIBBIN/libmetis.so ] || \
[ -r $METIS_ARCH_PATH/lib/libmetis.so ] || \
[ -r $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.so ] || \
[ "${METIS_ARCH_PATH##*-}" = system ] || {
[ "${METIS_ARCH_PATH##*-}" = system ] || \
findFirstFile \
$FOAM_EXT_LIBBIN/libmetis.so \
$METIS_ARCH_PATH/lib/libmetis.a \
$METIS_ARCH_PATH/lib/libmetis.so \
$METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.a \
$METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.so \
> /dev/null || {
echo "$warning (missing library)"
return 2
}
# Ensure consistent sizes between OpenFOAM and metis header
# Extract IDXTYPEWIDTH from metis.h: regex as per ThirdParty Allwmake
local label=$(sed -ne 's/^.*#define *IDXTYPEWIDTH *\([1-9][0-9]\).*/\1/p' $header)
label=$(sed -ne 's/^.*#define *IDXTYPEWIDTH *\([1-9][0-9]\).*/\1/p' $header)
: ${label:=unknown}
if [ "$WM_LABEL_SIZE" = "$label" ]
......@@ -67,6 +88,7 @@ hasMetis()
hasScotch()
{
local warning="==> skip scotch"
local header label settings
unset SCOTCH_ARCH_PATH SCOTCH_VERSION
settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) || {
......@@ -82,33 +104,54 @@ hasScotch()
fi
# Header
local header=$SCOTCH_ARCH_PATH/include/scotch.h
if [ "${SCOTCH_ARCH_PATH##*-}" = system ]
then
[ -f "$header" ] || header=/usr/include/scotch.h
fi
[ -f "$header" ] || {
header=$(findFirstFile \
$SCOTCH_ARCH_PATH/include/scotch.h \
/usr/include/scotch/scotch.h \
/usr/include/scotch.h
) || {
echo "$warning (no header)"
return 2 # file not found
}
# Library
[ -r $FOAM_EXT_LIBBIN/libscotch.so ] || \
[ -r $SCOTCH_ARCH_PATH/lib/libscotch.so ] || \
[ -r $SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.so ] || \
[ "${SCOTCH_ARCH_PATH##*-}" = system ] || {
[ "${SCOTCH_ARCH_PATH##*-}" = system ] || \
findFirstFile \
$FOAM_EXT_LIBBIN/libscotch.so \
$SCOTCH_ARCH_PATH/lib/libscotch.a \
$SCOTCH_ARCH_PATH/lib/libscotch.so \
$SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.a \
$SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.so \
> /dev/null || {
echo "$warning (missing library)"
return 2
}
# Ensure consistent sizes between OpenFOAM and scotch header
# extract 'typedef int64_t SCOTCH_Num' or equivalent
local label=$(sed -ne \
label=$(sed -ne \
's/^.*typedef *\([^ ]*\) *SCOTCH_Num.*/\1/ip' \
"$header")
: ${label:=unknown}
# No SCOTCH_VERSION set? Try to obtain from header
# extract #define SCOTCH_VERSION, SCOTCH_RELEASE, SCOTCH_PATCHLEVEL
[ -n "$SCOTCH_VERSION" ] || \
SCOTCH_VERSION=$(
eval $(
sed -ne \
's/^ *#define *SCOTCH_\(VERSION\|RELEASE\|PATCHLEVEL\) *\([0-9][0-9]*\).*$/\1=\2/p' \
"$header"
)
set -- $VERSION $RELEASE $PATCHLEVEL
IFS="."
[ "$#" -gt 0 ] && echo "scotch-$*"
)
# Failsafe value
: ${SCOTCH_VERSION:=scotch}
case "$WM_LABEL_SIZE:$label" in
(32:int32_t | 32:int | 64:int64_t | 64:long)
echo "Scotch (label=$label) - $SCOTCH_ARCH_PATH"
......@@ -168,4 +211,5 @@ fi
wmake $targetType decompositionMethods
wmake $targetType decompose
#------------------------------------------------------------------------------
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment