diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index b745c6a503293b54dae3fb0a5c4018d81565743c..ea5369a94cb2edece7ae44308cda1b20a0b75bb4 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -41,7 +41,8 @@ wmakeLnInclude -u decompositionMethods if have_scotch then wmake $targetType scotchDecomp - if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ] + + if have_ptscotch then wmakeMpiLib "$SCOTCH_VERSION" ptscotchDecomp fi diff --git a/src/parallel/decompose/ptscotchDecomp/Make/options b/src/parallel/decompose/ptscotchDecomp/Make/options index 8cd4aa7b582c41172be2877b6994b4ed885513ef..42e41f81462e205aec209775911409470676466a 100644 --- a/src/parallel/decompose/ptscotchDecomp/Make/options +++ b/src/parallel/decompose/ptscotchDecomp/Make/options @@ -1,13 +1,12 @@ /* - * NB: mplib PINC must appear after the SCOTCH_ARCH_PATH/include/FOAM_MPI - * to ensure we do not accidentally get a ptscotch header from the - * mpi distribution. + * NB: mplib PINC must appear after PTSCOTCH_INC_DIR to ensure we + * do not accidentally get a ptscotch header from the MPI distribution. */ sinclude $(GENERAL_RULES)/mplib$(WM_MPLIB) sinclude $(DEFAULT_RULES)/mplib$(WM_MPLIB) EXE_INC = \ - -I$(SCOTCH_ARCH_PATH)/include/$(FOAM_MPI) \ + -I$(PTSCOTCH_INC_DIR) \ -I$(SCOTCH_INC_DIR) \ $(PFLAGS) $(PINC) \ -I../decompositionMethods/lnInclude @@ -17,9 +16,8 @@ EXE_INC = \ * ptscotch 6 requires scotch linked in, but does not declare the dependency */ LIB_LIBS = \ + -L$(PTSCOTCH_LIB_DIR) \ -L$(SCOTCH_LIB_DIR) \ - -L$(FOAM_EXT_LIBBIN)/$(FOAM_MPI) \ - -L$(FOAM_EXT_LIBBIN) \ -lptscotch -lptscotcherrexit \ -lscotch diff --git a/wmake/scripts/have_scotch b/wmake/scripts/have_scotch index e25525926a28c362c602ba6287b53d9e61ebe175..8d17fa7f17f3752e95ea1f3bd4ca752637ffcada 100644 --- a/wmake/scripts/have_scotch +++ b/wmake/scripts/have_scotch @@ -37,6 +37,7 @@ no_scotch() { unset HAVE_SCOTCH SCOTCH_ARCH_PATH SCOTCH_INC_DIR SCOTCH_LIB_DIR unset SCOTCH_VERSION + unset HAVE_PTSCOTCH PTSCOTCH_ARCH_PATH PTSCOTCH_INC_DIR PTSCOTCH_LIB_DIR return 0 } @@ -48,6 +49,11 @@ echo_scotch() echo "root=$SCOTCH_ARCH_PATH" echo "include=$SCOTCH_INC_DIR" echo "library=$SCOTCH_LIB_DIR" + echo + echo "ptscotch=${HAVE_PTSCOTCH:-false}" + echo "root=$PTSCOTCH_ARCH_PATH" + echo "include=$PTSCOTCH_INC_DIR" + echo "library=$PTSCOTCH_LIB_DIR" } @@ -177,13 +183,105 @@ have_scotch() } +# Must be called after have_scotch! +# +# On success, return 0 and export variables +# -> HAVE_PTSCOTCH, PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR +have_ptscotch() +{ + local prefix header library static settings warn + warn="==> skip ptscotch" + + if [ "$HAVE_SCOTCH" != true ] + then + echo "$warn (no serial scotch available?)" + return 1 + fi + + # Reuse old settings + [ -n "$PTSCOTCH_ARCH_PATH" ] || PTSCOTCH_ARCH_PATH="$SCOTCH_ARCH_PATH" + + # Location + prefix="$PTSCOTCH_ARCH_PATH" + + # Header/library names + header="ptscotch.h" + library="libptscotch$extLibso" + static="libptscotch$extLiba" + + # ---------------------------------- + if isNone "$prefix" + then + [ -n "$warn" ] && echo "$warn (disabled)" + return 1 + elif hasAbsdir "$prefix" + then + header=$(findFirstFile \ + "$prefix/include/$FOAM_MPI/$header" \ + "$prefix/include/$header" + ) + + library=$(findFirstFile \ + "$(thirdExtLib $FOAM_MPI/$library)" \ + "$(thirdExtLib $library)" \ + "$prefix/lib/$static" \ + "$prefix/lib/$library" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$static" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ + ) + + elif isSystem "$prefix" + then + prefix=/usr + + header=$(findFirstFile \ + "/usr/local/include/ptscotch/$header" \ + "/usr/local/include/scotch/$header" \ + "/usr/local/include/$header" \ + "/usr/include/ptscotch/$header" \ + "/usr/include/scotch/$header" \ + "/usr/include/$header" \ + ) + + case "$header" in (/usr/local/*) prefix=/usr/local ;; esac + + library=$(findFirstFile \ + "$prefix/lib/$library" \ + "$prefix/lib$WM_COMPILER_LIB_ARCH/$library" \ + ) + else + unset prefix header library + fi + # ---------------------------------- + + # Header found? + [ -n "$header" ] || { + [ -n "$warn" ] && echo "$warn (no header)" + return 2 + } + + # Library found? + [ -n "$library" ] || { + [ -n "$warn" ] && echo "$warn (no library)" + return 2 + } + + # OK + echo "ptscotch - $prefix" + export HAVE_PTSCOTCH=true + export PTSCOTCH_ARCH_PATH="$prefix" + export PTSCOTCH_INC_DIR="${header%/*}" # Basename + export PTSCOTCH_LIB_DIR="${library%/*}" # Basename +} + + # Force reset of old variables no_scotch # Testing if [ "$1" = "-test" ] then - have_scotch + have_scotch && have_ptscotch echo_scotch fi diff --git a/wmake/scripts/sysFunctions b/wmake/scripts/sysFunctions index 30de032b90af4e91e182062270bd043d654436f5..a11f58c3c4eca62657a23683ce52853a9febc73a 100644 --- a/wmake/scripts/sysFunctions +++ b/wmake/scripts/sysFunctions @@ -48,14 +48,20 @@ then esac - # True if OS is Darwin. - # Uses libso extension to cache the value - # (instead of calling 'uname -s' each time) + # True if target OS is Darwin. + # Uses cached value from libso extension isDarwin() { test "$extLibso" = ".dylib" } + # True if target OS is Windows + # Uses cached value from libso extension + isWindows() + { + test "$extLibso" = ".dll" + } + # True if '$1' begins with '/' isAbsdir()