#!/bin/sh -xv

#Process cmd line args: the -src option is mandatory (source name as Abell85)
sourceRadio=
#use -sim option to simulate processing (debug the script as if...)
simulationMode=""
while [ $# -gt 0 ]
do
  case "$1" in
      -src)  sourceRadio=$2; shift;;
      -sim) simulationMode="-sim";;
	-h)
	    echo >&2 \
	    "usage: $0 -src souce [-sim]"
	    exit 1;;
	*)  break;;	# terminate while loop
    esac
    shift
done

jobBatchName="gains-$sourceRadio"
jobLogName="${jobBatchName}.log.$$"

qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=500M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF

${SCRIPTPATH}/gainmaker.sh  -src ${sourceRadio} ${simulationMode}
EOF
