-
Notifications
You must be signed in to change notification settings - Fork 0
/
mpis-compile
51 lines (39 loc) · 1016 Bytes
/
mpis-compile
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
#!/bin/bash
. "${MPIS_UI}"
if [[ "$*" == *--clean* ]]
then
find . -name "*.x" -delete; exit 0
fi
if [ "$#" -lt 1 ]
then
log "ERROR" "usage: $( basename "$0" ) [SOURCE] [MACROS]..."; exit 1
fi
if [ ! -r "$1" ]
then
log "ERROR" "'$1' is not readable"; exit 1
fi
exe="$( basename "$1" )"
exe="${exe%.*}.x"
args="-O3 -Wall -Wextra"
for ((key = 2; key <= $#; key += 2))
do
value="$(( $key + 1))"
if [ "$value" -gt "$#" ]
then
log "WARNING" "No value associated with key '${!key}'"
else
args="$args -D${!key}=${!value}"
fi
done
if [[ "$MPIS_ENABLE_PROFILING" == true ]] || ([[ -z "${MPIS_ENABLE_PROFILING+is_set}" ]] && confirm "MESSAGE" "enable profiling")
then
args="$args -g -L$MPIP_DIR/lib -lmpiP -lbfd -lunwind"
fi
if [[ "$MPIS_LINK_OPENMP" == true ]] || ([[ -z "${MPIS_LINK_OPENMP+is_set}" ]] && confirm "MESSAGE" "link OpenMP")
then
args="$args -fopenmp"
fi
if ! mpicc $args "$1" -o "$exe"
then
log "ERROR" "'$1' failed to compile"; exit 1
fi