source: trunk/MagicSoft/Mars/datacenter/scripts/runstar@ 7051

Last change on this file since 7051 was 7051, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 7.1 KB
Line 
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
29source /home/operator/Mars/datacenter/scripts/sourcefile
30
31set -C
32
33table=SequenceProcessStatus
34column=fStar
35date=NULL
36datetime=`date +%F-%H-%M-%S`
37year=`date +%Y`
38pno=24 # number of processes, i.e. number of todo-files
39
40todofile=/magic/datacenter/lists/ToDo-$table-$column
41getstatuslogpath=$logpath/getstatus/star/$year
42getstatuslog=$getstatuslogpath/getstatus-star-$datetime.log
43
44scriptlogpath=$logpath/run/star/`date +%Y/%m/%d`
45if [ ! -d $scriptlogpath ]
46then
47 mkdir -pv $scriptlogpath
48 if [ ! -d $scriptlogpath ]
49 then
50 echo "could not make scriptlogpath "$scriptlogpath
51 exit
52 fi
53fi
54
55scriptlog=$scriptlogpath/runstar-$datetime.log
56
57date >> $scriptlog 2>&1
58
59
60if [ ! -d $getstatuslogpath ]
61then
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
69fi
70
71cd $mars
72
73date > $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
74checklock0=$?
75case $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 star is running -> exit" >> $scriptlog 2>&1
79 date >> $scriptlog 2>&1
80 exit;;
81 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
82esac
83
84echo "checking if other todo-files are there" >> $scriptlog 2>&1
85if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
86then
87 echo "other file(s) on disk " >> $scriptlog 2>&1
88 echo " -> choose one file and start calculation of image parameter" >> $scriptlog 2>&1
89else
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 star" >> $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
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
122fi
123
124rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
125
126nr=bla
127echo "finding the right todo-file" >> $scriptlog 2>&1
128for (( i = 1; i <= $pno ; i++ ))
129do
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
144done
145
146case $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;;
151esac
152
153
154sequences=(`cat $todofile-$nr.txt`)
155
156if [ "$sequences" = "" ]
157then
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
163fi
164
165echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
166
167for sequence in ${sequences[@]}
168do
169 no=`printf %08d $sequence | cut -c 0-4`
170 no2=`printf %08d $sequence`
171 outpath="/magic/data/star/$no/$no2"
172 inpath=`echo $outpath | sed -e 's/star/callisto/'`
173 echo "inpath: "$inpath >> $scriptlog 2>&1
174 echo "outpath: "$outpath >> $scriptlog 2>&1
175 if [ ! -d $outpath ]
176 then
177 mkdir -pv $outpath >> $scriptlog 2>&1
178 if [ ! -d $outpath ]
179 then
180 echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
181 continue
182 fi
183 fi
184 sequfile="/magic/sequences/$no/sequence$no2.txt"
185 echo "sequfile: "$sequfile >> $scriptlog 2>&1
186
187 echo "run star..." >> $scriptlog 2>&1
188 ./star -b -q -f --log=$outpath/star$sequence.log --ind=$inpath --out=$outpath $sequfile 2>> $scriptlog> /dev/null
189 check1=$?
190
191 case $check1 in
192 0) echo "check1=$check1 -> everthing ok " >> $scriptlog 2>&1
193 echo "-> inserting the status for star for sequence $sequence into the db" >> $scriptlog 2>&1
194 setstatuslogpath=$logpath/setstatus/star/$no
195 if [ ! -d $setstatuslogpath ]
196 then
197 mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
198 if [ ! -d $setstatuslogpath ]
199 then
200 echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
201 continue
202 fi
203 fi
204 setstatuslog=$setstatuslogpath/setstatus-star-$no2.log
205 check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
206 case $check4 in
207 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
208 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
209 esac
210 ;;
211 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
212 esac
213done
214
215rm -v $todofile-$nr.txt >> $scriptlog 2>&1
216rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
217
218set +C
219
220date >> $scriptlog 2>&1
221
Note: See TracBrowser for help on using the repository browser.