1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Daniela Dorner 08/2004 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2004
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | #
|
---|
28 |
|
---|
29 | source /home/operator/Mars/datacenter/scripts/sourcefile
|
---|
30 |
|
---|
31 | set -C
|
---|
32 |
|
---|
33 | table=DataSetProcessStatus
|
---|
34 | column=fGanymed
|
---|
35 | date=NULL
|
---|
36 | datetime=`date +%F-%H-%M-%S`
|
---|
37 | year=`date +%Y`
|
---|
38 | pno=4 # number of processes, i.e. number of todo-files
|
---|
39 |
|
---|
40 | todofile=$listpath/ToDo-$table-$column
|
---|
41 | getstatuslogpath=$logpath/getstatus/ganymed/$year
|
---|
42 | getstatuslog=$getstatuslogpath/getstatus-ganymed-$datetime.log
|
---|
43 |
|
---|
44 | scriptlogpath=$logpath/run/ganymed/`date +%Y/%m/%d`
|
---|
45 | if [ ! -d $scriptlogpath ]
|
---|
46 | then
|
---|
47 | mkdir -pv $scriptlogpath
|
---|
48 | if [ ! -d $scriptlogpath ]
|
---|
49 | then
|
---|
50 | echo "could not make scriptlogpath "$scriptlogpath
|
---|
51 | exit
|
---|
52 | fi
|
---|
53 | fi
|
---|
54 |
|
---|
55 | scriptlog=$scriptlogpath/runganymed-$datetime.log
|
---|
56 |
|
---|
57 | date >> $scriptlog 2>&1
|
---|
58 |
|
---|
59 |
|
---|
60 | if [ ! -d $getstatuslogpath ]
|
---|
61 | then
|
---|
62 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
---|
63 | if [ ! -d $getstatuslogpath ]
|
---|
64 | then
|
---|
65 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
---|
66 | date >> $scriptlog 2>&1
|
---|
67 | exit
|
---|
68 | fi
|
---|
69 | fi
|
---|
70 |
|
---|
71 | cd $mars
|
---|
72 |
|
---|
73 | date > $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
|
---|
74 | checklock0=$?
|
---|
75 | case $checklock0 in
|
---|
76 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
77 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
78 | echo "-> getting list for ganymed is running -> exit" >> $scriptlog 2>&1
|
---|
79 | date >> $scriptlog 2>&1
|
---|
80 | exit;;
|
---|
81 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
82 | esac
|
---|
83 |
|
---|
84 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
85 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
86 | then
|
---|
87 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
88 | echo " -> choose one file and run ganymed" >> $scriptlog 2>&1
|
---|
89 | else
|
---|
90 | echo "getting list..." >> $scriptlog 2>&1
|
---|
91 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
92 |
|
---|
93 | case $check0 in
|
---|
94 | 1) echo "check0=$check0 -> everthing ok -> run ganymed" >> $scriptlog 2>&1;;
|
---|
95 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
96 | esac
|
---|
97 | echo "cutting to-do-file" >> $scriptlog 2>&1
|
---|
98 | echo "getting no of lines" >> $scriptlog 2>&1
|
---|
99 | lines=`cat $todofile.txt | wc -l`
|
---|
100 | echo "number of lines: "$lines >> $scriptlog 2>&1
|
---|
101 | while (( "$lines" < "$pno" ))
|
---|
102 | do
|
---|
103 | echo "# of lines ($lines) < # of processes ($pno) "
|
---|
104 | pno=`expr $pno / 2`
|
---|
105 | done
|
---|
106 | echo "pno: "$pno >> $scriptlog 2>&1
|
---|
107 | nofiles=`expr $lines / \( $pno - 1 \)`
|
---|
108 | echo "number of files: "$nofiles >> $scriptlog 2>&1
|
---|
109 | echo "deviding todo-file" >> $scriptlog 2>&1
|
---|
110 | for (( j=1 ; j <= $pno ; j++ ))
|
---|
111 | do
|
---|
112 | begin=$(echo "1 + ( ($j - 1) * $nofiles)" | bc -l)
|
---|
113 | end=$(echo "$begin + $nofiles - 1" | bc -l)
|
---|
114 | echo "begin: "$begin >> $scriptlog 2>&1
|
---|
115 | echo "end: "$end >> $scriptlog 2>&1
|
---|
116 | file=${todofile}-${j}.txt
|
---|
117 | echo "file: "$file >> $scriptlog 2>&1
|
---|
118 | sed -ne ''"$begin"','"$end"'w '"$file"'' $todofile.txt
|
---|
119 | done
|
---|
120 |
|
---|
121 | rm -v $todofile.txt >> $scriptlog 2>&1
|
---|
122 | fi
|
---|
123 |
|
---|
124 | rm -v $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
|
---|
125 |
|
---|
126 | nr=bla
|
---|
127 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
128 | for (( i = 1; i <= $pno ; i++ ))
|
---|
129 | do
|
---|
130 | if ! ls $todofile-$i.txt >> $scriptlog 2>&1
|
---|
131 | then
|
---|
132 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
133 | continue
|
---|
134 | fi
|
---|
135 | date > $lockpath/lock-$table-$column-$i.txt >> $scriptlog 2>&1
|
---|
136 | checklock=$?
|
---|
137 | case $checklock in
|
---|
138 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
---|
139 | nr=${i}
|
---|
140 | break;;
|
---|
141 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
---|
142 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
143 | esac
|
---|
144 | done
|
---|
145 |
|
---|
146 | case $nr in
|
---|
147 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
---|
148 | date >> $scriptlog 2>&1
|
---|
149 | exit;;
|
---|
150 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
---|
151 | esac
|
---|
152 |
|
---|
153 |
|
---|
154 | datasets=(`cat $todofile-$nr.txt`)
|
---|
155 |
|
---|
156 | if [ "$datasets" = "" ]
|
---|
157 | then
|
---|
158 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
159 | rm -v $todofile-$nr.txt >> $scriptlog 2>&1
|
---|
160 | rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
|
---|
161 | date >> $scriptlog 2>&1
|
---|
162 | exit
|
---|
163 | fi
|
---|
164 |
|
---|
165 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
---|
166 |
|
---|
167 | for dataset in ${datasets[@]}
|
---|
168 | do
|
---|
169 | no=`printf %08d $dataset | cut -c 0-5`
|
---|
170 | no2=`printf %08d $dataset`
|
---|
171 | outpath="$datapath/ganymed/$no/$no2"
|
---|
172 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
173 | if [ ! -d $outpath ]
|
---|
174 | then
|
---|
175 | mkdir -pv $outpath >> $scriptlog 2>&1
|
---|
176 | if [ ! -d $outpath ]
|
---|
177 | then
|
---|
178 | echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
|
---|
179 | continue
|
---|
180 | fi
|
---|
181 | fi
|
---|
182 | datasetfile="/magic/datasets/$no/dataset$no2.txt"
|
---|
183 | echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
|
---|
184 | wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
---|
185 | wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
|
---|
186 | if [ "$mode2" = "" ]
|
---|
187 | then
|
---|
188 | mode="wobble" >> $scriptlog 2>&1
|
---|
189 | else
|
---|
190 | mode="onoff" >> $scriptlog 2>&1
|
---|
191 | fi
|
---|
192 | ganymedrc=/magic/datacenter/setup/ganymed/ganymed_$mode
|
---|
193 |
|
---|
194 | echo "run ganymed..." >> $scriptlog 2>&1
|
---|
195 | ./ganymed -b -q -f --sum --config=$ganymedrc.rc --log=$outpath/ganymed$no2.log --html=$outpath/ganymed$no2.html --out=$outpath $datasetfile 2>> $scriptlog> /dev/null
|
---|
196 | check1=$?
|
---|
197 |
|
---|
198 | case $check1 in
|
---|
199 | 0) echo "check1=$check1 -> everthing ok " >> $scriptlog 2>&1
|
---|
200 | echo "-> do ganymed a second time " >> $scriptlog 2>&1
|
---|
201 | ./ganymed -b -q -f --skip-res --config=$ganymedrc-fs.rc --log=$outpath/ganymed$no2-fs.log --html=$outpath/ganymed$no2-fs.html --out=$outpath --outf=ganymed$no2-fs.root $datasetfile 2>> $scriptlog> /dev/null
|
---|
202 | check2=$?
|
---|
203 |
|
---|
204 | case $check2 in
|
---|
205 | 0) echo "check2=$check2 -> everthing ok " >> $scriptlog 2>&1
|
---|
206 | echo "-> inserting the status for ganymed for dataset $dataset into the db" >> $scriptlog 2>&1
|
---|
207 | setstatuslogpath=$logpath/setstatus/ganymed/$no
|
---|
208 | if [ ! -d $setstatuslogpath ]
|
---|
209 | then
|
---|
210 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
---|
211 | if [ ! -d $setstatuslogpath ]
|
---|
212 | then
|
---|
213 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
---|
214 | continue
|
---|
215 | fi
|
---|
216 | fi
|
---|
217 | setstatuslog=$setstatuslogpath/setstatus-ganymed-$no2.log
|
---|
218 | check4=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
219 | case $check4 in
|
---|
220 | 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
---|
221 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
---|
222 | esac
|
---|
223 | ;;
|
---|
224 | *) echo "check2=$check2 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
225 | esac
|
---|
226 | ;;
|
---|
227 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
228 | esac
|
---|
229 | done
|
---|
230 |
|
---|
231 | rm -v $todofile-$nr.txt >> $scriptlog 2>&1
|
---|
232 | rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
|
---|
233 |
|
---|
234 | set +C
|
---|
235 |
|
---|
236 | date >> $scriptlog 2>&1
|
---|
237 |
|
---|