#!/bin/bash # # osg.sh - a thin wrapper around gridmake that adds an offset # to the process number to obtain the job index. # max_retries=2 [ -r gridmake.xml ] || mv gridmake*.xml gridmake.xml [ -r gridmake ] || mv gridmake* gridmake if [ $# -lt 3 ]; then echo "Usage: osg.sh " exit 1 fi workdir=`pwd` if touch testfile; then rm testfile else echo "work directory $workdir is not writeable, cannot continue" exit 1 fi if [ "$X509_USER_PROXY" = "" ]; then X509_USER_PROXY=`ls x509*` if [ $? != 0 ]; then echo "X509_USER_PROXY is not defined, and no x509 file found!" exit 1 fi export X509_USER_PROXY fi homedir=`pwd` cd $workdir echo Free space left on work disk: `df -h $workdir` if [ ! -r gridmake ]; then cp $homedir/gridmake $homedir/gridmake.xml . fi jobno=`expr $1 + $2` chmod +x gridmake || exit 2 mv gridmake.xml gridmake.xml-orig sed "s/@@events to generate@@/$3/" gridmake.xml-orig >gridmake.xml || exit 3 retries=0 while [ $retries -lt $max_retries ]; do ./gridmake -srm -f gridmake.xml gxtwist_v001_${jobno}.root retcode=$? if [ $retcode != 0 ]; then rm -rf packages echo "sleeping for 2 minutes before retrying..." sleep 120 else break fi retries=`expr $retries + 1` done rm -f *.hddm *.root gridmake.xml* rm -f .srmput* exit $retcode