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

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