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

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