#!/bin/sh

Usage() {
    echo "KVsubmit ngsite release [patch] [dbrelease]"
    echo "Examples: KVsubmit siri 14.5.1"
    echo "          KVsubmit grid.uio.no 14.5.1 2"
    echo "          KVsubmit grid.uio.no 14.2.25 7 6.4.2"
}    

if test -z $2;
then
    Usage
    exit 1
fi

if [ \$1 == '-h' ]
then
    Usage
    exit
fi

if test -z $3;
then
    rte=$2
else
    rte="$2.$3"
fi
jname=$rte
args="$2 $3"

if ! test -z $4;
then
   dbrel=$4
   jname=$jname-$dbrel
   args="$2 $3 $4"
fi


cat > tmp.xrsl << EOF
&(executable=KVtest.sh)
   (inputfiles=(KVtest.sh http://www-f9.ijs.si/atlas/grid/script/KVtest.sh))

   (* The "-d" triggers storage of the detailed results. *)
   (arguments=$args)
   (outputfiles=(kitval_results.tgz ""))

   (stdout=KitValidation.log) 
   (join=yes) 
   (gridtime="240 minutes")
   (jobname=KVtest-$jname)
   (gmlog=log)

   (runTimeEnvironment=APPS/HEP/ATLAS-$rte)

   (* 800 is requested as of 10.02.2005 *)
   (memory=2000)

   (* Need more space if storing results *)
   (disk=1200)
EOF
cat tmp.xrsl
ngsub -c $1 -f tmp.xrsl
rm tmp.xrsl