[535] | 1 | #!/bin/sh -xv |
---|
| 2 | AWK=/bin/awk |
---|
| 3 | SED=/bin/sed |
---|
| 4 | GREP=/bin/grep |
---|
| 5 | WC=/usr/bin/wc |
---|
| 6 | RM=/bin/rm |
---|
| 7 | CAT=/bin/cat |
---|
| 8 | TOUCH=/bin/touch |
---|
| 9 | DATE=/bin/date |
---|
| 10 | ECHO=/bin/echo |
---|
| 11 | LS=/bin/ls |
---|
| 12 | MKDIR=/bin/mkdir |
---|
| 13 | TR=/usr/bin/tr |
---|
| 14 | FIND=/usr/bin/find |
---|
| 15 | PRINTF=/usr/bin/printf |
---|
| 16 | XARGS=/usr/bin/xargs |
---|
| 17 | SORT=/bin/sort |
---|
| 18 | QSUB=qsub |
---|
| 19 | |
---|
| 20 | DefaultIFS=$' \t\n' |
---|
| 21 | IFS=$DefaultIFS |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | scriptName="`basename $0`" |
---|
| 25 | echo "Processing script ${scriptName} at `date`" |
---|
| 26 | |
---|
| 27 | #Process cmd line args: the -src option is mandatory (source name as Abell85) |
---|
[555] | 28 | #action: gain|mspec (gain: gain-like doucble median filtering |
---|
| 29 | # mspec: mean+sigma wo filetring) |
---|
[556] | 30 | action="-act gain" |
---|
[535] | 31 | sourceRadio= |
---|
| 32 | dateSelected= |
---|
| 33 | typeofproc= |
---|
| 34 | #first and last cycle to process |
---|
| 35 | # |
---|
| 36 | firstCycle= |
---|
| 37 | lastCycle= |
---|
| 38 | #use -sim option to simulate processing (debug the script as if...) |
---|
| 39 | simulationMode="" |
---|
| 40 | while [ $# -gt 0 ] |
---|
| 41 | do |
---|
| 42 | case "$1" in |
---|
[555] | 43 | -act) action="-act $2"; act=$2; shift;; |
---|
[535] | 44 | -src) sourceRadio="$2"; shift;; |
---|
| 45 | -date) dateSelected="-date $2"; dateJob="$2"; shift;; |
---|
| 46 | -type) typeofproc="-type $2"; type=$2; shift;; |
---|
| 47 | -fcycle) firstCycle="-fcycle $2"; fcycle="$2"; shift;; |
---|
| 48 | -lcycle) lastCycle="-lcycle $2"; lcycle="$2"; shift;; |
---|
| 49 | -sim) |
---|
| 50 | simulationMode="-sim On" |
---|
| 51 | $ECHO "INFO ${scriptName} running in SIMUL mode";; |
---|
| 52 | -h) |
---|
| 53 | echo >&2 \ |
---|
| 54 | "usage: $0 -src souce -date YYYYMMDD -type type [-fcycle firstCycle] [-lcycle lastCycle] [-sim to trig simulation mode]" |
---|
| 55 | exit 1;; |
---|
| 56 | *) break;; # terminate while loop |
---|
| 57 | esac |
---|
| 58 | shift |
---|
| 59 | done |
---|
| 60 | |
---|
| 61 | if [ "<${sourceRadio}>" = "<>" ]; then |
---|
| 62 | $ECHO "FATAL: You have forgotten to select the source option (-src)" |
---|
| 63 | exit 1 |
---|
| 64 | fi |
---|
| 65 | |
---|
| 66 | if [ "<${dateSelected}>" = "<>" ]; then |
---|
| 67 | $ECHO "FATAL: You have forgotten to select the date option (-date)" |
---|
| 68 | exit 1 |
---|
| 69 | fi |
---|
| 70 | |
---|
| 71 | if [ "<${typeofproc}>" = "<>" ]; then |
---|
| 72 | $ECHO "FATAL: You have forgotten to select the type option (-type)" |
---|
| 73 | exit 1 |
---|
| 74 | fi |
---|
| 75 | |
---|
| 76 | #Path to public backupable path |
---|
| 77 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
| 78 | #temporary files to synchronize scripts |
---|
| 79 | tmppublicpath=${TMPPUBLICPATH} |
---|
| 80 | #Path of the utility scripts |
---|
| 81 | scriptpath="/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay" |
---|
| 82 | #get the daq current irod status |
---|
[540] | 83 | #JEC 1/10/11 Use generic baodaqstatus name |
---|
| 84 | #### tag=`${DATE} +%F` |
---|
| 85 | OUT1=${publicpath}/baodaqstatus-current.txt |
---|
[535] | 86 | |
---|
| 87 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then |
---|
[540] | 88 | $ECHO "FATAL (${scriptName}): ${OUT1} has a problem" |
---|
| 89 | exit 1 |
---|
| 90 | #JEC 29/9/11 avoid finished stuff |
---|
| 91 | # $RM -f ${tmppublicpath}/statusdaq.finished |
---|
| 92 | # ${scriptpath}/statusdaq.sh > ${OUT1} |
---|
| 93 | # while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do |
---|
| 94 | # sleep 30 |
---|
| 95 | # done |
---|
| 96 | # $RM ${tmppublicpath}/statusdaq.finished |
---|
[535] | 97 | #protect against remove/rewriting |
---|
[540] | 98 | # $CHMOD -v 444 ${OUT1} |
---|
[535] | 99 | fi |
---|
| 100 | |
---|
| 101 | #assume 20 files/cycles cf. 30sec/cycle et 3sec par signal et fact 2 margin |
---|
| 102 | if [ "<${firstCycle}>" != "<>" -a "<${lastCycle}>" != "<>" ]; then |
---|
| 103 | jobBatchName="rawonoff-${sourceRadio}${dateJob}${type}-${fcycle}-${lcycle}" |
---|
| 104 | nFiles=`expr ${lcycle} - ${fcycle} + 1` |
---|
| 105 | nFiles=`expr ${nFiles} \* 20` |
---|
| 106 | else |
---|
| 107 | jobBatchName="rawonoff-${sourceRadio}${dateJob}${type}-All" |
---|
| 108 | #assume 30 cycles maxi! |
---|
[555] | 109 | nFiles=`expr 20 \* 30` |
---|
[535] | 110 | |
---|
| 111 | fi |
---|
| 112 | |
---|
| 113 | jobLogName="${jobBatchName}.log.$$" |
---|
| 114 | |
---|
| 115 | #Nbre de paquets utilises pour 1 spectre |
---|
| 116 | tspwin="5120" |
---|
| 117 | #calcul du scratch sachant que l'on nettoie apres chaque cycle |
---|
| 118 | nSpectra=`expr 20 \* 25600 / ${tspwin}` |
---|
| 119 | scratchSize=`expr 20 \* 500 + ${nSpectra} \* 200 / 1000 + 5` |
---|
| 120 | |
---|
| 121 | #le cpu total tient compte de l'emsemble des ficheirs a taiter |
---|
| 122 | cpu=`expr ${nFiles} \* 60 \* 50` |
---|
| 123 | |
---|
| 124 | qsub -l u_sps_baoradio,u_irods,T=${cpu},M=1000MB,scratch=${scratchSize}MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu campagne@lal.in2p3.fr <<EOF |
---|
[555] | 125 | /afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/proc_rawonoff.sh ${action} -src ${sourceRadio} ${dateSelected} ${typeofproc} ${firstCycle} ${lastCycle} ${simulationMode} |
---|
[535] | 126 | EOF |
---|