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 |
|
---|
39 | user=`whoami`
|
---|
40 | program=ganymed
|
---|
41 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
---|
42 |
|
---|
43 | set -C
|
---|
44 |
|
---|
45 | table=DataSetProcessStatus
|
---|
46 | column=fGanymed
|
---|
47 | date=NULL
|
---|
48 | datetime=`date +%F-%H-%M-%S`
|
---|
49 | year=`date +%Y`
|
---|
50 | #pno=24 # number of processes, i.e. number of todo-files
|
---|
51 |
|
---|
52 | todofile=$listpath/ToDo-$table-$column
|
---|
53 | getstatuslogpath=$logpath/getstatus/$program/$year
|
---|
54 | getstatuslog=$getstatuslogpath/getstatus-$program-$datetime.log
|
---|
55 |
|
---|
56 | scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
|
---|
57 | makedir $scriptlogpath
|
---|
58 | scriptlog=$scriptlogpath/run$program-$datetime.log
|
---|
59 |
|
---|
60 | date >> $scriptlog 2>&1
|
---|
61 |
|
---|
62 | makedir $getstatuslogpath >> $scriptlog 2>&1
|
---|
63 |
|
---|
64 | cd $mars
|
---|
65 |
|
---|
66 | # check if getting of list is already running
|
---|
67 | date > $lockpath/lock-getting-$program-list.txt >> $scriptlog 2>&1
|
---|
68 | checklock0=$?
|
---|
69 | case $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;;
|
---|
76 | esac
|
---|
77 |
|
---|
78 | # finding todo file
|
---|
79 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
80 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
81 | then
|
---|
82 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
83 | echo " -> choose one file and run $program" >> $scriptlog 2>&1
|
---|
84 | else
|
---|
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
|
---|
92 | fi
|
---|
93 |
|
---|
94 | rm -v $lockpath/lock-getting-$program-list.txt >> $scriptlog 2>&1
|
---|
95 |
|
---|
96 | # choosing todo file
|
---|
97 | nr=bla
|
---|
98 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
99 | todofiles=`ls $listpath/ToDo-$table-$column-*`
|
---|
100 |
|
---|
101 | for todofile in ${todofiles[@]}
|
---|
102 | do
|
---|
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
|
---|
118 | done
|
---|
119 |
|
---|
120 | case $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;;
|
---|
125 | esac
|
---|
126 |
|
---|
127 | # retrieve dataset from todo file
|
---|
128 | datasets=(`cat $todofile`)
|
---|
129 | if [ "$datasets" = "" ]
|
---|
130 | then
|
---|
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
|
---|
136 | fi
|
---|
137 |
|
---|
138 | # run ganymed for dataset
|
---|
139 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
---|
140 | for dataset in ${datasets[@]}
|
---|
141 | do
|
---|
142 | no=`printf %08d $dataset | cut -c 0-5`
|
---|
143 | no2=`printf %08d $dataset`
|
---|
144 | outpath="$datapath/$program/$no/$no2"
|
---|
145 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
146 | makedir $outpath >> $scriptlog 2>&1
|
---|
147 |
|
---|
148 | datasetfile="$datasetpath/$no/dataset$no2.txt"
|
---|
149 | echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
|
---|
150 | # get observation mode to choose ganymed.rc file
|
---|
151 | wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
---|
152 | wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
|
---|
153 | if [ "$wobble2" = "" ]
|
---|
154 | then
|
---|
155 | mode="wobble" >> $scriptlog 2>&1
|
---|
156 | else
|
---|
157 | mode="onoff" >> $scriptlog 2>&1
|
---|
158 | fi
|
---|
159 | ganymedrc=$setuppath/$program/$program_$mode.rc
|
---|
160 |
|
---|
161 | echo "run $program..." >> $scriptlog 2>&1
|
---|
162 | ./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
|
---|
163 | check1=$?
|
---|
164 |
|
---|
165 | case $check1 in
|
---|
166 | 0) echo "check1=$check1 -> everything ok " >> $scriptlog 2>&1
|
---|
167 | echo "inserting the status for $program for dataset $dataset into the db" >> $scriptlog 2>&1
|
---|
168 | statustime="Now()"
|
---|
169 | failed="NULL"
|
---|
170 | starttime="NULL"
|
---|
171 | failedtime="NULL"
|
---|
172 | var1=$no
|
---|
173 | var2=$no2
|
---|
174 | setstatus
|
---|
175 | ;;
|
---|
176 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
---|
177 | esac
|
---|
178 | done
|
---|
179 |
|
---|
180 | rm -v $todofile >> $scriptlog 2>&1
|
---|
181 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
182 |
|
---|
183 | set +C
|
---|
184 |
|
---|
185 | date >> $scriptlog 2>&1
|
---|
186 |
|
---|