Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:18

0001 #! /bin/bash
0002 
0003 # $1 : CMSSW config file
0004 # $2 : output directory
0005 # $3 : output DQM directory (optional but recommended)
0006 source /afs/cern.ch/cms/caf/setup.sh
0007 curdir="$(pwd)"
0008 #workdir="/afs/cern.ch/cms/CAF/CMSALCA/ALCA_TRACKERALIGN/HIP/bonato/DEVEL/HIPWorkflow/CMSSW_3_2_4/src/"
0009 workdir="<MYCMSSW>"
0010 dqmdir="MICKEY"
0011 
0012 if [ $# == 3 ]
0013 then 
0014 dqmdir="$3"
0015 else
0016 dqmdir="${curdir}/MONITORING/DQM/"
0017 fi
0018 
0019 
0020 # set up the CMS environment (choose your release and working area):
0021 echo Setting up CMSSW environment in $workdir
0022 cd $workdir
0023 eval `scramv1 runtime -sh`
0024 #export STAGE_SVCCLASS=cmscafuser
0025 cd $curdir
0026 
0027 #prepare log files
0028 rfcp $1 /castor/cern.ch/cms/$2/logfiles/
0029 BASE_JOBNAME=$(basename "$1" .py)
0030 LOGFILE="${BASE_JOBNAME}.log"
0031 OUTFILE="${BASE_JOBNAME}.out"
0032 echo "Running the prescaling in $curdir..."
0033 echo "Logfile in $LOGFILE"
0034 
0035 #do the thing
0036 time cmsRun $1 &> $LOGFILE
0037 echo ""
0038 echo "---------"
0039 echo "File list in $(pwd): "
0040 ls -lh 
0041 echo "---------"
0042 echo ""
0043 echo ""
0044 echo "Copying to /castor/cern.ch/cms/$2" 
0045 # copy files to their final destination
0046 #export STAGE_SVCCLASS=cmscafuser
0047 
0048 STATUScp=0
0049 for outROOT in $( ls  ALCA*resc*.root )
0050 do
0051 cmsStageOut $outROOT "$2/"
0052 
0053 if [ $? -ne 0 ]
0054 then
0055 echo "Error in copying the .root file to CASTOR !"
0056 fi
0057 let STATUScp=$STATUScp+$?
0058 done
0059 echo "Copying to /castor/cern.ch/cms/$2/logfiles/" 
0060 STATUScp=0
0061 for outLOG in $( ls  *.out )
0062 do
0063 cp $outLOG "${dqmdir}/../logfiles/"
0064 let STATUScp=$STATUScp+$?
0065 cmsStageOut $outLOG "$2/"
0066 let STATUScp=$STATUScp+$?
0067 done
0068 
0069 for outLOG in $( ls  *.log )
0070 do
0071 cmsStageOut $outLOG "$2/"
0072 let STATUScp=$STATUScp+$?
0073 cp $outLOG "${dqmdir}/../logfiles/"
0074 let STATUScp=$STATUScp+$?
0075 
0076 if [ $STATUcp -ne 0 ]
0077 then
0078 echo "Error in copying the .log file to CASTOR !"
0079 fi
0080 done
0081 
0082 
0083 
0084 
0085 if [ $STATUScp -ne 0 ]
0086 then
0087 echo "Error in copying the logfiles (status=${STATUScp})! Parallel job $1" > tmpmess.txt
0088 echo >> tmpmess.txt
0089 echo >> tmpmess.txt
0090 cat tmpmess.txt |  mail -s "--- ERROR in copying files during ALCAPrescale!  ---" ${USER}@mail.cern.ch
0091 fi
0092 
0093 
0094 ### Clean up
0095 rm -f  *.root
0096 rm -f *.log
0097 rm -f *.out
0098 
0099 for logfile in $( ls ${curdir}/MONITORING/logfiles/*.log ) 
0100 do
0101 gzip  $logfile
0102 rm -f $logfile
0103 done