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

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