forked from COSIMA/access-om2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hashexe-public.sh
executable file
·167 lines (139 loc) · 8.56 KB
/
hashexe-public.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env sh
# Copy ACCESS-OM2 executables to bin with githash in name, and config.yaml to match.
# All changes to config.yaml are reported.
# This is basically the same as hashexe.sh but copies to a public bin dir (using non-clobbering copy for safety).
#
# Andrew Kiss https://github.com/aekiss
set -e
if [[ -z "${ACCESS_OM_DIR}" ]]; then
export ACCESS_OM_DIR=$(pwd)
fi
if [[ -z "${public}" ]]; then
public=/g/data/ik11/inputs/access-om2/bin # if not called from update-commit-push.sh
fi
if [ -w $public ]; then
bindir=$public
else
echo "You don't have write access to $public. Exiting."
exit 1
fi
if [[ -z "${mom_type}" ]]; then
echo "FATAL ERROR: mom_type not set. Need to do whichever of these is appropriate"
echo " export mom_type=ACCESS-OM"
echo "or"
echo " export mom_type=ACCESS-OM-BGC"
echo "taking into account the branches the control dirs are on:"
for d in control/*; do cd $d; echo $d; git status | grep "On branch"; cd -; done
exit 1
fi
yatmpath=${ACCESS_OM_DIR}/src/libaccessom2/build/bin/yatm.exe
fmspath=${ACCESS_OM_DIR}/src/mom/exec/nci/${mom_type}/fms_${mom_type}.x
cice1path=${ACCESS_OM_DIR}/src/cice5/build_auscom_360x300_24p/cice_auscom_360x300_24p.exe
cice025path=${ACCESS_OM_DIR}/src/cice5/build_auscom_1440x1080_480p/cice_auscom_1440x1080_480p.exe
cice010path=${ACCESS_OM_DIR}/src/cice5/build_auscom_3600x2700_722p/cice_auscom_3600x2700_722p.exe
cice010path_18x15=${ACCESS_OM_DIR}/src/cice5/build_auscom_18x15.3600x2700_1682p/cice_auscom_18x15.3600x2700_1682p.exe
mppnccombinepath=${ACCESS_OM_DIR}/src/mom/bin/mppnccombine.nci
config1ryfpath=${ACCESS_OM_DIR}/control/1deg_jra55_ryf/config.yaml
config025ryfpath=${ACCESS_OM_DIR}/control/025deg_jra55_ryf/config.yaml
config010ryfpath=${ACCESS_OM_DIR}/control/01deg_jra55_ryf/config.yaml
config1iafpath=${ACCESS_OM_DIR}/control/1deg_jra55_iaf/config.yaml
config025iafpath=${ACCESS_OM_DIR}/control/025deg_jra55_iaf/config.yaml
config010iafpath=${ACCESS_OM_DIR}/control/01deg_jra55_iaf/config.yaml
echo "Getting executable hashes..."
cd $(dirname "${yatmpath}") && yatmhash=`git rev-parse --short=7 HEAD`
test -z "$(git status --porcelain)" || yatmhash=${yatmhash}-modified # uncommitted changes or untracked files
cd $(dirname "${fmspath}") && fmshash=`git rev-parse --short=7 HEAD`
test -z "$(git status --porcelain)" || fmshash=${fmshash}-modified # uncommitted changes or untracked files
fmshash=${fmshash}_libaccessom2_${yatmhash} # also track libaccessom2
cd $(dirname "${cice1path}") && cicehash=`git rev-parse --short=7 HEAD` # NB only one hash for all three cice builds
test -z "$(git status --porcelain)" || cicehash=${cicehash}-modified # uncommitted changes or untracked files
cicehash=${cicehash}_libaccessom2_${yatmhash} # also track libaccessom2
echo "Copying executables to "${bindir}" with hashes added to names..."
yatmbn=$(basename "${yatmpath}")
yatmhashexe="${yatmbn%.*}"_${yatmhash}."${yatmpath##*.}"
echo " cp -n ${yatmpath} ${bindir}/${yatmhashexe}"
cp -n ${yatmpath} ${bindir}/${yatmhashexe}
chmod o+x ${bindir}/${yatmhashexe} || true
chgrp ik11 ${bindir}/${yatmhashexe} || true
fmsbn=$(basename "${fmspath}")
fmshashexe="${fmsbn%.*}"_${fmshash}."${fmspath##*.}"
echo " cp -n ${fmspath} ${bindir}/${fmshashexe}"
cp -n ${fmspath} ${bindir}/${fmshashexe}
chmod o+x ${bindir}/${fmshashexe} || true
chgrp ik11 ${bindir}/${fmshashexe} || true
cice1bn=$(basename "${cice1path}")
cice1hashexe="${cice1bn%.*}"_${cicehash}."${cice1path##*.}"
echo " cp -n ${cice1path} ${bindir}/${cice1hashexe}"
cp -n ${cice1path} ${bindir}/${cice1hashexe}
chmod o+x ${bindir}/${cice1hashexe} || true
chgrp ik11 ${bindir}/${cice1hashexe} || true
cice025bn=$(basename "${cice025path}")
cice025hashexe="${cice025bn%.*}"_${cicehash}."${cice025path##*.}"
echo " cp -n ${cice025path} ${bindir}/${cice025hashexe}"
cp -n ${cice025path} ${bindir}/${cice025hashexe}
chmod o+x ${bindir}/${cice025hashexe} || true
chgrp ik11 ${bindir}/${cice025hashexe} || true
cice010bn=$(basename "${cice010path}")
cice010hashexe="${cice010bn%.*}"_${cicehash}."${cice010path##*.}"
echo " cp -n ${cice010path} ${bindir}/${cice010hashexe}"
cp -n ${cice010path} ${bindir}/${cice010hashexe}
chmod o+x ${bindir}/${cice010hashexe} || true
chgrp ik11 ${bindir}/${cice010hashexe} || true
cice010bn_18x15=$(basename "${cice010path_18x15}")
cice010hashexe_18x15="${cice010bn_18x15%.*}"_${cicehash}."${cice010path_18x15##*.}"
echo " cp -n ${cice010path_18x15} ${bindir}/${cice010hashexe_18x15}"
cp -n ${cice010path_18x15} ${bindir}/${cice010hashexe_18x15}
chmod o+x ${bindir}/${cice010hashexe_18x15} || true
chgrp ik11 ${bindir}/${cice010hashexe_18x15} || true
echo " cp -n ${mppnccombinepath} ${bindir}/mppnccombine"
cp -n ${mppnccombinepath} ${bindir}/mppnccombine # no hash for mppnccombine
chmod o+x ${bindir}/mppnccombine || true # no hash for mppnccombine
chgrp ik11 ${bindir}/mppnccombine || true # no hash for mppnccombine
echo "Fixing exe in "${config1ryfpath}" to match executable names..."
sed "s|exe:.*${yatmbn%.*}_.*|exe: ${bindir}/${yatmhashexe}|g" < ${config1ryfpath} > ${config1ryfpath}-tmp
sed "s|exe:.*${fmsbn%.*}_.*|exe: ${bindir}/${fmshashexe}|g" < ${config1ryfpath}-tmp > ${config1ryfpath}-tmp2
sed "s|exe:.*${cice1bn%.*}_.*|exe: ${bindir}/${cice1hashexe}|g" < ${config1ryfpath}-tmp2 > ${config1ryfpath}-tmp3
diff ${config1ryfpath} ${config1ryfpath}-tmp3 || true
mv ${config1ryfpath}-tmp3 ${config1ryfpath}
rm ${config1ryfpath}-tmp*
echo "Fixing exe in "${config025ryfpath}" to match executable names..."
sed "s|exe:.*${yatmbn%.*}_.*|exe: ${bindir}/${yatmhashexe}|g" < ${config025ryfpath} > ${config025ryfpath}-tmp
sed "s|exe:.*${fmsbn%.*}_.*|exe: ${bindir}/${fmshashexe}|g" < ${config025ryfpath}-tmp > ${config025ryfpath}-tmp2
sed "s|exe:.*${cice025bn%.*}_.*|exe: ${bindir}/${cice025hashexe}|g" < ${config025ryfpath}-tmp2 > ${config025ryfpath}-tmp3
diff ${config025ryfpath} ${config025ryfpath}-tmp3 || true
mv ${config025ryfpath}-tmp3 ${config025ryfpath}
rm ${config025ryfpath}-tmp*
echo "Fixing exe in "${config010ryfpath}" to match executable names..."
sed "s|exe:.*${yatmbn%.*}_.*|exe: ${bindir}/${yatmhashexe}|g" < ${config010ryfpath} > ${config010ryfpath}-tmp
sed "s|exe:.*${fmsbn%.*}_.*|exe: ${bindir}/${fmshashexe}|g" < ${config010ryfpath}-tmp > ${config010ryfpath}-tmp2
sed "s|exe:.*${cice010bn%.*}_.*|exe: ${bindir}/${cice010hashexe}|g" < ${config010ryfpath}-tmp2 > ${config010ryfpath}-tmp3
diff ${config010ryfpath} ${config010ryfpath}-tmp3 || true
mv ${config010ryfpath}-tmp3 ${config010ryfpath}
rm ${config010ryfpath}-tmp*
echo "Fixing exe in "${config1iafpath}" to match executable names..."
sed "s|exe:.*${yatmbn%.*}_.*|exe: ${bindir}/${yatmhashexe}|g" < ${config1iafpath} > ${config1iafpath}-tmp
sed "s|exe:.*${fmsbn%.*}_.*|exe: ${bindir}/${fmshashexe}|g" < ${config1iafpath}-tmp > ${config1iafpath}-tmp2
sed "s|exe:.*${cice1bn%.*}_.*|exe: ${bindir}/${cice1hashexe}|g" < ${config1iafpath}-tmp2 > ${config1iafpath}-tmp3
diff ${config1iafpath} ${config1iafpath}-tmp3 || true
mv ${config1iafpath}-tmp3 ${config1iafpath}
rm ${config1iafpath}-tmp*
echo "Fixing exe in "${config025iafpath}" to match executable names..."
sed "s|exe:.*${yatmbn%.*}_.*|exe: ${bindir}/${yatmhashexe}|g" < ${config025iafpath} > ${config025iafpath}-tmp
sed "s|exe:.*${fmsbn%.*}_.*|exe: ${bindir}/${fmshashexe}|g" < ${config025iafpath}-tmp > ${config025iafpath}-tmp2
sed "s|exe:.*${cice025bn%.*}_.*|exe: ${bindir}/${cice025hashexe}|g" < ${config025iafpath}-tmp2 > ${config025iafpath}-tmp3
diff ${config025iafpath} ${config025iafpath}-tmp3 || true
mv ${config025iafpath}-tmp3 ${config025iafpath}
rm ${config025iafpath}-tmp*
echo "Fixing exe in "${config010iafpath}" to match executable names..."
sed "s|exe:.*${yatmbn%.*}_.*|exe: ${bindir}/${yatmhashexe}|g" < ${config010iafpath} > ${config010iafpath}-tmp
sed "s|exe:.*${fmsbn%.*}_.*|exe: ${bindir}/${fmshashexe}|g" < ${config010iafpath}-tmp > ${config010iafpath}-tmp2
sed "s|exe:.*${cice010bn%.*}_.*|exe: ${bindir}/${cice010hashexe}|g" < ${config010iafpath}-tmp2 > ${config010iafpath}-tmp3
diff ${config010iafpath} ${config010iafpath}-tmp3 || true
mv ${config010iafpath}-tmp3 ${config010iafpath}
rm ${config010iafpath}-tmp*
# TODO: fix sed script to handle changes of mom_type
echo
echo "WARNING: if your previous exe mom_type was not ${mom_type} it will need to be manually updated in the config.yaml file"
echo
sleep 1
echo "$(basename $BASH_SOURCE) completed."