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

Last change on this file since 7256 was 7256, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 5.5 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=SequenceProcessStatus
35column=fStar
36date=NULL
37datetime=`date +%F-%H-%M-%S`
38year=`date +%Y`
39#pno=500 # number of processes, i.e. number of todo-files
40
41todofile=$listpath/ToDo-$table-$column
42getstatuslogpath=$logpath/getstatus/star/$year
43getstatuslog=$getstatuslogpath/getstatus-star-$datetime.log
44
45scriptlogpath=$logpath/run/star/`date +%Y/%m/%d`
46makedir $scriptlogpath
47scriptlog=$scriptlogpath/runstar-$datetime.log
48
49date >> $scriptlog 2>&1
50
51makedir $getstatuslogpath >> $scriptlog 2>&1
52
53cd $mars
54
55date > $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
56checklock0=$?
57case $checklock0 in
58 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
59 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
60 echo "-> getting list for star is running -> exit" >> $scriptlog 2>&1
61 date >> $scriptlog 2>&1
62 exit;;
63 *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
64esac
65
66echo "checking if other todo-files are there" >> $scriptlog 2>&1
67if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
68then
69 echo "other file(s) on disk " >> $scriptlog 2>&1
70 echo " -> choose one file and start calculation of image parameter" >> $scriptlog 2>&1
71else
72 echo "getting list..." >> $scriptlog 2>&1
73 check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\,"\"$listpath\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
74
75 case $check0 in
76 1) echo "check0=$check0 -> everthing ok -> run star" >> $scriptlog 2>&1;;
77 *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
78 esac
79fi
80
81rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
82
83nr=bla
84echo "finding the right todo-file" >> $scriptlog 2>&1
85todofiles=`ls $listpath/*`
86
87echo "todofiles: "${todofiles[@]} >> $scriptlog 2>&1
88
89
90for todofile in ${todofiles[@]}
91do
92 if ! ls $todofile >> $scriptlog 2>&1
93 then
94 echo "file is not on disk -> continue" >> $scriptlog 2>&1
95 continue
96 fi
97 lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
98 date > $lockfile >> $scriptlog 2>&1
99 checklock=$?
100 case $checklock in
101 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
102 nr=${i}
103 break;;
104 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
105 *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
106 esac
107done
108
109case $nr in
110 bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
111 date >> $scriptlog 2>&1
112 exit;;
113 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
114esac
115
116
117sequences=(`cat $todofile`)
118
119if [ "$sequences" = "" ]
120then
121 echo "nothing to do -> exit" >> $scriptlog 2>&1
122 rm -v $todofile >> $scriptlog 2>&1
123 rm -v $lockfile >> $scriptlog 2>&1
124 date >> $scriptlog 2>&1
125 exit
126fi
127
128echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
129
130for sequence in ${sequences[@]}
131do
132 no=`printf %08d $sequence | cut -c 0-4`
133 no2=`printf %08d $sequence`
134 outpath="$datapath/star/$no/$no2"
135 inpath=`echo $outpath | sed -e 's/star/callisto/'`
136 echo "inpath: "$inpath >> $scriptlog 2>&1
137 echo "outpath: "$outpath >> $scriptlog 2>&1
138 makedir $outpath >> $scriptlog 2>&1
139
140 sequfile="$sequpath/$no/sequence$no2.txt"
141 echo "sequfile: "$sequfile >> $scriptlog 2>&1
142
143 echo "run star..." >> $scriptlog 2>&1
144 ./star -b -q -v4 -f --log=$outpath/star$no2.log --html=$outpath/star$no2.html --ind=$inpath --out=$outpath $sequfile 2>> $scriptlog> /dev/null
145 check1=$?
146
147 case $check1 in
148 0) echo "check1=$check1 -> everthing ok " >> $scriptlog 2>&1
149 echo "-> inserting the status for star for sequence $sequence into the db" >> $scriptlog 2>&1
150 setstatuslogpath=$logpath/setstatus/star/$no
151 makedir $setstatuslogpath >> $scriptlog 2>&1
152 setstatuslog=$setstatuslogpath/setstatus-star-$no2.log
153
154 check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog | grep int | sed -e 's/(int)//'`
155 case $check4 in
156 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
157 *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
158 esac
159 ;;
160 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
161 esac
162done
163
164rm -v $todofile >> $scriptlog 2>&1
165rm -v $lockfile >> $scriptlog 2>&1
166
167set +C
168
169date >> $scriptlog 2>&1
170
Note: See TracBrowser for help on using the repository browser.