#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# .
#
# Script
# makeSCOTCH
#
# Description
# Build the SCOTCH and PTSCOTCH libraries
#
# ----------------------------------------------
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Run from third-party directory only
cd "${0%/*}" || exit
wmakeCheckPwd "$WM_THIRD_PARTY_DIR" 2>/dev/null || {
echo "Error (${0##*/}) : not located in \$WM_THIRD_PARTY_DIR"
echo " Check your OpenFOAM environment and installation"
exit 1
}
[ -n "$FOAM_EXT_LIBBIN" ] || {
echo "Error (${0##*/}) : \$FOAM_EXT_LIBBIN not set"
echo " Check your OpenFOAM environment and installation"
exit 1
}
. etc/tools/ThirdPartyFunctions
#------------------------------------------------------------------------------
_foamConfig scotch # Get SCOTCH_ARCH_PATH, SCOTCH_VERSION
scotchPACKAGE=${SCOTCH_VERSION:-scotch-system}
unset withMPI
case "$WM_MPLIB" in (*MPI*) [ "$FOAM_MPI" = dummy ] || withMPI=true ;; esac
#------------------------------------------------------------------------------
usage()
{
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
/bin/cat</dev/null
mkdir -p $incDIR 2>/dev/null
mkdir -p $libDIR 2>/dev/null
if [ -f "$makefileInc" ]
then
rm -f Makefile.inc
ln -s $makefileInc Makefile.inc
fi
[ -f Makefile.inc ] || {
echo " Error: scotch needs an appropriate Makefile.inc"
exit 1
}
export CCS="$(whichCC)" # CCS (serial compiler)
export CCP="$(whichMpicc)" # CCP (parallel compiler) default=mpicc
# Consistency for Intel-MPI and non-icc compilers
[ -n "$I_MPI_CC" ] || export I_MPI_CC="$(whichCC)"
make realclean 2>/dev/null # Extra safety
make -j $WM_NCOMPPROCS libscotch \
&& make \
prefix=$prefixDIR \
includedir=$incDIR \
libdir=$libDIR \
install
rmdir "$SCOTCH_ARCH_PATH/bin" 2> /dev/null || true # Superfluous bin?
make realclean 2>/dev/null || true # Failed cleanup is uncritical
) || warnBuildIssues SCOTCH
else
warnNotFound SCOTCH
fi
# Build ptscotch when MPI (ThirdParty or system) is available
[ "${withMPI}" = true ] || {
# Report that the above tests failed and pass-through the failure
echo "Skipping pt-scotch (no mpi)"
exit 0
}
echo
echo ========================================
echo "pt-scotch decomposition ($scotchPACKAGE with $FOAM_MPI)"
# Build ptscotch if normal scotch was built (has include and library)
[ -f "$SCOTCH_ARCH_PATH/include/scotch.h" ] && \
[ -r "$FOAM_EXT_LIBBIN/libscotch$EXT_SO" ] || \
{
# Report that the above tests failed and pass-through the failure
echo
echo " skipping - no found"
exit 2
}
if [ -f "$SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h" ] && \
[ -r "$FOAM_EXT_LIBBIN/$FOAM_MPI/libptscotch$EXT_SO" ]
then
echo " ptscotch include: $SCOTCH_ARCH_PATH/include/$FOAM_MPI"
echo " ptscotch library: $FOAM_EXT_LIBBIN/$FOAM_MPI"
else
(
# Older versions ok, but scotch-6.0.5a cannot build in parallel.
# Force serial build
export WM_NCOMPPROCS=1
echo "*** building pt-scotch in serial ***"
[ -f "$scotchMakefile" ] || {
echo " Error: no such makefile: $scotchMakefile"
exit 1
}
cd "$SCOTCH_SOURCE_DIR/src" || exit
export GIT_DIR="$SCOTCH_SOURCE_DIR/.git" # Mask seeing our own git-repo
echo
prefixDIR=$SCOTCH_ARCH_PATH
incDIR=$SCOTCH_ARCH_PATH/include/$FOAM_MPI
libDIR=$FOAM_EXT_LIBBIN/$FOAM_MPI
mkdir -p $prefixDIR 2>/dev/null
mkdir -p $incDIR 2>/dev/null
mkdir -p $libDIR 2>/dev/null
if [ -f "$makefileInc" ]
then
rm -f Makefile.inc
ln -s $makefileInc Makefile.inc
fi
[ -f Makefile.inc ] || {
echo " Error: ptscotch needs an appropriate Makefile.inc"
exit 1
}
export CCS="$(whichCC)" # CCS (serial compiler)
export CCP="$(whichMpicc)" # CCP (parallel compiler) default=mpicc
# Consistency for Intel-MPI and non-icc compilers
[ -n "$I_MPI_CC" ] || export I_MPI_CC="$(whichCC)"
make realclean 2>/dev/null # Extra safety
make -j $WM_NCOMPPROCS libptscotch \
&& make \
prefix=$prefixDIR \
includedir=$incDIR \
libdir=$libDIR \
install
rmdir "$SCOTCH_ARCH_PATH/bin" 2> /dev/null || true # Superfluous bin?
make realclean 2>/dev/null || true # Failed cleanup is uncritical
) || warnBuildIssues PTSCOTCH
fi
# Verify existence of ptscotch include
[ -f "$SCOTCH_ARCH_PATH/include/$FOAM_MPI/ptscotch.h" ] || {
echo
echo " WARNING: required include file 'ptscotch.h' not found!"
}
# Could now remove $SCOTCH_SOURCE_DIR/src/Makefile.inc
#------------------------------------------------------------------------------