Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-17 09:02:54

0001 #! /bin/bash                            
0002                                                                             
0003 # SJDK - 09/02/22 - An updated version of the batch submission script. This script is designed for the torque queueing system on Lark at the University of Regina. However, it could quickly be adapted for use on the JLab iFarm for example.
0004 # This script creates batch job files and submits them, these jobs run the Process_EIC.csh script
0005 
0006 echo "Running as ${USER}" # Checks who you're running this as
0007 # If output directory for .out/.err files doesn't exist, make it
0008 if [ ! -d  "/home/${USER}/trq_output" ]; then
0009     echo "/home/${USER}/trq_output directory doesn't exist, making this directory for you..."
0010     mkdir "/home/${USER}/trq_output"
0011     echo "Directory created, check there for output and error logs from your job."
0012 fi
0013 # If 7 or 8 arguments not given, complain
0014 if [[ "$#" -ne 7 && "$#" -ne 8 ]]; then
0015     echo ""
0016     echo "!!! ERROR !!! - Expected 7 or 8 arguments - !!! ERROR !!!"
0017     echo "Expect - NumFiles NumEvents EBeamE HBeamE OutputType InteractionPoint Ejectile RecoilHadron(optional)"
0018     echo "See the Config_EIC.json file or the README for options and try again, exiting"
0019     echo "!!! ERROR !!! - Expected 7 or 8 arguments - !!! ERROR !!!"
0020     echo ""
0021     exit 0
0022 fi
0023 
0024 # Set variables equal to arguments provided
0025 NumFiles=$1
0026 NumEvents=$2
0027 EBeamE=$3
0028 HBeamE=$4
0029 OutputType=$5
0030 InteractionPoint=$6
0031 Ejectile=$7
0032 
0033 # If K+ specified, check the 8th argument, expect this to exist for K+, if it does NOT (case 1), set a default
0034 if [[ $Ejectile == "K+" && -z "$8" ]]; then
0035     echo "!!! WARNING !!! - For K+ production expect a hadron specified, defaulting to Lambda - !!! WARNING !!!"
0036     RecoilHadron="Lambda"
0037 elif [[ $Ejectile == "K+" && ! -z "$8" ]]; then # If 8th argument is not a blank string (i.e. it exists), set the RecoilHadron to this
0038     RecoilHadron=$8
0039 else # Any other case (non K+), set RecoilHadron to be a blank string. We don't actually care for Pi+, Pi0 production etc.
0040     RecoilHadron=""
0041 fi
0042 
0043 i=1
0044 while [[ $i -le $NumFiles ]]; do
0045     # This is the name of the job submission script the shell script creates
0046     batch="${USER}_EICDempGen_${EBeamE}on${HBeamE}_${Ejectile}${RecoilHadron}_${InteractionPoint}_${NumEvents}_${i}_Job.txt" # The name of the job submission script it'll create each time
0047     echo "Running ${batch} for file ${i}"
0048     cp /dev/null ${batch}
0049     RandomSeed=$(od -An -N3 -i /dev/urandom)
0050     echo "#!/bin/csh" >> ${batch} # Tells your job which shell to run in
0051     echo "#PBS -N DEMPGen_${EBeamE}on${HBeamE}_${Ejectile}${RecoilHadron}_${InteractionPoint}_${NumEvents}_${i}" >> ${batch} # Name your job                     
0052     echo "#PBS -m abe" >> ${batch} # Email you on job start, end or error
0053     #echo "#PBS -M ${USER}@jlab.org" >>${batch} # Your email address, change it to be what you like
0054     echo "#PBS -r n" >> ${batch} # Don't re-run if it crashes
0055     echo "#PBS -o  /home/${USER}/trq_output/${EBeamE}on${HBeamE}_${Ejectile}${RecoilHadron}_${InteractionPoint}_${NumEvents}_${i}.out" >> ${batch} # Output directory and file name, set to what you like
0056     echo "#PBS -e  /home/${USER}/trq_output/${EBeamE}on${HBeamE}_${Ejectile}${RecoilHadron}_${InteractionPoint}_${NumEvents}_${i}.err" >> ${batch} # Error output directory and file name
0057     echo "date" >> ${batch} 
0058     echo "cd /home/apps/DEMPgen/" >> ${batch} # Tell your job to go to the directory with the script you want to run
0059     echo "./Process_EIC.csh ${i} ${NumEvents} ${EBeamE} ${HBeamE} ${RandomSeed} ${OutputType} ${InteractionPoint} ${Ejectile} ${RecoilHadron}" >> ${batch} # Run your script, change this to what you like
0060     echo "date">>${batch}
0061     echo "exit">>${batch} # End of your job script
0062     echo "Submitting batch"
0063     eval "qsub ${batch} 2>/dev/null" # Use qsub to actually submit your job
0064     echo " "
0065     i=$(( $i + 1 ))
0066     sleep 2
0067     rm ${batch}
0068 done
0069