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 | #pno=24 # number of processes, i.e. number of todo-files
|
---|
48 |
|
---|
49 | todofile=$listpath/ToDo-$table-$column
|
---|
50 | lockfile=$lockpath/lock-getting-$program-list.txt
|
---|
51 |
|
---|
52 | scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
|
---|
53 | makedir $scriptlogpath
|
---|
54 | scriptlog=$scriptlogpath/run$program-$datetime.log
|
---|
55 |
|
---|
56 | date >> $scriptlog 2>&1
|
---|
57 |
|
---|
58 | cd $mars
|
---|
59 |
|
---|
60 | # check if getting of list is already running
|
---|
61 | date > $lockfile >> $scriptlog 2>&1
|
---|
62 | checklock0=$?
|
---|
63 | case $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;;
|
---|
70 | esac
|
---|
71 |
|
---|
72 | # finding todo file
|
---|
73 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
---|
74 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
---|
75 | then
|
---|
76 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
---|
77 | echo " -> choose one file and run $program" >> $scriptlog 2>&1
|
---|
78 | else
|
---|
79 | # get todo list
|
---|
80 | getdolist >> $scriptlog 2>&1
|
---|
81 | rm -v $lockfile >> $scriptlog 2>&1
|
---|
82 | fi
|
---|
83 |
|
---|
84 | # choosing todo file
|
---|
85 | nr=bla
|
---|
86 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
---|
87 | todofiles=`ls $listpath/ToDo-$table-$column-*`
|
---|
88 |
|
---|
89 | for todofile in ${todofiles[@]}
|
---|
90 | do
|
---|
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
|
---|
106 | done
|
---|
107 |
|
---|
108 | case $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;;
|
---|
113 | esac
|
---|
114 |
|
---|
115 | # retrieve dataset from todo file
|
---|
116 | datasets=(`cat $todofile`)
|
---|
117 | if [ "$datasets" = "" ]
|
---|
118 | then
|
---|
119 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
120 | finish >> $scriptlog 2>&1
|
---|
121 | fi
|
---|
122 |
|
---|
123 | # run ganymed for dataset
|
---|
124 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
---|
125 | for dataset in ${datasets[@]}
|
---|
126 | do
|
---|
127 | no=`printf %08d $dataset | cut -c 0-5`
|
---|
128 | no2=`printf %08d $dataset`
|
---|
129 | var1=$no
|
---|
130 | var2=$no2
|
---|
131 | outpath="$datapath/$program/$no/$no2"
|
---|
132 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
---|
133 | makedir $outpath >> $scriptlog 2>&1
|
---|
134 |
|
---|
135 | datasetfile="$datasetpath/$no/dataset$no2.txt"
|
---|
136 | echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
|
---|
137 | # get observation mode to choose ganymed.rc file
|
---|
138 | wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
---|
139 | wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
|
---|
140 | if [ "$wobble2" = "" ]
|
---|
141 | then
|
---|
142 | mode="wobble" >> $scriptlog 2>&1
|
---|
143 | else
|
---|
144 | mode="onoff" >> $scriptlog 2>&1
|
---|
145 | fi
|
---|
146 | ganymedrc=$setuppath/$program/$program_$mode.rc
|
---|
147 |
|
---|
148 | echo "run $program..." >> $scriptlog 2>&1
|
---|
149 | setstatus "start" >> $scriptlog 2>&1
|
---|
150 |
|
---|
151 | ./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
|
---|
152 | check1=$?
|
---|
153 |
|
---|
154 | case $check1 in
|
---|
155 | 0) echo "check1=$check1 -> everything ok " >> $scriptlog 2>&1 ;;
|
---|
156 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
157 | com="ganymed failed"
|
---|
158 | check=$check1
|
---|
159 | ;;
|
---|
160 | esac
|
---|
161 | echo "inserting the status for $program for dataset $dataset into the db" >> $scriptlog 2>&1
|
---|
162 | setstatus "stop" >> $scriptlog 2>&1
|
---|
163 | done
|
---|
164 |
|
---|
165 | finish >> $scriptlog 2>&1
|
---|
166 |
|
---|