| 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)
 | 
|---|
| 28 | #action: gain|mspec (gain: gain-like doucble median filtering
 | 
|---|
| 29 | #                   mspec: mean+sigma wo filetring)
 | 
|---|
| 30 | action="-act gain"
 | 
|---|
| 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 | #drift scan option
 | 
|---|
| 41 | drift="No"
 | 
|---|
| 42 | while [ $# -gt 0 ]
 | 
|---|
| 43 | do
 | 
|---|
| 44 |   case "$1" in
 | 
|---|
| 45 |       -act)  action="-act $2"; act=$2; shift;;
 | 
|---|
| 46 |       -src)  sourceRadio="$2"; shift;;
 | 
|---|
| 47 |       -date) dateSelected="-date $2"; dateJob="$2";     shift;;
 | 
|---|
| 48 |       -type) typeofproc="-type $2"; type=$2; shift;;
 | 
|---|
| 49 |       -fcycle) firstCycle="-fcycle $2"; fcycle="$2"; shift;;
 | 
|---|
| 50 |       -lcycle) lastCycle="-lcycle $2"; lcycle="$2"; shift;;
 | 
|---|
| 51 |       -drift) drift="Yes";;
 | 
|---|
| 52 |        -sim) 
 | 
|---|
| 53 |       simulationMode="-sim On"
 | 
|---|
| 54 |       $ECHO "INFO ${scriptName} running in SIMUL mode";;
 | 
|---|
| 55 |         -h)
 | 
|---|
| 56 |         echo >&2 \
 | 
|---|
| 57 |             "usage: $0 -src source -date YYYYMMDD -type type [-fcycle firstCycle] [-lcycle lastCycle] [-sim to trig simulation mode]"
 | 
|---|
| 58 |         exit 1;;
 | 
|---|
| 59 |         *)  break;;     # terminate while loop
 | 
|---|
| 60 |     esac
 | 
|---|
| 61 |     shift
 | 
|---|
| 62 | done
 | 
|---|
| 63 | 
 | 
|---|
| 64 | if [ "<${sourceRadio}>" = "<>" ]; then
 | 
|---|
| 65 |     $ECHO "FATAL: You have forgotten to select the source option (-src)"
 | 
|---|
| 66 |     exit 1
 | 
|---|
| 67 | fi
 | 
|---|
| 68 | 
 | 
|---|
| 69 | if [ "<${dateSelected}>" = "<>" ]; then
 | 
|---|
| 70 |     $ECHO "FATAL: You have forgotten to select the date option (-date)"
 | 
|---|
| 71 |     exit 1
 | 
|---|
| 72 | fi
 | 
|---|
| 73 | 
 | 
|---|
| 74 | if [ "<${typeofproc}>" = "<>" ]; then
 | 
|---|
| 75 |     $ECHO "FATAL: You have forgotten to select the type option (-type)"
 | 
|---|
| 76 |     exit 1
 | 
|---|
| 77 | fi
 | 
|---|
| 78 | 
 | 
|---|
| 79 | #Path to public backupable path
 | 
|---|
| 80 | publicpath="/afs/in2p3.fr/home/c/campagne/public"
 | 
|---|
| 81 | #temporary files to synchronize scripts
 | 
|---|
| 82 | tmppublicpath=${TMPPUBLICPATH}
 | 
|---|
| 83 | #Path of the utility scripts
 | 
|---|
| 84 | scriptpath=${SCRIPTPATH}
 | 
|---|
| 85 | #get the daq current irod status
 | 
|---|
| 86 | #JEC 1/10/11 Use generic baodaqstatus name 
 | 
|---|
| 87 | #### tag=`${DATE} +%F`
 | 
|---|
| 88 | OUT1=${publicpath}/baodaqstatus-current.txt
 | 
|---|
| 89 | 
 | 
|---|
| 90 | if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
 | 
|---|
| 91 |     $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
 | 
|---|
| 92 |     exit 1
 | 
|---|
| 93 | fi
 | 
|---|
| 94 | 
 | 
|---|
| 95 | #assume 2*10 files/cycles cf. 30sec/cycle et 3sec par signal et fact 2 margin
 | 
|---|
| 96 | # Test: assume for Abell1205, aout2011, 2*20 files
 | 
|---|
| 97 | if [ "<${type}>" = "<GAIN>" -o "<${type}>" = "<GAINDS>" ]; then
 | 
|---|
| 98 |     guessFiles=10
 | 
|---|
| 99 | elif [ "<$drift>" != "<Yes>" ]; then
 | 
|---|
| 100 |     guessFiles=40
 | 
|---|
| 101 | else
 | 
|---|
| 102 |     guessFiles=120
 | 
|---|
| 103 | fi
 | 
|---|
| 104 | 
 | 
|---|
| 105 | if [ "<${firstCycle}>" != "<>" -a "<${lastCycle}>" != "<>" ]; then
 | 
|---|
| 106 |     jobBatchName="procspecmfib-${sourceRadio}${dateJob}${type}-${fcycle}-${lcycle}"
 | 
|---|
| 107 |     nFiles=`expr ${lcycle} - ${fcycle} + 1`
 | 
|---|
| 108 |     nFiles=`expr ${nFiles} \* ${guessFiles}`
 | 
|---|
| 109 | else
 | 
|---|
| 110 |     jobBatchName="procspecmfib-${sourceRadio}${dateJob}${type}-All"
 | 
|---|
| 111 |     #assume 20 cycles maxi!
 | 
|---|
| 112 |     nFiles=`expr ${guessFiles} \* 20`
 | 
|---|
| 113 | 
 | 
|---|
| 114 | fi
 | 
|---|
| 115 | 
 | 
|---|
| 116 | jobLogName="${jobBatchName}.log.$$"
 | 
|---|
| 117 | 
 | 
|---|
| 118 | #Nbre de paquets utilises pour 1 spectre
 | 
|---|
| 119 | tspwin="5120"
 | 
|---|
| 120 | #calcul du scratch sachant que l'on nettoie apres chaque cycle
 | 
|---|
| 121 | nSpectra=`expr ${guessFiles} \* 25600 /  ${tspwin}`
 | 
|---|
| 122 | scratchSize=`expr  ${guessFiles} \* 500 + ${nSpectra} \* 200 / 1000 + 5`
 | 
|---|
| 123 | 
 | 
|---|
| 124 | #le cpu total tient compte de l'emsemble des ficheirs a traiter
 | 
|---|
| 125 | #cpu=`expr ${nFiles} \* 60 \* 50`  # BQS estimation
 | 
|---|
| 126 | cpu=`expr ${nFiles} \* 60`
 | 
|---|
| 127 | 
 | 
|---|
| 128 | qsub -P P_baoradio -l sps=1,irods=1,ct=${cpu},vmem=1000M,fsize=${scratchSize}M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 | 
|---|
| 129 | 
 | 
|---|
| 130 | ${SCRIPTPATH}/proc_specmfib.sh ${action} -src ${sourceRadio} ${dateSelected} ${typeofproc} ${firstCycle} ${lastCycle} ${simulationMode}
 | 
|---|
| 131 | EOF
 | 
|---|