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 | program=ganymed
|
---|
40 | source `dirname $0`/sourcefile
|
---|
41 |
|
---|
42 | set -C
|
---|
43 |
|
---|
44 | column=fGanymed
|
---|
45 | #pno=24 # number of processes, i.e. number of todo-files
|
---|
46 |
|
---|
47 | lockfile=$lockpath/lock-getting-$program-list.txt
|
---|
48 |
|
---|
49 | scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
|
---|
50 | makedir $scriptlogpath
|
---|
51 | scriptlog=$scriptlogpath/run$program-$datetime.log
|
---|
52 |
|
---|
53 | date >> $scriptlog 2>&1
|
---|
54 |
|
---|
55 | # get todo file
|
---|
56 | possibletodofiles=`ls -r $listpath/ToDo-*-$column-*.txt` >> $scriptlog 2>&1
|
---|
57 | if [ "$possibletodofiles" = "" ]
|
---|
58 | then
|
---|
59 | echo "ERROR: in $program no todofiles found => something went wrong in jobmanager"
|
---|
60 | finish >> $scriptlog 2>&1
|
---|
61 | else
|
---|
62 | singleprocess="yes"
|
---|
63 | echo "todofiles: "${possibletodofiles[@]} >> $scriptlog 2>&1
|
---|
64 | for possibletodofile in ${possibletodofiles[@]}
|
---|
65 | do
|
---|
66 | if ! ls $possibletodofile >> $scriptlog 2>&1
|
---|
67 | then
|
---|
68 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
---|
69 | continue
|
---|
70 | fi
|
---|
71 | lockfile=`echo $possibletodofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
---|
72 | checklock >> $scriptlog 2>&1
|
---|
73 | todofile=$possibletodofile
|
---|
74 | done
|
---|
75 | fi
|
---|
76 | if [ "$todofile" = "" ]
|
---|
77 | then
|
---|
78 | echo "no todofile found -> exit" >> $scriptlog 2>&1
|
---|
79 | finish >> $scriptlog 2>&1
|
---|
80 | fi
|
---|
81 |
|
---|
82 | # retrieve dataset from todo file
|
---|
83 | datasets=(`cat $todofile`)
|
---|
84 | if [ "$datasets" = "" ]
|
---|
85 | then
|
---|
86 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
---|
87 | finish >> $scriptlog 2>&1
|
---|
88 | fi
|
---|
89 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
---|
90 | rm -v $todofile >> $scriptlog 2>&
|
---|
91 |
|
---|
92 | # run ganymed for dataset
|
---|
93 | for dataset in ${datasets[@]}
|
---|
94 | do
|
---|
95 | echo "run $program for dataset $dataset..." >> $scriptlog 2>&1
|
---|
96 | no=`printf %08d $dataset | cut -c 0-5`
|
---|
97 | no2=`printf %08d $dataset`
|
---|
98 | var1=$no
|
---|
99 | var2=$no2
|
---|
100 | outpath="$datapath/$program/$no/$no2"
|
---|
101 | makedir $outpath >> $scriptlog 2>&1
|
---|
102 |
|
---|
103 | datasetfile="$datasetpath/$no/dataset$no2.txt"
|
---|
104 | # get observation mode to choose ganymed.rc file
|
---|
105 | wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
---|
106 | wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
|
---|
107 | if [ "$wobble2" = "" ]
|
---|
108 | then
|
---|
109 | mode="wobble" >> $scriptlog 2>&1
|
---|
110 | else
|
---|
111 | mode="onoff" >> $scriptlog 2>&1
|
---|
112 | fi
|
---|
113 | ganymedrc=$setuppath/ganymed/ganymed_$mode.rc
|
---|
114 |
|
---|
115 | setstatus "start" >> $scriptlog 2>&1
|
---|
116 |
|
---|
117 | ./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
|
---|
118 | check1=$?
|
---|
119 |
|
---|
120 | case $check1 in
|
---|
121 | 0) echo " check1=$check1 -> everything ok " >> $scriptlog 2>&1 ;;
|
---|
122 | *) echo " check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
---|
123 | com=$Fganymed
|
---|
124 | check=$check1
|
---|
125 | ;;
|
---|
126 | esac
|
---|
127 |
|
---|
128 | setstatus "stop" >> $scriptlog 2>&1
|
---|
129 | done
|
---|
130 |
|
---|
131 | finish >> $scriptlog 2>&1
|
---|
132 |
|
---|