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

Last change on this file since 7604 was 7514, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.9 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`
40program=ganymed
41source /home/$user/Mars/datacenter/scripts/sourcefile
42
43set -C
44
45table=DataSetProcessStatus
46column=fGanymed
47#pno=24 # 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# finding todo file
61echo "checking if other todo-files are there" >> $scriptlog 2>&1
62if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
63then
64 echo "other file(s) on disk " >> $scriptlog 2>&1
65 echo " -> choose one file and run $program" >> $scriptlog 2>&1
66else
67 # check if getting of list is already running
68 checklock "getting list of" >> $scriptlog 2>&1
69 # get todo list
70 getdolist >> $scriptlog 2>&1
71 rm -v $lockfile >> $scriptlog 2>&1
72fi
73
74# choosing todo file
75nr=bla
76echo "finding the right todo-file" >> $scriptlog 2>&1
77todofiles=`ls $listpath/ToDo-$table-$column-*`
78
79for todofile in ${todofiles[@]}
80do
81 if ! ls $todofile >> $scriptlog 2>&1
82 then
83 echo "file is not on disk -> continue" >> $scriptlog 2>&1
84 continue
85 fi
86 lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
87 date > $lockfile >> $scriptlog 2>&1
88 checklock=$?
89 case $checklock in
90 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
91 nr=${i}
92 break;;
93 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
94 *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
95 esac
96done
97
98case $nr in
99 bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
100 date >> $scriptlog 2>&1
101 exit;;
102 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
103esac
104
105# retrieve dataset from todo file
106datasets=(`cat $todofile`)
107if [ "$datasets" = "" ]
108then
109 echo "nothing to do -> exit" >> $scriptlog 2>&1
110 finish >> $scriptlog 2>&1
111fi
112
113# run ganymed for dataset
114echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
115for dataset in ${datasets[@]}
116do
117 no=`printf %08d $dataset | cut -c 0-5`
118 no2=`printf %08d $dataset`
119 var1=$no
120 var2=$no2
121 outpath="$datapath/$program/$no/$no2"
122 echo "outpath: "$outpath >> $scriptlog 2>&1
123 makedir $outpath >> $scriptlog 2>&1
124
125 datasetfile="$datasetpath/$no/dataset$no2.txt"
126 echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
127 # get observation mode to choose ganymed.rc file
128 wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
129 wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
130 if [ "$wobble2" = "" ]
131 then
132 mode="wobble" >> $scriptlog 2>&1
133 else
134 mode="onoff" >> $scriptlog 2>&1
135 fi
136 ganymedrc=$setuppath/ganymed/ganymed_$mode.rc
137
138 echo "run $program..." >> $scriptlog 2>&1
139 setstatus "start" >> $scriptlog 2>&1
140
141 ./ganymed -b -q -v4 -f --ind=$datapath/star --config=$ganymedrc --log=$outpath/$program$no2.log --html=$outpath/$program$no2.html --out=$outpath $datasetfile 2>> $scriptlog> /dev/null
142 check1=$?
143
144 case $check1 in
145 0) echo "check1=$check1 -> everything ok " >> $scriptlog 2>&1 ;;
146 *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
147 com=$Fganymed
148 check=$check1
149 ;;
150 esac
151 echo "inserting the status for $program for dataset $dataset into the db" >> $scriptlog 2>&1
152 setstatus "stop" >> $scriptlog 2>&1
153done
154
155finish >> $scriptlog 2>&1
156
Note: See TracBrowser for help on using the repository browser.