-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.sh
executable file
·63 lines (56 loc) · 1.33 KB
/
run.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
#!/bin/bash
# This script compiles and runs the simulation
# How to use it:
# run.sh -d <simulation-directory> -n <number-of-cores> -c <compilation-type>
BIN="simulate"
DIRPREFIX="simulation-"
AUX=`ls simulations | grep $DIRPREFIX | tail -1 | sed -e "s/^"$DIRPREFIX"0*//"`
AUX=$((AUX+1))
AUX=`printf "%06d\n" $AUX`
SIMDIR="simulations/"$DIRPREFIX$AUX
NTHREADS=
COMPTYPE=FAST_OMP # See Makefile:
# STD: Standar compilation
# FAST: With Ofast optimizations
# OPT: With O3 optimizations
# DBG: With debug options
# OMP: With OpenMP
# FAST_OMP: With Ofast optimizations and OpenMP
# O3_OMP: With O3 optimizations and OpenMP
while getopts "d:n:c:" o; do
case "${o}" in
d)
SIMDIR=$OPTARG
;;
n)
NTHREADS=$OPTARG
;;
c)
COMPTYPE=$OPTARG
;;
\?)
echo "Invalid option -$OPTARG" >&2
break
;;
esac
done
if [ -d $SIMDIR ]; then
echo "Error: directory already exists"
exit 1
elif [ $SIMDIR == "" ]; then
echo "Error: you must define a directory"
exit 1
fi
mkdir -p $SIMDIR
mkdir -p $SIMDIR/data
mkdir -p $SIMDIR/src
mkdir -p $SIMDIR/bin
cp src/*.cpp src/*.h src/Makefile $SIMDIR/src/
make COMP_TYPE=$COMPTYPE -C $SIMDIR/src
mv $SIMDIR/src/$BIN $SIMDIR/bin/$BIN-$AUX
if [ "$NTHREADS" != "" ]; then
export OMP_NUM_THREADS=$NTHREADS
fi
ulimit -s unlimited
cd $SIMDIR/data
time ../bin/$BIN-$AUX > out.dat &