forked from hystrath/hyStrath
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·258 lines (240 loc) · 5.79 KB
/
install.sh
File metadata and controls
executable file
·258 lines (240 loc) · 5.79 KB
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/bin/bash
nProcs=1
if [ $# -ne 0 ]
then
nProcs=$1
fi
tref_CFD=1050
tref_DSMC=1380
tref_PICDSMC=310
tref_MHD=160
speedup=1.0
if [[ $nProcs -eq 2 || $nProcs -eq 3 ]]
then
speedup=1.5
elif [ $nProcs -ge 4 ]; then
speedup=2.0
fi
display_bar() {
local w=20 p=$1; shift
local pct=$(( $p*$w/100 ))
printf -v arrows "%*s" "$pct" ""; arrows=${arrows// />};
printf "\r\e[K[%-*s] %3d%% %s" "$w" "$arrows" "$p" "$*";
}
progress_bar() {
local slp=$1;
for x in {1..99}
do
display_bar "$x" $2
sleep $slp
done
}
print_status() {
local logfile="$1"
local last_line=$( tail -n 2 $logfile )
if [[ "$last_line" == *"successfully"* ]]; then
echo -e "\nSUCCESS";
else
echo -e "\nFAIL: check $logfile";
fi
}
install_CFD() {
local sleep_period=`bc -l <<< $tref_CFD/$speedup/100`
progress_bar $sleep_period "installing CFD module" &
./build/install-CFD.sh $nProcs > logInstall-CFD 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "installed CFD module"
print_status logInstall-CFD
}
sync_CFD() {
local sleep_period=`bc -l <<< $tref_CFD/$speedup/100`
progress_bar $sleep_period "syncing CFD module" &
./build/resync-CFD.sh $nProcs > logSync-CFD 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "synced CFD module"
print_status logSync-CFD
}
install_DSMC() {
local sleep_period=`bc -l <<< $tref_DSMC/$speedup/100`
progress_bar $sleep_period "installing DSMC module" &
./build/install-DSMC.sh $nProcs > logInstall-DSMC 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "installed DSMC module"
print_status logInstall-DSMC
}
sync_DSMC() {
local sleep_period=`bc -l <<< $tref_DSMC/$speedup/100`
progress_bar $sleep_period "syncing DSMC module" &
./build/resync-DSMC.sh $nProcs > logSync-DSMC 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "synced DSMC module"
print_status logSync-DSMC
}
install_PICDSMC() {
local sleep_period=`bc -l <<< $tref_PICDSMC/$speedup/100`
progress_bar $sleep_period "installing hybrid PIC-DSMC module" &
./build/install-hybridPICDSMC.sh $nProcs > logInstall-hybridPICDSMC 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "installed hybrid PIC-DSMC module"
print_status logInstall-hybridPICDSMC
}
sync_PICDSMC() {
local sleep_period=`bc -l <<< $tref_PICDSMC/$speedup/100`
progress_bar $sleep_period "syncing hybrid PIC-DSMC module" &
./build/resync-hybridPICDSMC.sh $nProcs > logSync-hybridPICDSMC 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "synced hybrid PIC-DSMC module"
print_status logSync-hybridPICDSMC
}
install_MHD() {
local sleep_period=`bc -l <<< $tref_MHD/$speedup/100`
progress_bar $sleep_period "installing CFD-MHD module" &
./build/install-MHD.sh $nProcs > logInstall-MHD 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "installed CFD-MHD module"
print_status logInstall-MHD
}
sync_MHD() {
local sleep_period=`bc -l <<< $tref_MHD/$speedup/100`
progress_bar $sleep_period "syncing CFD-MHD module" &
./build/resync-MHD.sh $nProcs > logSync-MHD 2>&1 &
wait %2
if [ ! -z `jobs -p` ]
then
progress_bar_pid=$!
disown
pkill -P $$ > /dev/null 2>&1
fi
display_bar "100" "synced CFD-MHD module"
print_status logSync-MHD
}
echo "----- INSTALLATION -----"
echo "1 - CFD module"
echo "2 - DSMC module"
echo "3 - Hybrid PIC-DSMC module"
echo "4 - CFD-MHD module"
echo -e "5 - All modules\n"
echo "----- SYNCHRONISATION -----"
echo "11 - CFD module"
echo "12 - DSMC module"
echo "13 - Hybrid PIC-DSMC module"
echo "14 - CFD-MHD module"
echo -e "15 - All modules\n"
echo -e "Enter choice: \c"
read input
case $input in
1)
install_CFD
;;
2)
install_DSMC
;;
3)
echo -e "Confirm that the DSMC module is already installed [Y/n]: \c"
read input_conf
case $input_conf in
[yY][eE][sS]|[yY])
install_PICDSMC
;;
[nN][oO]|[nN])
echo "Please install the DSMC module first"
;;
*)
echo "Invalid input"
exit 1
;;
esac
;;
4)
echo -e "Confirm that the CFD module is already installed [Y/n]: \c"
read input_conf
case $input_conf in
[yY][eE][sS]|[yY])
install_MHD
;;
[nN][oO]|[nN])
echo "Please install the CFD module first"
;;
*)
echo "Invalid input"
exit 1
;;
esac
;;
5)
install_CFD
wait -n
install_DSMC
wait -n
install_PICDSMC
wait -n
install_MHD
;;
11)
sync_CFD
;;
12)
sync_DSMC
;;
13)
sync_PICDSMC
;;
14)
sync_MHD
;;
15)
sync_CFD
wait -n
sync_DSMC
wait -n
sync_PICDSMC
wait -n
sync_MHD
;;
*)
echo "Invalid input"
exit 1
;;
esac