Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-15 04:21:42

0001 #!/bin/bash
0002 
0003 #script to run generic lhe generation tarballs
0004 #kept as simply as possible to minimize need
0005 #to update the cmssw release
0006 #(all the logic goes in the run script inside the tarball
0007 # on frontier)
0008 #J.Bendavid
0009 
0010 #exit on first error
0011 set -e
0012 
0013 echo "   ______________________________________     "
0014 echo "         Running Generic Tarball/Gridpack     "
0015 echo "   ______________________________________     "
0016 
0017 path=${1}
0018 echo "gridpack tarball path = $path"
0019 
0020 nevt=${2}
0021 echo "%MSG-MG5 number of events requested = $nevt"
0022 
0023 rnum=${3}
0024 echo "%MSG-MG5 random seed used for the run = $rnum"
0025 
0026 ncpu=${4}
0027 echo "%MSG-MG5 thread count requested = $ncpu"
0028 
0029 echo "%MSG-MG5 residual/optional arguments = ${@:5}"
0030 
0031 if [ -n "${5}" ]; then
0032   use_gridpack_env=${5}
0033   echo "%MSG-MG5 use_gridpack_env = $use_gridpack_env"
0034 fi
0035 
0036 if [ -n "${6}" ]; then
0037   scram_arch_version=${6}
0038   echo "%MSG-MG5 override scram_arch_version = $scram_arch_version"
0039 fi
0040 
0041 if [ -n "${7}" ]; then
0042   cmssw_version=${7}
0043   echo "%MSG-MG5 override cmssw_version = $cmssw_version"
0044 fi
0045 
0046 LHEWORKDIR=`pwd`
0047 
0048 if [ "$use_gridpack_env" = false -a -n "$scram_arch_version" -a -n  "$cmssw_version" ]; then
0049   echo "%MSG-MG5 CMSSW version = $cmssw_version"
0050   export SCRAM_ARCH=${scram_arch_version}
0051   scramv1 project CMSSW ${cmssw_version}
0052   cd ${cmssw_version}/src
0053   eval `scramv1 runtime -sh`
0054   cd $LHEWORKDIR
0055 fi
0056 
0057 if [[ -d lheevent ]]
0058     then
0059     echo 'lheevent directory found'
0060     echo 'Setting up the environment'
0061     rm -rf lheevent
0062 fi
0063 mkdir lheevent; cd lheevent
0064 
0065 #untar the tarball directly from cvmfs
0066 tar -xaf ${path} 
0067 
0068 # If TMPDIR is unset, set it to the condor scratch area if present
0069 # and fallback to /tmp
0070 export TMPDIR=${TMPDIR:-${_CONDOR_SCRATCH_DIR:-/tmp}}
0071 
0072 # define singularity
0073 if [ "$use_gridpack_env" != false ]; then
0074     if [ -n "$scram_arch_version" ]; then
0075         sing=$(echo ${scram_arch_version} | sed -E 's/^[^0-9]*([0-9]{1,2}).*/\1/')
0076     elif egrep -q "scram_arch_version=[^$]" runcmsgrid.sh; then
0077         sing=$(grep "scram_arch_version=[^$]" runcmsgrid.sh | sed -E 's/^[^0-9]*([0-9]{1,2}).*/\1/')
0078     fi
0079     if [ -n "${sing}" ]; then
0080         sing="cmssw-el"${sing}" --"
0081     fi
0082 fi
0083 
0084 #generate events
0085 ${sing} ./runcmsgrid.sh $nevt $rnum $ncpu ${@:5}
0086 
0087 mv cmsgrid_final.lhe $LHEWORKDIR/
0088 
0089 cd $LHEWORKDIR
0090 
0091 #cleanup working directory (save space on worker node for edm output)
0092 rm -rf lheevent
0093 
0094 exit 0
0095