-
Notifications
You must be signed in to change notification settings - Fork 21
/
install.sh
executable file
·185 lines (138 loc) · 4.25 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
echo ""
echo "***"
echo "*** Executing chimes_lsq install.sh"
echo "***"
echo ""
# Builds all relevant chimes_calculator executables/library files
# Run with:
# ./install.sh
# or
# ./install.sh <debug option (0 or 1)> <install prefix (full path)> <verbosity option (0 or 1 or 2 or 3)> <MPI option (0 or 1)>
DEBUG=${1-0} # False (0) by default; if false, compiles with -O3, otherwise, uses -g
PREFX=${2-""} # Empty by default
VERBO=${3-1} # Verbosity set to 1 by default, 0 gives minimal output, 3 gives minimal with DEBUG_CHEBY output, 4 gives all output
DOMPI=${4-1} # Compile with MPI support by default
echo "Attempting to perform a fresh install"
echo "Imports directory will be deleted and re-cloned/installed. Proceed? (y/n)"
read PROCEED
if [[ "$PROCEED" == "n" ]] ; then
echo 'Will use pre-existing imports directory'
else
echo "Are you sure? Imports directory will be deleted! (y/n)"
read PROCEED
if [[ "$PROCEED" == "y" ]] ; then
rm -rf imports
fi
fi
# Load module files based on user-specified host-typeand configure compilers
ICC=`which g++` # Default option in case impi unavailable
MPI=`which mpicxx`
if [ ! -v hosttype ] ; then
echo "No hosttype specified"
echo "Be sure to load modules/configure compilers by hand before running this script!"
elif [[ "$hosttype" == "LLNL-LC" ]] ; then
source modfiles/LLNL-LC.mod
ICC=`which icc`
MPI=`which mpicxx`
elif [[ "$hosttype" == "UM-ARC" ]] ; then
source modfiles/UM-ARC.mod
ICC=`which icc`
MPI=`which mpicxx`
elif [[ "$hosttype" == "JHU-ARCH" ]] ; then
source modfiles/JHU-ARCH.mod
ICC=`which icc`
MPI=`which mpicxx`
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"
module list
# Grab and install dependencies
if [[ ! -d imports ]] ; then
./clone-all.sh
fi
# Compile dlars if mpi compilers are available on a HPC platform
if [[ -v hosttype ]] ; then
cd contrib/dlars/src
if [[ "$hosttype" == "LLNL-LC" ]] ; then
make
elif [[ "$hosttype" == "UM-ARC" ]] ; then
make CXX=mpiicpc
fi
cd - 2>&1> /dev/null
fi
# Compile molanal
cd contrib/molanal/src
make molanal.new
cd ../../..
# Clean up previous installation,
./uninstall.sh $PREFX
# Move into build directory
mkdir build
cd build
# Generate cmake flags
my_flags="-DCMAKE_CXX_COMPILER=${ICC}"
if [ ! -z $PREFX ] ; then
my_flags="-DCMAKE_INSTALL_PREFIX=${PREFX}"
fi
if [ $DEBUG -eq 1 ] ;then
my_flags="${my_flags} -Wall -DCMAKE_BUILD_TYPE=Debug"
else
my_flags="${my_flags} -DCMAKE_BUILD_TYPE=Release"
fi
if [ $VERBO -eq 0 ] ;then
my_flags="${my_flags} -DVERBOSITY=0"
my_flags="${my_flags} -DDEBUG_CHEBY=0"
elif [ $VERBO -eq 1 ] ; then
my_flags="${my_flags} -DVERBOSITY=1"
my_flags="${my_flags} -DDEBUG_CHEBY=0"
elif [ $VERBO -eq 2 ] ; then
my_flags="${my_flags} -DVERBOSITY=0"
my_flags="${my_flags} -DDEBUG_CHEBY=1"
elif [ $VERBO -eq 3 ] ; then
my_flags="${my_flags} -DVERBOSITY=1"
my_flags="${my_flags} -DDEBUG_CHEBY=1"
fi
if [ $DOMPI -eq 1 ] ;then
my_flags="${my_flags} -DUSE_MPI=1"
my_flags="${my_flags} -DMPI_CXX_COMPILER=${MPI}"
else
my_flags="${my_flags} -DUSE_MPI=0"
fi
echo "compiling with flags: $my_flags"
# Setup, make and install
cmake $my_flags ..
make
cp ../src/chimes_lsq.py .
cp ../src/post_proc_chimes_lsq.py .
if [ $DOMPI -eq 1 ] ;then
# Create some executables for the ALD
cp chimes_md chimes_md-mpi
cp chimes_lsq chimes_lsq.tmp
my_flags=`echo $my_flags | awk '{for(i=1;i<=NF; i++){if($i~"DUSE_MPI=1"){$i="-DUSE_MPI=0"}}{print}}'`
cmake $my_flags ..
make
cp chimes_md chimes_md-serial
cp chimes_md-mpi chimes_md
mv chimes_lsq.tmp chimes_lsq
fi
if [ ! -z $PREFX ] ; then
make install
cp src/chimes_lsq.py $PREFX
cp src/post_proc_chimes_lsq.py $PREFX
fi
cd ..
echo ""
echo "***"
echo "*** chimes_lsq install complete"
echo "***"
echo ""