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 | user=`whoami`
|
---|
30 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
31 |
|
---|
32 | set -C
|
---|
33 |
|
---|
34 | table=SequenceProcessStatus
|
---|
35 | column=fStar
|
---|
36 | date=NULL
|
---|
37 | datetime=`date +%F-%H-%M-%S`
|
---|
38 | year=`date +%Y`
|
---|
39 | pno=500 # number of processes, i.e. number of todo-files
|
---|
40 |
|
---|
41 | todofile=$listpath/ToDo-$table-$column
|
---|
42 | getstatuslogpath=$logpath/getstatus/star/$year
|
---|
43 | getstatuslog=$getstatuslogpath/getstatus-star-$datetime.log
|
---|
44 |
|
---|
45 | scriptlogpath=$logpath/run/star/`date +%Y/%m/%d`
|
---|
46 | if [ ! -d $scriptlogpath ]
|
---|
47 | then
|
---|
48 | mkdir -pv $scriptlogpath
|
---|
49 | if [ ! -d $scriptlogpath ]
|
---|
50 | then
|
---|
51 | echo "could not make scriptlogpath "$scriptlogpath
|
---|
52 | exit
|
---|
53 | fi
|
---|
54 | fi
|
---|
55 |
|
---|
56 | scriptlog=$scriptlogpath/runstar-$datetime.log
|
---|
57 |
|
---|
58 | date >> $scriptlog 2>&1
|
---|
59 |
|
---|
60 |
|
---|
61 | if [ ! -d $getstatuslogpath ]
|
---|
62 | then
|
---|
63 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
---|
64 | if [ ! -d $getstatuslogpath ]
|
---|
65 | then
|
---|
66 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
---|
67 | date >> $scriptlog 2>&1
|
---|
68 | exit
|
---|
69 | fi
|
---|
70 | fi
|
---|
71 |
|
---|
72 | cd $mars
|
---|
73 |
|
---|
74 | date > $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
|
---|
75 | checklock0=$?
|
---|
76 | case $checklock0 in
|
---|
77 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
---|
78 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
---|
79 | echo "-> getting list for star is running -> exit" >> $scriptlog 2>&1
|
---|
80 | date >> $scriptlog 2>&1
|
---|
81 | exit;;
|
---|
82 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
83 | esac
|
---|
84 |
|
---|
85 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
86 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
87 | then
|
---|
88 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
89 | echo " -> choose one file and start calculation of image parameter" >> $scriptlog 2>&1
|
---|
90 | else
|
---|
91 | echo "getting list..." >> $scriptlog 2>&1
|
---|
92 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
---|
93 |
|
---|
94 | case $check0 in
|
---|
95 | 1) echo "check0=$check0 -> everthing ok -> run star" >> $scriptlog 2>&1;;
|
---|
96 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
97 | esac
|
---|
98 | echo "cutting to-do-file" >> $scriptlog 2>&1
|
---|
99 | echo "getting no of lines" >> $scriptlog 2>&1
|
---|
100 | lines=`cat $todofile.txt | wc -l`
|
---|
101 | echo "number of lines: "$lines >> $scriptlog 2>&1
|
---|
102 | while (( "$lines" < "$pno" ))
|
---|
103 | do
|
---|
104 | echo "# of lines ($lines) < # of processes ($pno) "
|
---|
105 | pno=`expr $pno / 2`
|
---|
106 | done
|
---|
107 | echo "pno: "$pno
|
---|
108 | nofiles=`expr $lines / \( $pno - 1 \)`
|
---|
109 | nofiles=`expr $nofiles + 1 `
|
---|
110 | echo "number of files: "$nofiles >> $scriptlog 2>&1
|
---|
111 | echo "deviding todo-file" >> $scriptlog 2>&1
|
---|
112 | for (( j=1 ; j <= $pno ; j++ ))
|
---|
113 | do
|
---|
114 | begin=$(echo "1 + ( ($j - 1) * $nofiles)" | bc -l)
|
---|
115 | end=$(echo "$begin + $nofiles - 1" | bc -l)
|
---|
116 | echo "begin: "$begin >> $scriptlog 2>&1
|
---|
117 | echo "end: "$end >> $scriptlog 2>&1
|
---|
118 | file=${todofile}-${j}.txt
|
---|
119 | echo "file: "$file >> $scriptlog 2>&1
|
---|
120 | sed -ne ''"$begin"','"$end"'w '"$file"'' $todofile.txt
|
---|
121 | done
|
---|
122 |
|
---|
123 | rm -v $todofile.txt >> $scriptlog 2>&1
|
---|
124 | fi
|
---|
125 |
|
---|
126 | rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
|
---|
127 |
|
---|
128 | nr=bla
|
---|
129 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
130 | for (( i = 1; i <= $pno ; i++ ))
|
---|
131 | do
|
---|
132 | if ! ls $todofile-$i.txt >> $scriptlog 2>&1
|
---|
133 | then
|
---|
134 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
135 | continue
|
---|
136 | fi
|
---|
137 | date > $lockpath/lock-$table-$column-$i.txt >> $scriptlog 2>&1
|
---|
138 | checklock=$?
|
---|
139 | case $checklock in
|
---|
140 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
---|
141 | nr=${i}
|
---|
142 | break;;
|
---|
143 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
---|
144 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
---|
145 | esac
|
---|
146 | done
|
---|
147 |
|
---|
148 | case $nr in
|
---|
149 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
---|
150 | date >> $scriptlog 2>&1
|
---|
151 | exit;;
|
---|
152 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
---|
153 | esac
|
---|
154 |
|
---|
155 |
|
---|
156 | sequences=(`cat $todofile-$nr.txt`)
|
---|
157 |
|
---|
158 | if [ "$sequences" = "" ]
|
---|
159 | then
|
---|
160 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
161 | rm -v $todofile-$nr.txt >> $scriptlog 2>&1
|
---|
162 | rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
|
---|
163 | date >> $scriptlog 2>&1
|
---|
164 | exit
|
---|
165 | fi
|
---|
166 |
|
---|
167 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
---|
168 |
|
---|
169 | for sequence in ${sequences[@]}
|
---|
170 | do
|
---|
171 | no=`printf %08d $sequence | cut -c 0-4`
|
---|
172 | no2=`printf %08d $sequence`
|
---|
173 | outpath="$datapath/star/$no/$no2"
|
---|
174 | inpath=`echo $outpath | sed -e 's/star/callisto/'`
|
---|
175 | echo "inpath: "$inpath >> $scriptlog 2>&1
|
---|
176 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
177 | if [ ! -d $outpath ]
|
---|
178 | then
|
---|
179 | mkdir -pv $outpath >> $scriptlog 2>&1
|
---|
180 | if [ ! -d $outpath ]
|
---|
181 | then
|
---|
182 | echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
|
---|
183 | continue
|
---|
184 | fi
|
---|
185 | fi
|
---|
186 | sequfile="$sequpath/$no/sequence$no2.txt"
|
---|
187 | echo "sequfile: "$sequfile >> $scriptlog 2>&1
|
---|
188 |
|
---|
189 | echo "run star..." >> $scriptlog 2>&1
|
---|
190 | ./star -b -q -v4 -f --log=$outpath/star$no2.log --html=$outpath/star$no2.html --ind=$inpath --out=$outpath $sequfile 2>> $scriptlog> /dev/null
|
---|
191 | check1=$?
|
---|
192 |
|
---|
193 | case $check1 in
|
---|
194 | 0) echo "check1=$check1 -> everthing ok " >> $scriptlog 2>&1
|
---|
195 | echo "-> inserting the status for star for sequence $sequence into the db" >> $scriptlog 2>&1
|
---|
196 | setstatuslogpath=$logpath/setstatus/star/$no
|
---|
197 | if [ ! -d $setstatuslogpath ]
|
---|
198 | then
|
---|
199 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
---|
200 | if [ ! -d $setstatuslogpath ]
|
---|
201 | then
|
---|
202 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
---|
203 | continue
|
---|
204 | fi
|
---|
205 | fi
|
---|
206 | setstatuslog=$setstatuslogpath/setstatus-star-$no2.log
|
---|
207 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
|
---|
208 | case $check4 in
|
---|
209 | 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
---|
210 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
---|
211 | esac
|
---|
212 | ;;
|
---|
213 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
214 | esac
|
---|
215 | done
|
---|
216 |
|
---|
217 | rm -v $todofile-$nr.txt >> $scriptlog 2>&1
|
---|
218 | rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
|
---|
219 |
|
---|
220 | set +C
|
---|
221 |
|
---|
222 | date >> $scriptlog 2>&1
|
---|
223 |
|
---|