install.sh 1.58 KB
Newer Older
Matthieu Boileau's avatar
Matthieu Boileau committed
1
2
#!/bin/bash

Matthieu Boileau's avatar
Matthieu Boileau committed
3
4
source ../common.sh

Matthieu Boileau's avatar
Matthieu Boileau committed
5
LIB_NAME="fftw"
Matthieu Boileau's avatar
Matthieu Boileau committed
6
LIB_VERSION=3.3.7
Matthieu Boileau's avatar
Matthieu Boileau committed
7
8
GCC_VERSION=6.4.0
MPI_LIB=openmpi
9
MPI_VERSION=1.10.7
Matthieu Boileau's avatar
Matthieu Boileau committed
10
11
12
13
14
15
16

LIB_FULLNAME=${LIB_NAME}-${LIB_VERSION}
GCC_FULL=gcc-$GCC_VERSION
GCC_SHORT="gcc${GCC_VERSION//.}"
MPI_FULL=${MPI_LIB}-${MPI_VERSION}
MPI_SHORT="${MPI_LIB}${MPI_VERSION//.}"
SUB_DIR=${LIB_NAME}/${LIB_VERSION}/${GCC_FULL}/${MPI_FULL}
Matthieu Boileau's avatar
Matthieu Boileau committed
17
WORK_DIR=${BASE_WORK_DIR}/${SUB_DIR}
Matthieu Boileau's avatar
Matthieu Boileau committed
18
SRC_DIR=${WORK_DIR}/${LIB_FULLNAME}
Matthieu Boileau's avatar
Matthieu Boileau committed
19
ARCHIVE=${SRC_DIR}.tar.gz
Matthieu Boileau's avatar
Matthieu Boileau committed
20
URL="http://www.fftw.org/${LIB_FULLNAME}.tar.gz"
Matthieu Boileau's avatar
Matthieu Boileau committed
21
BUILD_DIR=${WORK_DIR}/${LIB_FULLNAME}-build
Matthieu Boileau's avatar
Matthieu Boileau committed
22
INSTALL_DIR=${BASE_INSTALL_DIR}/${SUB_DIR}
Matthieu Boileau's avatar
Matthieu Boileau committed
23
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Matthieu Boileau's avatar
Matthieu Boileau committed
24
MODULE_DIR=${BASE_MODULE_DIR}/libs/${LIB_NAME}
Matthieu Boileau's avatar
Matthieu Boileau committed
25
26
MODULE_PATH=${MODULE_DIR}/${LIB_VERSION}_${GCC_SHORT}_${MPI_SHORT}

27
install_lib()
28
{
Matthieu Boileau's avatar
Matthieu Boileau committed
29
30
31
32
module purge
module load gcc/${GCC_VERSION}
module load ${MPI_LIB}/${MPI_VERSION}_${GCC_SHORT}

33
gcc --version | head -n 1
Matthieu Boileau's avatar
Matthieu Boileau committed
34
sleep 2
35
mpirun --version | head -n 1
Matthieu Boileau's avatar
Matthieu Boileau committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
sleep 2

if [[ ! -f $ARCHIVE ]]; then
  mkdir -p $WORK_DIR
  wget $URL -O $ARCHIVE
fi

if [[ ! -d $SRC_DIR ]]; then
  tar zxf $ARCHIVE --directory $WORK_DIR
fi

if [[ ! -d $BUILD_DIR ]]; then
  mkdir $BUILD_DIR
  cd $BUILD_DIR
  ${SRC_DIR}/configure \
  --prefix=${INSTALL_DIR} \
  --enable-mpi \
  --enable-shared
fi

cd $BUILD_DIR
make -j || exit 1
make -j install || exit 1
59
}
Matthieu Boileau's avatar
Matthieu Boileau committed
60

61
install_module()
62
{
Matthieu Boileau's avatar
Matthieu Boileau committed
63
64
65
66
67
68
69
cd $SCRIPT_DIR
mkdir -p ${MODULE_DIR}

export LIB_NAME
export LIB_VERSION
export INSTALL_DIR
envtpl  --keep-template -o $MODULE_PATH module.tmpl
70
71
72
73
74
}

if [[ $1 == "module" ]]
then
  install_module
75
76
77
elif [[ $1 == "clean" ]]
then
  clean_all
78
79
80
81
else
  install_lib
  install_module
fi