-
Notifications
You must be signed in to change notification settings - Fork 2
/
mymake.sh
71 lines (66 loc) · 3.97 KB
/
mymake.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
#!/bin/bash
#=======================================================================
# mymake.sh example --Zheng Gong, 2020-03-04(yy/mm/dd)
#=======================================================================
# The below line is needed to be modified if necessary.
SRC="./src/"
CompilingLog="sDEM_CompilingLog.txt"
#-----------------------------------------------------------------------
# Normally no need to change anything below
PathCurrent="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
CompilingLog=$PathCurrent/$CompilingLog
TimeString=$(date "+%Y-%m-%d %H:%M:%S")
rm -rf $CompilingLog; touch $CompilingLog
echo | tee -a $CompilingLog
echo "!========================*- sDEM -*========================!" | tee -a $CompilingLog
echo "! !" | tee -a $CompilingLog
echo "! sDEM: simple Discrete Element Method !" | tee -a $CompilingLog
echo "! Version: 1.0 !" | tee -a $CompilingLog
echo "! Author: Zheng Gong !" | tee -a $CompilingLog
echo "! E-mail: gongzheng_justin@outlook.com !" | tee -a $CompilingLog
echo "! !" | tee -a $CompilingLog
echo "!====================*- Fortran 95/03 -*===================!" | tee -a $CompilingLog
echo | tee -a $CompilingLog
echo " Source Path: "$SRC | tee -a $CompilingLog
echo " Current Path: "$PathCurrent | tee -a $CompilingLog
echo " Compiling Time: "$TimeString | tee -a $CompilingLog
echo | tee -a $CompilingLog
echo " Which compiler do you use? " | tee -a $CompilingLog
echo " 1: Intel MPI ( mpiifort )" | tee -a $CompilingLog
echo " 2: gcc MPI ( mpif90 )" | tee -a $CompilingLog
read -p " please type a compiler index (1 or 2): " id_cmp
echo " please type a compiler index (1 or 2): "$id_cmp >> $CompilingLog
if [ $id_cmp -eq 1 ]; then
CMP="intel_MPI"
elif [ $id_cmp -eq 2 ]; then
CMP="gcc_MPI"
else
echo " Sorry, compiler type cannot be recognized." | tee -a $CompilingLog
echo " Compiling filed" | tee -a $CompilingLog
exit 1
fi
echo " "$CMP" will be used" | tee -a $CompilingLog
echo | tee -a $CompilingLog
EXE="dem"
echo " "$EXE" will be compiled" | tee -a $CompilingLog
echo | tee -a $CompilingLog
echo "!==================*- Compiling begins -*=================!" | tee -a $CompilingLog
echo | tee -a $CompilingLog
rm -fr $EXE
cd $SRC
make -f "make_"$EXE clean >&/dev/null
make -f "make_"$EXE CMP=$CMP exeName=$EXE 2>&1 | tee -a $CompilingLog
echo | tee -a $CompilingLog
mv $EXE $PathCurrent
if [ $? -ne 0 ]; then
make -f "make_"$EXE clean >&/dev/null
echo $EXE" CANNOT be compiled correctly, please check !!!" | tee -a $CompilingLog
else
make -f "make_"$EXE clean >&/dev/null
echo $EXE" has been compiled normally. Enjoy !!!" | tee -a $CompilingLog
cd ..
chmod a+x ./$EXE
fi
echo | tee -a $CompilingLog
echo "!===================*- Compiling ends -*==================!" | tee -a $CompilingLog
echo | tee -a $CompilingLog