-
Notifications
You must be signed in to change notification settings - Fork 6
/
compileTag.sh
executable file
·91 lines (75 loc) · 2.42 KB
/
compileTag.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
#!/bin/bash
whsPath=`grep "wrfHydroScripts" ~/.wrfHydroScripts | cut -d '=' -f2 | tr -d ' '`
source $whsPath/helpers.sh
source $whsPath/sourceMe.sh
clean=1
while getopts ":c" opt; do
case $opt in
c)
clean=0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift "$((OPTIND-1))" # Shift off the options and optional
## what is the integer argument to ./configure ?
## hydro vs yellowstone
theHost=`hostname`
## HYDRO
if [[ $theHost == *"hydro-c1"* ]]; then confOpt=2; fi ## pgfortran
## YELLOWSTONE
if [[ $theHost == *"yslogin"* ]]; then confOpt=8; fi ## intel
echo -e "Relevant environment variables:"
henv | grep '=1' | grep -v "WRF_HYDRO=1"
## configure
echo -e "\e[46mconfigure $confOpt\e[0m"
./configure $confOpt &> /dev/null
## make clean or just make?
if [ $clean -eq 0 ]
then
echo -e "\e[46mmake clean\e[0m"
make clean &> /dev/null
echo -e "\e[46mcompiling\e[0m"
./compile_offline_NoahMP.csh &> make.log
else
makeCheck &> make.log
fi
## was the compilation successful?
errGrep make.log
if [ ! $? -eq 0 ]
then
echo -e "\e[31mThere were compilation issues, see make.log.\e[0m"
exit 1
fi
## git-based tagging
## Master and "nobranch" are not tagged with branch name
## if on master/nobranch with no changes since commit
## wrf_hydro.sha.ENVVAR1-ENVVAR2.exe
## if on master/nobranch with changes since commit
## wrf_hydro.sha+.ENVVAR1-ENVVAR2.exe
## Other branches include the branch name
## if on branch with no changes since commit
## wrf_hydro.sha.ENVVAR1-ENVVAR2.exe
## if on branch with changes since commit
## wrf_hydro.sha+.ENVVAR1-ENVVAR2.exe
theSha=`git rev-parse --short HEAD`
unCommittedChanges=`git diff-index --quiet HEAD --`
if [ $? -ne 0 ]; then theSha=${theSha}+ ; fi
theSha=${theSha}.
whmPath=`grep "wrf_hydro_model" ~/.wrfHydroScripts | cut -d '=' -f2 | tr -d ' '`
cd $whmPath/trunk/NDHMS/
theBranch=`git branch | grep '*' | tr -d "*" | tr -d ' ' | stripColors`
isInSet $theBranch "master (nobranch)"
if [ $? -eq 0 ]; then theBranch=''; else theBranch=${theBranch}.;fi
## the env vars
envVars=`henv | grep '=1' | grep -v 'WRF_HYDRO=1' | cut -d '=' -f1 | tr '\n' '-'`
lEnvVars=${#envVars}
envVars=`echo $envVars | cut -c-$((${lEnvVars}-1))`
#echo $envVars
tag=${theSha}${theBranch}${envVars}
#echo $tag
cp Run/wrf_hydro.exe Run/wrf_hydro.${tag}.exe
ls -lah --color=auto Run/wrf_hydro.${tag}.exe
exit 0