source: trunk/MagicSoft/Mars/datacenter/scripts/runganymed@ 7233

Last change on this file since 7233 was 7233, checked in by Daniela Dorner, 20 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.6 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
29user=`whoami`
30source /home/$user/Mars/datacenter/scripts/sourcefile
31
32set -C
33
34table=DataSetProcessStatus
35column=fGanymed
36date=NULL
37datetime=`date +%F-%H-%M-%S`
38year=`date +%Y`
39pno=24 # number of processes, i.e. number of todo-files
40
41todofile=$listpath/ToDo-$table-$column
42getstatuslogpath=$logpath/getstatus/ganymed/$year
43getstatuslog=$getstatuslogpath/getstatus-ganymed-$datetime.log
44
45scriptlogpath=$logpath/run/ganymed/`date +%Y/%m/%d`
46makedir $scriptlogpath
47
48scriptlog=$scriptlogpath/runganymed-$datetime.log
49
50date >> $scriptlog 2>&1
51
52makedir $getstatuslogpath >> $scriptlog 2>&1
53
54cd $mars
55
56date > $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
57checklock0=$?
58case $checklock0 in
59 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
60 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
61 echo "-> getting list for ganymed is running -> exit" >> $scriptlog 2>&1
62 date >> $scriptlog 2>&1
63 exit;;
64 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
65esac
66
67echo "checking if other todo-files are there" >> $scriptlog 2>&1
68if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
69then
70 echo "other file(s) on disk " >> $scriptlog 2>&1
71 echo " -> choose one file and run ganymed" >> $scriptlog 2>&1
72else
73 echo "getting list..." >> $scriptlog 2>&1
74 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
75
76 case $check0 in
77 1) echo "check0=$check0 -> everthing ok -> run ganymed" >> $scriptlog 2>&1;;
78 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
79 esac
80 echo "cutting to-do-file" >> $scriptlog 2>&1
81 echo "getting no of lines" >> $scriptlog 2>&1
82 lines=`cat $todofile.txt | wc -l`
83 echo "number of lines: "$lines >> $scriptlog 2>&1
84 while (( "$lines" < "$pno" ))
85 do
86 echo "# of lines ($lines) < # of processes ($pno) "
87 pno=`expr $pno / 2`
88 done
89 echo "pno: "$pno >> $scriptlog 2>&1
90 nofiles=`expr $lines / \( $pno - 1 \)`
91 echo "number of files: "$nofiles >> $scriptlog 2>&1
92 echo "deviding todo-file" >> $scriptlog 2>&1
93 for (( j=1 ; j <= $pno ; j++ ))
94 do
95 begin=$(echo "1 + ( ($j - 1) * $nofiles)" | bc -l)
96 end=$(echo "$begin + $nofiles - 1" | bc -l)
97 echo "begin: "$begin >> $scriptlog 2>&1
98 echo "end: "$end >> $scriptlog 2>&1
99 file=${todofile}-${j}.txt
100 echo "file: "$file >> $scriptlog 2>&1
101 sed -ne ''"$begin"','"$end"'w '"$file"'' $todofile.txt
102 done
103
104 rm -v $todofile.txt >> $scriptlog 2>&1
105fi
106
107rm -v $lockpath/lock-getting-ganymed-list.txt >> $scriptlog 2>&1
108
109nr=bla
110echo "finding the right todo-file" >> $scriptlog 2>&1
111for (( i = 1; i <= $pno ; i++ ))
112do
113 if ! ls $todofile-$i.txt >> $scriptlog 2>&1
114 then
115 echo "file is not on disk -> continue" >> $scriptlog 2>&1
116 continue
117 fi
118 date > $lockpath/lock-$table-$column-$i.txt >> $scriptlog 2>&1
119 checklock=$?
120 case $checklock in
121 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
122 nr=${i}
123 break;;
124 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
125 *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
126 esac
127done
128
129case $nr in
130 bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
131 date >> $scriptlog 2>&1
132 exit;;
133 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
134esac
135
136
137datasets=(`cat $todofile-$nr.txt`)
138
139if [ "$datasets" = "" ]
140then
141 echo "nothing to do -> exit" >> $scriptlog 2>&1
142 rm -v $todofile-$nr.txt >> $scriptlog 2>&1
143 rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
144 date >> $scriptlog 2>&1
145 exit
146fi
147
148echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
149
150for dataset in ${datasets[@]}
151do
152 no=`printf %08d $dataset | cut -c 0-5`
153 no2=`printf %08d $dataset`
154 outpath="$datapath/ganymed/$no/$no2"
155 echo "outpath: "$outpath >> $scriptlog 2>&1
156 makedir $outpath >> $scriptlog 2>&1
157
158 datasetfile="$datasetpath/$no/dataset$no2.txt"
159 echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
160 wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
161 wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
162 if [ "$wobble2" = "" ]
163 then
164 mode="wobble" >> $scriptlog 2>&1
165 else
166 mode="onoff" >> $scriptlog 2>&1
167 fi
168 ganymedrc=$setuppath/ganymed/ganymed_$mode.rc
169
170 echo "run ganymed..." >> $scriptlog 2>&1
171 ./ganymed -b -q -v4 -f --sum --config=$ganymedrc --log=$outpath/ganymed$no2.log --html=$outpath/ganymed$no2.html --out=$outpath $datasetfile 2>> $scriptlog> /dev/null
172 check1=$?
173
174 case $check1 in
175 0) echo "check1=$check1 -> everthing ok " >> $scriptlog 2>&1
176 echo "-> inserting the status for ganymed for dataset $dataset into the db" >> $scriptlog 2>&1
177 setstatuslogpath=$logpath/setstatus/ganymed/$no
178 makedir $setstatuslogpath >> $scriptlog 2>&1
179 setstatuslog=$setstatuslogpath/setstatus-ganymed-$no2.log
180
181 check4=`root -q -b $macrospath/setstatus.C+\("\"$dataset\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
182 case $check4 in
183 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
184 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
185 esac
186 ;;
187 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
188 esac
189done
190
191rm -v $todofile-$nr.txt >> $scriptlog 2>&1
192rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
193
194set +C
195
196date >> $scriptlog 2>&1
197
Note: See TracBrowser for help on using the repository browser.