Skip to content

Commit e3e36cc

Browse files
committed
new install script for SUNDIALS which now requires CMake
1 parent f3e0657 commit e3e36cc

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

bin/install-sundials.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# This script installs any SUNDIALS version starting with version 2.6.0
5+
# when SUNDIALS moved to a CMake-based installation. Will install locally.
6+
# It may need environment variables to work, like `export CC=gcc` in ARCHER.
7+
8+
SUNDIALS=sundials-2.6.2
9+
10+
# Make sure CMake is installed, since SUNDIALS requires it.
11+
which cmake > /dev/null
12+
if [ $? -eq 0 ]
13+
then
14+
echo "Found CMake."
15+
else
16+
echo "CMake required to build SUNDIALS. Installing."
17+
sudo apt-get install cmake
18+
fi
19+
20+
HERE_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
21+
FIDIMAG_DIR="$(dirname "$HERE_DIR")"
22+
LIBS_DIR=${FIDIMAG_DIR}/local
23+
24+
echo "Will install SUNDIALS to "${LIBS_DIR}" using CC="${CC}"."
25+
mkdir ${LIBS_DIR}
26+
cd ${LIBS_DIR}
27+
28+
download_and_cmake_install() {
29+
# $1 name of the package
30+
# $2 URL where ${1}.tar.gz can be obtained
31+
# $3 configure options
32+
if [ ! -e ${1}.tar.gz ]; then
33+
echo "Downloading "${1}"."
34+
wget -q ${2}/${1}.tar.gz
35+
fi;
36+
37+
if [ ! -e ${1} ]; then
38+
tar -xzf ${1}.tar.gz
39+
40+
echo "Configuring "${1}"."
41+
mkdir ${1}_build
42+
cd ${1}_build
43+
cmake ${3} ../${1}
44+
45+
echo "Compiling and installing "${1}"."
46+
{
47+
make
48+
make install
49+
} > /dev/null
50+
51+
echo "Cleaning up."
52+
cd ..
53+
rm -rf ${1}
54+
rm -rf ${1}_build
55+
56+
cd ${HERE_DIR}
57+
echo "Done."
58+
fi;
59+
}
60+
61+
download_and_cmake_install \
62+
${SUNDIALS} \
63+
http://computation.llnl.gov/projects/sundials-suite-nonlinear-differential-algebraic-equation-solvers/download \
64+
"-DBUILD_STATIC_LIBS=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX="${LIBS_DIR}" -DEXAMPLES_ENABLE=OFF -DLAPACK_ENABLE=ON -DOPENMP_ENABLE=ON"

0 commit comments

Comments
 (0)