source: trunk/DataCheck/Processing/CalcSource.sh@ 19651

Last change on this file since 19651 was 19489, checked in by Daniela Dorner, 6 years ago
fixed typo
  • Property svn:executable set to *
File size: 2.2 KB
Line 
1#!/bin/bash
2#
3
4source `dirname $0`/../Sourcefile.sh
5printprocesslog "INFO starting $0"
6program=CalcSource
7step=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]
15if [ "$1" != "" ]
16then
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
30else
31 numjobs=1
32 numjob=0
33fi
34
35
36set -C
37
38# check if script is already running
39lockfile=$lockpath/lock-$numjob-$program.txt
40checklock
41
42# get todo list
43gettodo
44
45logfile=$runlogpath"/CalcSource-"$numjob"-"$datetime".log"
46date >> $logfile
47
48# setup file for calcsource
49rc=`ls \`dirname $0\`/../Setup/calcsource.rc`
50
51
52for (( s=0 ; s < $num ; s++ ))
53do
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"
90done
91
92finish
93
Note: See TracBrowser for help on using the repository browser.