-
Notifications
You must be signed in to change notification settings - Fork 0
/
runall.sh
executable file
·191 lines (167 loc) · 5.61 KB
/
runall.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
186
187
188
189
190
191
#!/bin/bash
###########################
# 1) parse arguments
###########################
issaga=False
if [[ "`uname --nodename|cut -d "." -f2,3`" == "saga.sigma2" ]]; then
issaga=True
fi
maxproc=""
flowdir=""
cases=""
maxthreads=""
count=0
args=(${@})
argsleft=$#
if [ $# == 0 ]; then
echo "please specify the maximum number of precessors with --maxproc";
exit 1
else
while [[ $argsleft -gt 0 ]]; do
arg=${args[count]}
(( count++ ))
(( argsleft-- ))
case $arg in
--maxproc)
if [[ $argsleft -gt 0 ]]; then
if [ ${args[count]} == "--maxthreads" ] \
|| [ ${args[count]} == "--flowdir" ] \
|| [ ${args[count]} == "--data" ] \
; then
break;
else
maxproc=${args[count]}
(( count++ ))
(( argsleft-- ))
fi
fi
;;
--maxthreads)
if [[ $argsleft -gt 0 ]]; then
if [ ${args[count]} == "--maxproc" ] \
|| [ ${args[count]} == "--flowdir" ] \
|| [ ${args[count]} == "--data" ] \
; then
break;
else
maxthreads=${args[count]}
(( count++ ))
(( argsleft-- ))
fi
fi
;;
--flowdir)
if [[ $argsleft -gt 0 ]]; then
if [ ${args[count]} == "--maxproc" ] \
|| [ ${args[count]} == "--maxthreads" ] \
|| [ ${args[count]} == "--data" ] \
; then
break;
else
flowdir=${args[count]}
(( count++ ))
(( argsleft-- ))
fi
fi
;;
--data)
while [[ $argsleft -gt 0 ]]; do
if [ ${args[count]} == "--maxproc" ] \
|| [ ${args[count]} == "--maxthreads" ] \
|| [ ${args[count]} == "--flowdir" ] \
; then
break;
else
cases+=" "${args[count]}
(( count++ ))
(( argsleft-- ))
fi
done
;;
*)
echo "unknown option:" $arg;
;;
esac
shift # past argument or value
done
fi
if [[ $maxproc == "" ]]; then
echo "please specify the maximum number of precessors with --maxproc";
exit 1
fi
if [[ $maxthreads == "" ]]; then
echo "please specify the maximum number of threads with --maxthreads";
exit 1
fi
if [[ $flowdir == "" ]]; then
echo "please specify the flow directory with --flowdir"
exit 1
fi
if [[ $cases == "" ]]; then
echo "please specify the cases you want to run with --data, e.g., --data dir1/spe9/SPE9.DATA dir2/norne/NORNE_ATW2013.DATA"
exit 1
fi
re='^[0-9]+$'
if ! [[ $maxproc =~ $re ]] ; then
echo "maxproc is not a number" >&2
exit 1
fi
if ! [[ $maxthreads =~ $re ]] ; then
echo "maxthreads is not a number" >&2
exit 1
fi
if [[ ! -d $flowdir ]]; then
echo "flowdir is not a directory" >&2
exit 1
fi
if [[ ! -d sims ]]; then
mkdir sims
fi
cd sims/
for data in $cases
do
casename="$(basename -s .DATA $data)"
casefullfoldername="$(dirname $data)"
casefoldername="$(basename $(dirname $data))"
for numproc in $(seq $maxproc)
do
for numthreads in $(seq $maxthreads)
do
name=$casename"_processors"$numproc"_threads"$numthreads
fname=$name".sh"
if [[ ! $issaga == "True" ]]; then
mpirun -np $numproc $flowdir/flow $data --threads-per-process=$numthreads --output-dir=$casename"_processors"$numproc"_threads"$numthreads
else
if [[ ! -d $name ]]; then
mkdir -p $name
fi
(
cd $name
echo "#!/bin/bash" > $fname
echo "#SBATCH --account=NN9766K" >> $fname
echo "#SBATCH --job-name="$name >> $fname
echo "#SBATCH --time=0-01:00:00" >> $fname
echo "#SBATCH --mem-per-cpu=3G" >> $fname
echo "#SBATCH --ntasks="$numproc" --cpus-per-task="$numthreads >> $fname
echo "set -o errexit # Make bash exit on any error" >> $fname
echo "set -o nounset # Treat unset variables as errors" >> $fname
echo "module --quiet purge" >> $fname
echo "module load Boost/1.71.0-GCC-8.3.0" >> $fname
echo "module load OpenMPI/3.1.4-GCC-8.3.0" >> $fname
echo "module load OpenBLAS/0.3.7-GCC-8.3.0" >> $fname
echo "module list" >> $fname
###echo "workdir=\$USERWORK/$name" >> $fname
###echo "mkdir -p \$workdir" >> $fname
###echo "cp -r "$casefullfoldername" \$workdir" >> $fname
###echo "cd \$workdir" >> $fname
echo "cp -r "$casefullfoldername" \$SCRATCH" >> $fname
echo "cd \$SCRATCH" >> $fname
echo "savefile output/*DBG " >> $fname
echo "time mpirun "$flowdir"flow $casefoldername/$casename.DATA --threads-per-process=$numthreads --output-dir=output" >> $fname
echo "exit 0" >> $fname
sbatch $fname
)
fi
done
done
done