#!/bin/bash function usage() { echo "Usage: ./BHgen.bash [-o ] " echo " where is the index of the subset" echo " of events to simulate in this job. The output" echo " is written to BHgen_.hddm where" echo " is added to if it is given." exit 1 } nthreads=1 nevents=10 ftpserver="nod29.phys.uconn.edu" ftpdir="/Gluex/simulation/BHgen-5-2020" source setup_osg_debug.sh offset=0 process=none while [ $# -gt 0 ]; do if echo $1 | grep -q -- '-'; then if [ "$1" = "-o" ]; then offset=$2 shift; shift else usage fi else process=$1 break fi done if [ "$process" = "none" ]; then usage else process=`expr $process + $offset` fi random_sequence=`expr $process + 1` random_numbers=`awk '{if(NR=='$random_sequence'){print}}' randoms` echo Running process $process on `hostname -s` cp control.in0 control.in sed -i "s/^TRIG.*/TRIG $nevents/" control.in sed -i "s/^RNDM.*/RNDM $random_numbers/" control.in sed -i "s/^OUTF.*/OUTFILE 'BHgen.hddm'/" control.in hdgeant4 -t$nthreads retcode=$? if [ $retcode = 0 ]; then outfile=BHgen_$process.hddm mv BHgen.hddm $outfile srmuri=srm://grinch.phys.uconn.edu/Gluex/simulation/BHgen-5-2020 outfilepath=file://`pwd`/$outfile srmoptions="-2 -overwrite_mode=ALWAYS" echo "srmcp $srmoptions $outfilepath $srmuri/$outfile" srmcp $srmoptions $outfilepath $srmuri/$outfile && rm BHgen_$process.hddm #uberftp $ftpserver "cd $ftpdir; put BHgen_$process.hddm" && rm BHgen_$process.hddm [ -r BHgen_stats.astate ] && mv BHgen_stats.astate BHgen_$process.astate && rm -f BHgen_thread_*.astate rm control.in rm -f *.dlog else exit $retcode fi