-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·131 lines (113 loc) · 2.68 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
#!/bin/bash
function showhelp
{
echo 'Usage: ./install.sh [option] [option]...'
echo 'Compile and run mcgrid.'
echo
echo ' -h, --help Shows this dialog.'
echo ' -n, --cores Compiles and run code on n cores. Default is 1 core.'
echo ' -d, --debug Compiles and runs code with debug flags on n core.'
echo ' -m, --make Compiles the code with warnings enabled.'
echo ' -c, --complier Select complier. gnu or intel. Default is gnu.'
echo ' -p, --progName Set executable name. Default is mcgrid.'
}
function makebuild
{
if [ "$comp" = 'gnu' ];then
string="FCOMP=mpifort PROGRAM="
elif [ "$comp" = 'intel' ];then
string="FCOMP=mpiifort PROGRAM="
fi
string+="$pname"
if [ "$debug" = 1 ];then
make clean && make debug $string
elif [ "$NUM_CORES" = 0 ];then
make clean && make build $string
else
if [ "$comp" = 'gnu' ];then
make clean && make $string
elif [ "$comp" = 'intel' ];then
echo 'here'
make clean && make $string
fi
fi
}
function createdirs
{
if [ ! -d "data" ]; then
mkdir "data"
mkdir "data/jmean"
mkdir "data/im"
mkdir "data/deposit"
fi
if [ ! -d "build" ]; then
mkdir "build"
fi
cd build
ndirec="$(pwd)"
cd ..
if [ ! -d "bin" ]; then
mkdir "bin"
fi
cd bin
bdirc="$(pwd)"
cd ..
cd src
}
function run
{
for i in *; do
if [ "${i}" != "${i%.mod}" ];then
cp "${i}" "$ndirec"
fi
if [ "${i}" != "${i%.o}" ];then
mv "${i}" "$ndirec"
fi
done
if [ "$NUM_CORES" = "0" ]; then #just make code
exit 0
fi
echo $(pwd)
mv $pname "$bdirc" && echo " "&& echo "*****Install complete*****" && echo " "
clear
cd ../bin
if [ "$NUM_CORES" = "1" ]; then
./$pname
else
if [ $comp = 'gnu' ];then
/usr/local/bin/mpirun -n $NUM_CORES ./$pname
elif [ $comp = 'intel' ];then
mpirun -n $NUM_CORES ./$pname
fi
fi
}
#defaults
NUM_CORES=1
debug=0
help=0
comp="gnu"
pname="mcgrid"
set -e
createdirs
while [ "$1" != "" ]; do
case $1 in
-n | --cores ) NUM_CORES=$2
;;
-c | --comp ) comp=$2
;;
-h | --help ) showhelp
exit
;;
-m | --make ) NUM_CORES=0
makebuild
exit
;;
-d | --debug ) debug=1
;;
-p | --progName ) pname=$2
;;
esac
shift
done
makebuild
run