| 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 | table=DataSetProcessStatus
|
|---|
| 45 | column=fGanymed
|
|---|
| 46 | #pno=24 # number of processes, i.e. number of todo-files
|
|---|
| 47 |
|
|---|
| 48 | todofile=$listpath/ToDo-$table-$column
|
|---|
| 49 | lockfile=$lockpath/lock-getting-$program-list.txt
|
|---|
| 50 |
|
|---|
| 51 | scriptlogpath=$logpath/run/$program/`date +%Y/%m/%d`
|
|---|
| 52 | makedir $scriptlogpath
|
|---|
| 53 | scriptlog=$scriptlogpath/run$program-$datetime.log
|
|---|
| 54 |
|
|---|
| 55 | date >> $scriptlog 2>&1
|
|---|
| 56 |
|
|---|
| 57 | cd $mars
|
|---|
| 58 |
|
|---|
| 59 | # finding todo file
|
|---|
| 60 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
|---|
| 61 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
|---|
| 62 | then
|
|---|
| 63 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
|---|
| 64 | echo " -> choose one file and run $program" >> $scriptlog 2>&1
|
|---|
| 65 | else
|
|---|
| 66 | # check if getting of list is already running
|
|---|
| 67 | checklock "getting list of" >> $scriptlog 2>&1
|
|---|
| 68 | # get todo list
|
|---|
| 69 | getdolist >> $scriptlog 2>&1
|
|---|
| 70 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 71 | fi
|
|---|
| 72 |
|
|---|
| 73 | # choosing todo file
|
|---|
| 74 | nr=bla
|
|---|
| 75 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
|---|
| 76 | todofiles=`ls $listpath/ToDo-$table-$column-*`
|
|---|
| 77 |
|
|---|
| 78 | for todofile in ${todofiles[@]}
|
|---|
| 79 | do
|
|---|
| 80 | if ! ls $todofile >> $scriptlog 2>&1
|
|---|
| 81 | then
|
|---|
| 82 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
|---|
| 83 | continue
|
|---|
| 84 | fi
|
|---|
| 85 | lockfile=`echo $todofile | sed -e 's/lists/locks/' -e 's/ToDo/lock/'`
|
|---|
| 86 | date > $lockfile >> $scriptlog 2>&1
|
|---|
| 87 | checklock=$?
|
|---|
| 88 | case $checklock in
|
|---|
| 89 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
|---|
| 90 | nr=${i}
|
|---|
| 91 | break;;
|
|---|
| 92 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
|---|
| 93 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 94 | esac
|
|---|
| 95 | done
|
|---|
| 96 |
|
|---|
| 97 | case $nr in
|
|---|
| 98 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
|---|
| 99 | date >> $scriptlog 2>&1
|
|---|
| 100 | exit;;
|
|---|
| 101 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
|---|
| 102 | esac
|
|---|
| 103 |
|
|---|
| 104 | # retrieve dataset from todo file
|
|---|
| 105 | datasets=(`cat $todofile`)
|
|---|
| 106 | if [ "$datasets" = "" ]
|
|---|
| 107 | then
|
|---|
| 108 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 109 | finish >> $scriptlog 2>&1
|
|---|
| 110 | fi
|
|---|
| 111 |
|
|---|
| 112 | # run ganymed for dataset
|
|---|
| 113 | echo "datasets: "${datasets[@]} >> $scriptlog 2>&1
|
|---|
| 114 | for dataset in ${datasets[@]}
|
|---|
| 115 | do
|
|---|
| 116 | no=`printf %08d $dataset | cut -c 0-5`
|
|---|
| 117 | no2=`printf %08d $dataset`
|
|---|
| 118 | var1=$no
|
|---|
| 119 | var2=$no2
|
|---|
| 120 | outpath="$datapath/$program/$no/$no2"
|
|---|
| 121 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
|---|
| 122 | makedir $outpath >> $scriptlog 2>&1
|
|---|
| 123 |
|
|---|
| 124 | datasetfile="$datasetpath/$no/dataset$no2.txt"
|
|---|
| 125 | echo "datasetfile: "$datasetfile >> $scriptlog 2>&1
|
|---|
| 126 | # get observation mode to choose ganymed.rc file
|
|---|
| 127 | wobble=`grep 'WobbleMode:' $datasetfile` >> $scriptlog 2>&1
|
|---|
| 128 | wobble2=`echo $wobble | grep ^\#` >> $scriptlog 2>&1
|
|---|
| 129 | if [ "$wobble2" = "" ]
|
|---|
| 130 | then
|
|---|
| 131 | mode="wobble" >> $scriptlog 2>&1
|
|---|
| 132 | else
|
|---|
| 133 | mode="onoff" >> $scriptlog 2>&1
|
|---|
| 134 | fi
|
|---|
| 135 | ganymedrc=$setuppath/ganymed/ganymed_$mode.rc
|
|---|
| 136 |
|
|---|
| 137 | echo "run $program..." >> $scriptlog 2>&1
|
|---|
| 138 | setstatus "start" >> $scriptlog 2>&1
|
|---|
| 139 |
|
|---|
| 140 | ./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
|
|---|
| 141 | check1=$?
|
|---|
| 142 |
|
|---|
| 143 | case $check1 in
|
|---|
| 144 | 0) echo "check1=$check1 -> everything ok " >> $scriptlog 2>&1 ;;
|
|---|
| 145 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1
|
|---|
| 146 | com=$Fganymed
|
|---|
| 147 | check=$check1
|
|---|
| 148 | ;;
|
|---|
| 149 | esac
|
|---|
| 150 | echo "inserting the status for $program for dataset $dataset into the db" >> $scriptlog 2>&1
|
|---|
| 151 | setstatus "stop" >> $scriptlog 2>&1
|
|---|
| 152 | done
|
|---|
| 153 |
|
|---|
| 154 | finish >> $scriptlog 2>&1
|
|---|
| 155 |
|
|---|