1 | #!/bin/bash
|
---|
2 | #
|
---|
3 |
|
---|
4 | source `dirname $0`/../Sourcefile.sh
|
---|
5 | printprocesslog "INFO starting $0"
|
---|
6 | program=CalcSource
|
---|
7 | step=CalcSource
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 | # for refilling DB from scratch several processes are useful
|
---|
12 | # therefore two commandline options have been implemented:
|
---|
13 | # numjobs: number of process that are started from CalcSource.sh
|
---|
14 | # numjob: number of the current process [0 to numjobs-1]
|
---|
15 | if [ "$1" != "" ]
|
---|
16 | then
|
---|
17 | numjobs=$1
|
---|
18 | if [ "$2" == "" ]
|
---|
19 | then
|
---|
20 | echo "missing second argument"
|
---|
21 | finish
|
---|
22 | else
|
---|
23 | numjob=$2
|
---|
24 | fi
|
---|
25 | if [ $2 -gt $(($1 - 1)) ]
|
---|
26 | then
|
---|
27 | echo "you cannot start a job with a number larger than the number of jobs you specified"
|
---|
28 | finish
|
---|
29 | fi
|
---|
30 | else
|
---|
31 | numjobs=1
|
---|
32 | numjob=0
|
---|
33 | fi
|
---|
34 |
|
---|
35 |
|
---|
36 | set -C
|
---|
37 |
|
---|
38 | # check if script is already running
|
---|
39 | lockfile=$lockpath/lock-$numjob-$program.txt
|
---|
40 | checklock
|
---|
41 |
|
---|
42 | # get todo list
|
---|
43 | gettodo
|
---|
44 |
|
---|
45 | logfile=$runlogpath"/CalcSource-"$numjob"-"$datetime".log"
|
---|
46 | date >> $logfile
|
---|
47 |
|
---|
48 | # setup file for calcsource
|
---|
49 | rc=`ls \`dirname $0\`/../Setup/calcsource.rc`
|
---|
50 |
|
---|
51 |
|
---|
52 | for (( s=0 ; s < $num ; s++ ))
|
---|
53 | do
|
---|
54 | night=${primaries[$s+$s]}
|
---|
55 | runid=${primaries[$s+$s+1]}
|
---|
56 |
|
---|
57 | if [ $(($runid % $numjobs)) -ne $numjob ]
|
---|
58 | then
|
---|
59 | printprocesslog "INFO processing only part of the data (runid "$runid", numjobs "$numjobs", "$numjob") -> continue"
|
---|
60 | continue
|
---|
61 | fi
|
---|
62 |
|
---|
63 | setstatus "start"
|
---|
64 | if [ $numchanged -eq 0 ]
|
---|
65 | then
|
---|
66 | printprocesslog "INFO "$numchanged" rows were changed in DB => "$night"_"$runid" is already processed => continue."
|
---|
67 | continue
|
---|
68 | fi
|
---|
69 |
|
---|
70 | # get file-id
|
---|
71 | query="SELECT FileID FROM CalcSourceStatus WHERE fNight="$night" AND fRunID="$runid
|
---|
72 | fileid=`sendquery`
|
---|
73 | #echo "INFO calculating source position for "$fileid
|
---|
74 | printprocesslog "INFO calculating source position for "$fileid
|
---|
75 | echo "INFO filling star events for "$fileid >> $logfile
|
---|
76 |
|
---|
77 | # fill star files to DB
|
---|
78 | printprocesslog "INFO /swdev_nfs/FACT++.r19193-bin/calcsource -C $rc $fileid"
|
---|
79 | /swdev_nfs/FACT++.r19193-bin/calcsource -C $rc $fileid >> $logfile 2>&1
|
---|
80 | check1=$?
|
---|
81 | case $check1 in
|
---|
82 | 0) printprocesslog "INFO successfully calculated source for "$fileid
|
---|
83 | ;;
|
---|
84 | *) printprocesslog "ERROR could not calc source for "$fileid
|
---|
85 | check=$check1
|
---|
86 | ;;
|
---|
87 | esac
|
---|
88 |
|
---|
89 | setstatus "stop"
|
---|
90 | done
|
---|
91 |
|
---|
92 | finish
|
---|
93 |
|
---|