source: BAORadio/AmasNancay/trunk/submit2bqs-procspecmfib.sh @ 575

Last change on this file since 575 was 575, checked in by campagne, 13 years ago

introduce SCRIPTPATH environment variable (jec)

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1#!/bin/sh -xv
2AWK=/bin/awk
3SED=/bin/sed
4GREP=/bin/grep
5WC=/usr/bin/wc
6RM=/bin/rm
7CAT=/bin/cat
8TOUCH=/bin/touch
9DATE=/bin/date
10ECHO=/bin/echo
11LS=/bin/ls
12MKDIR=/bin/mkdir
13TR=/usr/bin/tr
14FIND=/usr/bin/find
15PRINTF=/usr/bin/printf
16XARGS=/usr/bin/xargs
17SORT=/bin/sort
18QSUB=qsub
19
20DefaultIFS=$' \t\n'
21IFS=$DefaultIFS
22
23
24scriptName="`basename $0`"
25echo "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)
30action="-act gain"
31sourceRadio=
32dateSelected=
33typeofproc=
34#first and last cycle to process
35#
36firstCycle=
37lastCycle=
38#use -sim option to simulate processing (debug the script as if...)
39simulationMode=""
40while [ $# -gt 0 ]
41do
42  case "$1" in
43      -act)  action="-act $2"; act=$2; shift;;
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
59done
60
61if [ "<${sourceRadio}>" = "<>" ]; then
62    $ECHO "FATAL: You have forgotten to select the source option (-src)"
63    exit 1
64fi
65
66if [ "<${dateSelected}>" = "<>" ]; then
67    $ECHO "FATAL: You have forgotten to select the date option (-date)"
68    exit 1
69fi
70
71if [ "<${typeofproc}>" = "<>" ]; then
72    $ECHO "FATAL: You have forgotten to select the type option (-type)"
73    exit 1
74fi
75
76#Path to public backupable path
77publicpath="/afs/in2p3.fr/home/c/campagne/public"
78#temporary files to synchronize scripts
79tmppublicpath=${TMPPUBLICPATH}
80#Path of the utility scripts
81scriptpath=${SCRIPTPATH}
82#get the daq current irod status
83#JEC 1/10/11 Use generic baodaqstatus name
84#### tag=`${DATE} +%F`
85OUT1=${publicpath}/baodaqstatus-current.txt
86
87if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
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
97#protect against remove/rewriting   
98#    $CHMOD -v 444 ${OUT1}
99fi
100
101#assume 20 files/cycles cf. 30sec/cycle et 3sec par signal et fact 2 margin
102if [ "<${firstCycle}>" != "<>" -a "<${lastCycle}>" != "<>" ]; then
103    jobBatchName="procspecmfib-${sourceRadio}${dateJob}${type}-${fcycle}-${lcycle}"
104    nFiles=`expr ${lcycle} - ${fcycle} + 1`
105    nFiles=`expr ${nFiles} \* 20`
106else
107    jobBatchName="procspecmfib-${sourceRadio}${dateJob}${type}-All"
108    #assume 30 cycles maxi!
109    nFiles=`expr 20 \* 30`
110
111fi
112
113jobLogName="${jobBatchName}.log.$$"
114
115#Nbre de paquets utilises pour 1 spectre
116tspwin="5120"
117#calcul du scratch sachant que l'on nettoie apres chaque cycle
118nSpectra=`expr 20 \* 25600 /  ${tspwin}`
119scratchSize=`expr  20 \* 500 + ${nSpectra} \* 200 / 1000 + 5`
120
121#le cpu total tient compte de l'emsemble des ficheirs a taiter
122cpu=`expr ${nFiles} \* 60 \* 50`
123
124qsub -l u_sps_baoradio,u_irods,T=${cpu},M=1000MB,scratch=${scratchSize}MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
125/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/proc_specmfib.sh ${action} -src ${sourceRadio} ${dateSelected} ${typeofproc} ${firstCycle} ${lastCycle} ${simulationMode}
126EOF
Note: See TracBrowser for help on using the repository browser.