#! /bin/sh

makeRSL()
{
    if [ -z "$1" ]; then
	sleeptime=0
    else
	sleeptime=$1
    fi
    pwd=`/bin/pwd`

    cat <<EOF
+
(&(resourceManagerContact="${GRAMCONTACT}")
  (label="subjob 1") 
  (directory=${pwd})
  (count=1)
  (executable=duroctestruntime)
  (stdout=out.1)
)
(&(resourceManagerContact="${GRAMCONTACT}")
  (label="subjob 2")
  (directory=${pwd})
  (count=1)
  (executable=duroctestruntime)
  (arguments=${sleeptime})
  (stdout=out.2)
)
EOF
}

if [ $# -eq 0 ]; then
    echo "provide argument <seconds to delay subjob before it checks in>"
    exit 1
fi
if [ -z "$GRAMCONTACT" ]; then
    GRAMCONTACT="pitcairn.mcs.anl.gov"
fi

rm -f rsl out.1 out.2
makeRSL $@ > rsl

./durocrun rsl
