| 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-2004
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | #
|
|---|
| 28 |
|
|---|
| 29 | source /home/operator/Mars/datacenter/scripts/sourcefile
|
|---|
| 30 |
|
|---|
| 31 | set -C
|
|---|
| 32 |
|
|---|
| 33 | table=SequenceProcessStatus
|
|---|
| 34 | column=fStar
|
|---|
| 35 | date=NULL
|
|---|
| 36 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 37 | year=`date +%Y`
|
|---|
| 38 | pno=24 # number of processes, i.e. number of todo-files
|
|---|
| 39 |
|
|---|
| 40 | todofile=/magic/datacenter/lists/ToDo-$table-$column
|
|---|
| 41 | getstatuslogpath=$logpath/getstatus/star/$year
|
|---|
| 42 | getstatuslog=$getstatuslogpath/getstatus-star-$datetime.log
|
|---|
| 43 |
|
|---|
| 44 | scriptlogpath=$logpath/run/star/`date +%Y/%m/%d`
|
|---|
| 45 | if [ ! -d $scriptlogpath ]
|
|---|
| 46 | then
|
|---|
| 47 | mkdir -pv $scriptlogpath
|
|---|
| 48 | if [ ! -d $scriptlogpath ]
|
|---|
| 49 | then
|
|---|
| 50 | echo "could not make scriptlogpath "$scriptlogpath
|
|---|
| 51 | exit
|
|---|
| 52 | fi
|
|---|
| 53 | fi
|
|---|
| 54 |
|
|---|
| 55 | scriptlog=$scriptlogpath/runstar-$datetime.log
|
|---|
| 56 |
|
|---|
| 57 | date >> $scriptlog 2>&1
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | if [ ! -d $getstatuslogpath ]
|
|---|
| 61 | then
|
|---|
| 62 | mkdir -pv $getstatuslogpath >> $scriptlog 2>&1
|
|---|
| 63 | if [ ! -d $getstatuslogpath ]
|
|---|
| 64 | then
|
|---|
| 65 | echo "could not make getstatuslogpath "$getstatuslogpath >> $scriptlog 2>&1
|
|---|
| 66 | date >> $scriptlog 2>&1
|
|---|
| 67 | exit
|
|---|
| 68 | fi
|
|---|
| 69 | fi
|
|---|
| 70 |
|
|---|
| 71 | cd $mars
|
|---|
| 72 |
|
|---|
| 73 | date > $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
|
|---|
| 74 | checklock0=$?
|
|---|
| 75 | case $checklock0 in
|
|---|
| 76 | 0) echo "checklock0=$checklock0 -> continue " >> $scriptlog 2>&1;;
|
|---|
| 77 | 1) echo "checklock0=$checklock0 -> file exists " >> $scriptlog 2>&1
|
|---|
| 78 | echo "-> getting list for star is running -> exit" >> $scriptlog 2>&1
|
|---|
| 79 | date >> $scriptlog 2>&1
|
|---|
| 80 | exit;;
|
|---|
| 81 | *) echo "checklock0=$checklock0 -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 82 | esac
|
|---|
| 83 |
|
|---|
| 84 | echo "checking if other todo-files are there" >> $scriptlog 2>&1
|
|---|
| 85 | if ls $todofile-[1-9]*.txt >> $scriptlog 2>&1
|
|---|
| 86 | then
|
|---|
| 87 | echo "other file(s) on disk " >> $scriptlog 2>&1
|
|---|
| 88 | echo " -> choose one file and start calculation of image parameter" >> $scriptlog 2>&1
|
|---|
| 89 | else
|
|---|
| 90 | echo "getting list..." >> $scriptlog 2>&1
|
|---|
| 91 | check0=`root -q -b $macrospath/getdolist.C+\("\"$table\""\,"\"$column\""\,"\"$date\""\) | tee $getstatuslog | grep int | sed -e 's/(int)//'`
|
|---|
| 92 |
|
|---|
| 93 | case $check0 in
|
|---|
| 94 | 1) echo "check0=$check0 -> everthing ok -> run star" >> $scriptlog 2>&1;;
|
|---|
| 95 | *) echo "check0=$check0 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 96 | esac
|
|---|
| 97 | echo "cutting to-do-file" >> $scriptlog 2>&1
|
|---|
| 98 | echo "getting no of lines" >> $scriptlog 2>&1
|
|---|
| 99 | lines=`cat $todofile.txt | wc -l`
|
|---|
| 100 | echo "number of lines: "$lines >> $scriptlog 2>&1
|
|---|
| 101 | while (( "$lines" < "$pno" ))
|
|---|
| 102 | do
|
|---|
| 103 | echo "# of lines ($lines) < # of processes ($pno) "
|
|---|
| 104 | pno=`expr $pno / 2`
|
|---|
| 105 | done
|
|---|
| 106 | echo "pno: "$pno
|
|---|
| 107 | nofiles=`expr $lines / \( $pno - 1 \)`
|
|---|
| 108 | echo "number of files: "$nofiles >> $scriptlog 2>&1
|
|---|
| 109 | echo "deviding todo-file" >> $scriptlog 2>&1
|
|---|
| 110 | for (( j=1 ; j <= $pno ; j++ ))
|
|---|
| 111 | do
|
|---|
| 112 | begin=$(echo "1 + ( ($j - 1) * $nofiles)" | bc -l)
|
|---|
| 113 | end=$(echo "$begin + $nofiles - 1" | bc -l)
|
|---|
| 114 | echo "begin: "$begin >> $scriptlog 2>&1
|
|---|
| 115 | echo "end: "$end >> $scriptlog 2>&1
|
|---|
| 116 | file=${todofile}-${j}.txt
|
|---|
| 117 | echo "file: "$file >> $scriptlog 2>&1
|
|---|
| 118 | sed -ne ''"$begin"','"$end"'w '"$file"'' $todofile.txt
|
|---|
| 119 | done
|
|---|
| 120 |
|
|---|
| 121 | rm -v $todofile.txt >> $scriptlog 2>&1
|
|---|
| 122 | fi
|
|---|
| 123 |
|
|---|
| 124 | rm -v $lockpath/lock-getting-star-list.txt >> $scriptlog 2>&1
|
|---|
| 125 |
|
|---|
| 126 | nr=bla
|
|---|
| 127 | echo "finding the right todo-file" >> $scriptlog 2>&1
|
|---|
| 128 | for (( i = 1; i <= $pno ; i++ ))
|
|---|
| 129 | do
|
|---|
| 130 | if ! ls $todofile-$i.txt >> $scriptlog 2>&1
|
|---|
| 131 | then
|
|---|
| 132 | echo "file is not on disk -> continue" >> $scriptlog 2>&1
|
|---|
| 133 | continue
|
|---|
| 134 | fi
|
|---|
| 135 | date > $lockpath/lock-$table-$column-$i.txt >> $scriptlog 2>&1
|
|---|
| 136 | checklock=$?
|
|---|
| 137 | case $checklock in
|
|---|
| 138 | 0) echo "checklock=$checklock -> setting number" >> $scriptlog 2>&1
|
|---|
| 139 | nr=${i}
|
|---|
| 140 | break;;
|
|---|
| 141 | 1) echo "checklock=$checklock -> file exists -> continue" >> $scriptlog 2>&1;;
|
|---|
| 142 | *) echo "checklock=$checklock -> something went completely wrong" >> $scriptlog 2>&1;;
|
|---|
| 143 | esac
|
|---|
| 144 | done
|
|---|
| 145 |
|
|---|
| 146 | case $nr in
|
|---|
| 147 | bla) echo "everything is beeing processed -> exit" >> $scriptlog 2>&1
|
|---|
| 148 | date >> $scriptlog 2>&1
|
|---|
| 149 | exit;;
|
|---|
| 150 | 12345678) echo "process nr: "$nr >> $scriptlog 2>&1;;
|
|---|
| 151 | esac
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | sequences=(`cat $todofile-$nr.txt`)
|
|---|
| 155 |
|
|---|
| 156 | if [ "$sequences" = "" ]
|
|---|
| 157 | then
|
|---|
| 158 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 159 | rm -v $todofile-$nr.txt >> $scriptlog 2>&1
|
|---|
| 160 | rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
|
|---|
| 161 | date >> $scriptlog 2>&1
|
|---|
| 162 | exit
|
|---|
| 163 | fi
|
|---|
| 164 |
|
|---|
| 165 | echo "sequences: "${sequences[@]} >> $scriptlog 2>&1
|
|---|
| 166 |
|
|---|
| 167 | for sequence in ${sequences[@]}
|
|---|
| 168 | do
|
|---|
| 169 | no=`printf %08d $sequence | cut -c 4`
|
|---|
| 170 | outpath="/magic/data/star/"`printf %04d $no`"/"`printf %08d $sequence`
|
|---|
| 171 | inpath=`echo $outpath | sed -e 's/star/callisto/'`
|
|---|
| 172 | echo "inpath: "$inpath >> $scriptlog 2>&1
|
|---|
| 173 | echo "outpath: "$outpath >> $scriptlog 2>&1
|
|---|
| 174 | if [ ! -d $outpath ]
|
|---|
| 175 | then
|
|---|
| 176 | mkdir -pv $outpath >> $scriptlog 2>&1
|
|---|
| 177 | if [ ! -d $outpath ]
|
|---|
| 178 | then
|
|---|
| 179 | echo "could not make outpath $outpath -> continue " >> $scriptlog 2>&1
|
|---|
| 180 | continue
|
|---|
| 181 | fi
|
|---|
| 182 | fi
|
|---|
| 183 | sequfile="/magic/sequences/"`printf %04d $no`"/sequence"`printf %08d $sequence`".txt"
|
|---|
| 184 | echo "sequfile: "$sequfile >> $scriptlog 2>&1
|
|---|
| 185 |
|
|---|
| 186 | echo "run star..." >> $scriptlog 2>&1
|
|---|
| 187 | ./star -b -q -f --log=$outpath/star$sequence.log --ind=$inpath --out=$outpath $sequfile 2>> $scriptlog> /dev/null
|
|---|
| 188 | check1=$?
|
|---|
| 189 |
|
|---|
| 190 | case $check1 in
|
|---|
| 191 | 0) echo "check1=$check1 -> everthing ok " >> $scriptlog 2>&1
|
|---|
| 192 | echo "-> inserting the status for star for sequence $sequence into the db" >> $scriptlog 2>&1
|
|---|
| 193 | setstatuslogpath=$logpath/setstatus/star/`printf %04d $no`
|
|---|
| 194 | if [ ! -d $setstatuslogpath ]
|
|---|
| 195 | then
|
|---|
| 196 | mkdir -pv $setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 197 | if [ ! -d $setstatuslogpath ]
|
|---|
| 198 | then
|
|---|
| 199 | echo "could not make setstatuslogpath "$setstatuslogpath >> $scriptlog 2>&1
|
|---|
| 200 | continue
|
|---|
| 201 | fi
|
|---|
| 202 | fi
|
|---|
| 203 | setstatuslog=$setstatuslogpath/setstatus-star
|
|---|
| 204 | check4=`root -q -b $macrospath/setstatus.C+\("\"$sequence\""\,"\"$table\""\,"\"$column\""\,"\"Now()\""\) | tee $setstatuslog-$sequence.log | grep int | sed -e 's/(int)//'`
|
|---|
| 205 | case $check4 in
|
|---|
| 206 | 1) echo "check4=$check4 -> everthing ok, status has been set" >> $scriptlog 2>&1;;
|
|---|
| 207 | *) echo "check4=$check4 -> ERROR -> step could not be set" >> $scriptlog 2>&1;;
|
|---|
| 208 | esac
|
|---|
| 209 | ;;
|
|---|
| 210 | *) echo "check1=$check1 -> ERROR -> step has to be repeated" >> $scriptlog 2>&1;;
|
|---|
| 211 | esac
|
|---|
| 212 | done
|
|---|
| 213 |
|
|---|
| 214 | rm -v $todofile-$nr.txt >> $scriptlog 2>&1
|
|---|
| 215 | rm -v $lockpath/lock-$table-$column-$nr.txt >> $scriptlog 2>&1
|
|---|
| 216 |
|
|---|
| 217 | set +C
|
|---|
| 218 |
|
|---|
| 219 | date >> $scriptlog 2>&1
|
|---|
| 220 |
|
|---|