mirror of
https://develop.openfoam.com/Development/ThirdParty-common.git
synced 2025-12-08 06:57:50 +00:00
ENH: initial (rudimentary) makeHYPRE, makePETSC scripts
This commit is contained in:
172
makeHYPRE
Executable file
172
makeHYPRE
Executable file
@ -0,0 +1,172 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# makeHYPRE
|
||||
#
|
||||
# Description
|
||||
# Build script for HYPRE
|
||||
#
|
||||
# ----------------------------------------------
|
||||
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
|
||||
#------------------------------------------------------------------------------
|
||||
# Dynamic library endings (default is .so)
|
||||
[ "$(uname -s)" = Darwin ] && SO=dylib || SO=so
|
||||
|
||||
# Short-circuit test for an installation
|
||||
if [ "$1" = "-test" ]
|
||||
then
|
||||
[ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
|
||||
dir="$2" # <- HYPRE_ARCH_PATH
|
||||
if [ -d "$dir/include" ]
|
||||
then
|
||||
for lib in \
|
||||
$FOAM_EXT_LIBBIN/libhypre.$SO \
|
||||
$dir/lib/libhypre.a \
|
||||
$dir/lib/libhypre.$SO \
|
||||
$dir/lib$WM_COMPILER_LIB_ARCH/libhypre.a \
|
||||
$dir/lib$WM_COMPILER_LIB_ARCH/libhypre.$SO \
|
||||
;
|
||||
do
|
||||
if [ -r "$lib" ]
|
||||
then
|
||||
echo " hypre include: $dir/include"
|
||||
echo " hypre library: ${lib%/*}"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
exit 2
|
||||
fi
|
||||
#------------------------------------------------------------------------------
|
||||
# Run from third-party directory only
|
||||
cd ${0%/*} && 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 hypre
|
||||
|
||||
hyprePACKAGE=${hypre_version:-hypre-system}
|
||||
targetType=libso
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
|
||||
usage: ${0##*/} [OPTION] [lib|libso] [HYPRE-VERSION]
|
||||
options:
|
||||
-gcc Force gcc/g++ instead of using \$WM_CC, \$WM_CXX
|
||||
-help
|
||||
|
||||
* build HYPRE with
|
||||
${hyprePACKAGE:-'unspecified hypre version'}
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
exportCompiler # Compiler info for CMake/configure
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
'') ;; # Ignore empty
|
||||
-h | -help) usage ;;
|
||||
-gcc) useGcc ;;
|
||||
|
||||
lib|libso)
|
||||
targetType="$1"
|
||||
;;
|
||||
|
||||
hypre-[0-9]*)
|
||||
hyprePACKAGE="${1%%/}"
|
||||
unset HYPRE_ARCH_PATH # Avoid inconsistency
|
||||
;;
|
||||
*)
|
||||
die "unknown option/argument: '$1'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -n "$hyprePACKAGE" ] || die "The hypre-VERSION was not specified"
|
||||
|
||||
# Nothing to build
|
||||
if _foamIsNone $hyprePACKAGE
|
||||
then
|
||||
echo "Using hypre-none (skip ThirdParty build of HYPRE)"
|
||||
exit 0
|
||||
elif _foamIsSystem $hyprePACKAGE
|
||||
then
|
||||
echo "Using hypre-system"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Build HYPRE
|
||||
#
|
||||
# HYPRE_ARCH_PATH : installation directory
|
||||
# HYPRE_SOURCE_DIR : location of the original sources
|
||||
|
||||
HYPRE_SOURCE_DIR=$sourceBASE/$hyprePACKAGE
|
||||
: ${HYPRE_ARCH_PATH:=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$hyprePACKAGE}
|
||||
|
||||
[ -d "$HYPRE_SOURCE_DIR" ] || {
|
||||
echo "Missing sources: '$hyprePACKAGE'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
# Compilers
|
||||
CC="$(whichMpicc)"
|
||||
CXX="$(whichMpicxx)"
|
||||
|
||||
echo "Starting build: $hyprePACKAGE ($targetType)"
|
||||
echo
|
||||
(
|
||||
# Configuration options:
|
||||
unset configOpt
|
||||
|
||||
cd $HYPRE_SOURCE_DIR/src || exit 1
|
||||
export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
|
||||
|
||||
rm -rf $HYPRE_ARCH_PATH
|
||||
[ -e Makefile ] && make distclean 2>/dev/null
|
||||
|
||||
./configure \
|
||||
--prefix=$HYPRE_ARCH_PATH \
|
||||
--disable-fortran \
|
||||
--enable-shared \
|
||||
$configOpt \
|
||||
&& make -j $WM_NCOMPPROCS \
|
||||
&& echo "Built: hypre" \
|
||||
&& make install \
|
||||
&& echo "Installed: hypre"
|
||||
) || {
|
||||
echo "Error building: hypre"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
194
makePETSC
Executable file
194
makePETSC
Executable file
@ -0,0 +1,194 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# makePETSC
|
||||
#
|
||||
# Description
|
||||
# Build script for PETSC
|
||||
#
|
||||
# ----------------------------------------------
|
||||
# NO USER-CONFIGURABLE SETTINGS WITHIN THIS FILE
|
||||
#------------------------------------------------------------------------------
|
||||
# Dynamic library endings (default is .so)
|
||||
[ "$(uname -s)" = Darwin ] && SO=dylib || SO=so
|
||||
|
||||
# Short-circuit test for an installation
|
||||
if [ "$1" = "-test" ]
|
||||
then
|
||||
[ "$#" -eq 2 ] || { echo "${0##*/} -test : needs 1 argument"; exit 1; }
|
||||
dir="$2" # <- PETSC_ARCH_PATH
|
||||
if [ -d "$dir/include" ]
|
||||
then
|
||||
for lib in \
|
||||
$FOAM_EXT_LIBBIN/libpetsc.$SO \
|
||||
$dir/lib/libpetsc.a \
|
||||
$dir/lib/libpetsc.$SO \
|
||||
$dir/lib$WM_COMPILER_LIB_ARCH/libpetsc.a \
|
||||
$dir/lib$WM_COMPILER_LIB_ARCH/libpetsc.$SO \
|
||||
;
|
||||
do
|
||||
if [ -r "$lib" ]
|
||||
then
|
||||
echo " petsc include: $dir/include"
|
||||
echo " petsc library: ${lib%/*}"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
exit 2
|
||||
fi
|
||||
#------------------------------------------------------------------------------
|
||||
# Run from third-party directory only
|
||||
cd ${0%/*} && 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 petsc
|
||||
|
||||
petscPACKAGE=${petsc_version:-petsc-system}
|
||||
targetType=libso
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
usage() {
|
||||
exec 1>&2
|
||||
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
|
||||
cat<<USAGE
|
||||
|
||||
usage: ${0##*/} [OPTION] [lib|libso] [PETSC-VERSION]
|
||||
options:
|
||||
-gcc Force gcc/g++ instead of using \$WM_CC, \$WM_CXX
|
||||
-help
|
||||
|
||||
* build PETSC with
|
||||
${petscPACKAGE:-'unspecified petsc version'}
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
#------------------------------------------------------------------------------
|
||||
exportCompiler # Compiler info for CMake/configure
|
||||
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
'') ;; # Ignore empty
|
||||
-h | -help) usage ;;
|
||||
-gcc) useGcc ;;
|
||||
|
||||
lib|libso)
|
||||
targetType="$1"
|
||||
;;
|
||||
|
||||
petsc-[0-9]*)
|
||||
petscPACKAGE="${1%%/}"
|
||||
unset PETSC_ARCH_PATH # Avoid inconsistency
|
||||
;;
|
||||
*)
|
||||
die "unknown option/argument: '$1'"
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
[ -n "$petscPACKAGE" ] || die "The petsc-VERSION was not specified"
|
||||
|
||||
# Nothing to build
|
||||
if _foamIsNone $petscPACKAGE
|
||||
then
|
||||
echo "Using petsc-none (skip ThirdParty build of PETSC)"
|
||||
exit 0
|
||||
elif _foamIsSystem $petscPACKAGE
|
||||
then
|
||||
echo "Using petsc-system"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
#
|
||||
# Build PETSC
|
||||
#
|
||||
# PETSC_ARCH_PATH : installation directory
|
||||
# PETSC_SOURCE_DIR : location of the original sources
|
||||
|
||||
PETSC_SOURCE_DIR=$sourceBASE/$petscPACKAGE
|
||||
: ${PETSC_ARCH_PATH:=$installBASE$WM_PRECISION_OPTION$WM_LABEL_OPTION/$petscPACKAGE}
|
||||
|
||||
[ -d "$PETSC_SOURCE_DIR" ] || {
|
||||
echo "Missing sources: '$petscPACKAGE'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
echo "Starting build: $petscPACKAGE ($targetType)"
|
||||
echo
|
||||
(
|
||||
# PETSC arch
|
||||
archOpt="${WM_PRECISION_OPTION}Int$WM_LABEL_SIZE"
|
||||
|
||||
# Configuration options:
|
||||
configOpt="--with-cc=$(whichMpicc) --with-cxx=$(whichMpicxx)"
|
||||
|
||||
if [ "$targetType" = libso ]
|
||||
then
|
||||
configOpt="--with-shared-libraries"
|
||||
fi
|
||||
|
||||
if [ "$WM_LABEL_SIZE" = 64 ]
|
||||
then
|
||||
configOpt="$configOpt --with-64-bit-indices=1"
|
||||
else
|
||||
configOpt="$configOpt --with-64-bit-indices=0"
|
||||
fi
|
||||
|
||||
if [ "$WM_PRECISION_OPTION" = SP ]
|
||||
then
|
||||
configOpt="$configOpt --with-precision=single"
|
||||
else
|
||||
configOpt="$configOpt --with-precision=double"
|
||||
fi
|
||||
|
||||
cd $PETSC_SOURCE_DIR || exit 1
|
||||
export GIT_DIR=$PWD/.git # Mask seeing our own git-repo
|
||||
|
||||
rm -rf $PETSC_ARCH_PATH
|
||||
|
||||
./configure \
|
||||
--prefix=$PETSC_ARCH_PATH \
|
||||
--with-petsc-arch=$archOpt \
|
||||
--with-clanguage=C \
|
||||
--with-scalapack=0 \
|
||||
--with-superlu_dist=0 \
|
||||
--with-suitesparse=0 \
|
||||
--download-f2cblaslapack=1 \
|
||||
$configOpt \
|
||||
&& echo "Configured: petsc" \
|
||||
&& make PETSC_DIR=$PETSC_SOURCE_DIR PETSC_ARCH=$archOpt all \
|
||||
&& echo "Built: petsc" \
|
||||
&& make PETSC_DIR=$PETSC_SOURCE_DIR PETSC_ARCH=$archOpt install
|
||||
&& echo "Installed: petsc"
|
||||
) || {
|
||||
echo "Error building: petsc"
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user