forked from rk-lindsey/chimes_calculator
-
Notifications
You must be signed in to change notification settings - Fork 16
/
install.sh
executable file
·100 lines (80 loc) · 2.37 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# Builds all relevant chimes_calculator executables/library files
#
# If working on a machine with a corresponding .mod file in the modfiles folder
# (e.g., modfiles/LLNL-LC.mod), execute with, e.g.:
#
# export hosttype=LLNL-LC; ./install.sh
#
# Otherwise, load necessary modules manually and execute with
#
# ./install.sh
#
# Note that additional arguments can be specified, i.e.:
#
# ./install.sh <debug option (0 or 1)> <install prefix (full path)>
# Verbose is required for testing.
BUILD=`pwd`/build
DEBUG=${1-0} # False (0) by default.
PREFX=${2-$BUILD} # Empty by default
VERBOSE=${4-0}
# Clean up previous installation,
./uninstall.sh $PREFX
# Load modules based on user-specified host-type
if [ -z "$hosttype" ] ; then
echo ""
echo "WARNING: No hosttype specified"
echo "Be sure to load modules/configure compilers by hand before running this script!"
echo ""
elif [[ "$hosttype" == "LLNL-LC" ]] ; then
source modfiles/LLNL-LC.mod
ICC=`which icc`
IFORT=`which ifort`
my_flags="$my_flags -DCMAKE_CXX_COMPILER=${ICC} -DCMAKE_Fortran_COMPILER=${IFORT} -DCMAKE_C_COMPILER=${ICC}"
my_flags="$my_flags -DCMAKE_CXX_FLAGS_RELEASE=\"-O3 -fno-alias -fno-fnalias -xhost\""
elif [[ "$hosttype" == "UM-ARC" ]] ; then
source modfiles/UM-ARC.mod
elif [[ "$hosttype" == "JHU-ARCH" ]] ; then
source modfiles/JHU-ARCH.mod
ICC=`which icc`
MPI=`which mpicxx`
elif [[ "$hosttype" == "UT-TACC" ]] ; then
source modfiles/UT-TACC.mod
else
echo ""
echo "ERROR: Unknown hosttype ($hosttype) specified"
echo ""
echo "Valid options are:"
for i in `ls modfiles`; do echo " ${i%.mod}"; done
echo ""
echo "Please run again with: export hosttype=<host type>; ./install.sh"
echo "Or manually load modules and run with: ./install.sh"
exit 0
fi
echo "Detected hosttype: $hosttype"
if [ ! -z "$hasmod" ] ; then
module list
fi
# Move into build directory
mkdir build
cd build
if [[ $VERBOSE -eq 1 ]] ; then
my_flags="-DVERBOSE=1"
else
my_flags="-DVERBOSE=0"
fi
if [ ! -z $PREFX ] ; then
my_flags="-DCMAKE_INSTALL_PREFIX=${PREFX} $my_flags"
fi
if [ $DEBUG -eq 1 ] ;then
my_flags="${my_flags} -DDEBUG=1 -DCMAKE_BUILD_TYPE=Release"
else
my_flags="${my_flags} -DDEBUG=0 -DCMAKE_BUILD_TYPE=Release"
fi
# Setup, make and install
cmake $my_flags ..
make
if [ ! -z $PREFX ] ; then
make install
fi
cd ..