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

Last change on this file since 7175 was 7141, 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=$listpath/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 nofiles=`expr $nofiles + 1 `
109 echo "number of files: "$nofiles >> $scriptlog 2>&1
110 echo "deviding todo-file" >> $scriptlog 2>&1
111 for (( j=1 ; j <= $pno ; j++ ))
112 do
113 begin=$(echo "1 + ( ($j - 1) * $nofiles)" | bc -l)
114 end=$(echo "$begin + $nofiles - 1" | bc -l)
115 echo "begin: "$begin >> $scriptlog 2>&1
116 echo "end: "$end >> $scriptlog 2>&1
117 file=${todofile}-${j}.txt
118 echo "file: "$file >> $scriptlog 2>&1
119 sed -ne ''"$begin"','"$end"'w '"$file"'' $todofile.txt
120 done
121
122 rm -v $todofile.txt >> $scriptlog 2>&1
123fi
124
125rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
126
127nr=bla
128echo "finding the right todo-file" >> $scriptlog 2>&1
129for (( i = 1; i <= $pno ; i++ ))
130do
131 if ! ls $todofile-$i.txt >> $scriptlog 2>&1
132 then
133 echo "file is not on disk -> continue" >> $scriptlog 2>&1
134 continue
135 fi
136 date > $lockpath/lock-$table-$column-$i.txt >> $scriptlog 2>&1
137 checklock=$?
138 case $checklock in
139 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
140 nr=${i}
141 break;;
142 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
143 *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
144 esac
145done
146
147case $nr in
148 bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
149 date >> $scriptlog 2>&1
150 exit;;
151 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
152esac
153
154
155sequences=(`cat $todofile-$nr.txt`)
156
157if [ "$sequences" = "" ]
158then
159 echo "nothing to do -> exit" >> $scriptlog 2>&1
160 rm -v $todofile-$nr.txt >> $scriptlog 2>&1
161 rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
162 date >> $scriptlog 2>&1
163 exit
164fi
165
166echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
167
168for sequence in ${sequences[@]}
169do
170 no=`printf %08d $sequence | cut -c 0-4`
171 no2=`printf %08d $sequence`
172 outpath="$datapath/star/$no/$no2"
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/$no/sequence$no2.txt"
186 echo "sequfile: "$sequfile >> $scriptlog 2>&1
187
188 echo "run star..." >> $scriptlog 2>&1
189 ./star -b -q -v4 -f --log=$outpath/star$no2.log --html=$outpath/star$no2.html --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/$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-$no2.log
206 check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | 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.