#!/bin/sh cd ${0%/*} || exit 1 # Run from this directory # Parse arguments for library compilation . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # Test for metis. # - return 0 and export METIS_ARCH_PATH on success hasMetis() { echo echo "Metis decomposition" unset METIS_ARCH_PATH METIS_VERSION settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis) || { echo echo "Error: no config.sh/metis settings" echo return 1 } . $settings if [ -z "$METIS_ARCH_PATH" -o "${METIS_ARCH_PATH##*-}" = none ] then echo " skipping - no metis" echo return 1 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" ] || { echo " skipping - no metis header" echo return 2 # file not found } # Library [ -r $FOAM_EXT_LIBBIN/libmetis.so ] || \ [ -r $METIS_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libmetis.so ] || \ [ "${METIS_ARCH_PATH##*-}" = system ] || { echo " skipping - missing library" echo 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) [ "$WM_LABEL_SIZE" = "$label" ] || { echo " skipping - label=$WM_LABEL_SIZE, metis.h has '$label'" echo return 1 } echo "using METIS_ARCH_PATH=$METIS_ARCH_PATH" echo " label=$label" echo export METIS_ARCH_PATH return 0 # success } # Test for scotch. # - return 0 and export SCOTCH_ARCH_PATH, SCOTCH_VERSION on success hasScotch() { echo echo "Scotch decomposition" unset SCOTCH_ARCH_PATH SCOTCH_VERSION settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) || { echo echo "Error: no config.sh/scotch settings" echo return 1 } . $settings if [ -z "$SCOTCH_ARCH_PATH" -o "${SCOTCH_ARCH_PATH##*-}" = none ] then echo " skipping - no scotch" echo return 1 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" ] || { echo " skipping - no scotch header" echo return 2 # file not found } # Library [ -r $FOAM_EXT_LIBBIN/libscotch.so ] || \ [ -r $SCOTCH_ARCH_PATH/lib$WM_COMPILER_LIB_ARCH/libscotch.so ] || \ [ "${SCOTCH_ARCH_PATH##*-}" = system ] || { echo " skipping - missing library" echo return 2 } # Ensure consistent sizes between OpenFOAM and scotch header # extract 'typedef int64_t SCOTCH_Num' or equivalent local label=$(sed -ne \ 's/^.*typedef *\([^ ]*\) *SCOTCH_Num.*/\1/ip' \ "$header") : ${label:=unknown} [ "$WM_LABEL_SIZE" = 32 -a \( "$label" = int32_t -o "$label" = int \) ] || \ [ "$WM_LABEL_SIZE" = 64 -a \( "$label" = int64_t -o "$label" = long \) ] || { echo " skipping - label='$WM_LABEL_SIZE', scotch.h has '$label'" echo return 1 } echo "using SCOTCH_ARCH_PATH=$SCOTCH_ARCH_PATH" echo " label=$label ($WM_LABEL_SIZE)" echo export SCOTCH_ARCH_PATH SCOTCH_VERSION return 0 # success } # # Define how to create an mpi-versioned library of $targetType # compile into qualified directory # use sentinel file(s) to handle version changes # wmakeMpiLib() { local decompName="$1" shift for libName do ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" libDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName" whichmpi="$libDir/using:$FOAM_MPI" whichdecomp="$libDir/using:$decompName" [ -e "$whichmpi" -a -e "$whichdecomp" ] || wclean $libName echo "wmake $targetType $libName" wmake $targetType $libName mkdir -p "$libDir" touch "$whichdecomp" "$whichmpi" ) done } wmakeLnInclude decompositionMethods if hasScotch then wmake $targetType scotchDecomp if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ] then wmakeMpiLib "$SCOTCH_VERSION" ptscotchDecomp fi fi if hasMetis then wmake $targetType metisDecomp fi wmake $targetType decompositionMethods wmake $targetType decompose #------------------------------------------------------------------------------