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

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