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 - 07/03/22 - A version of the batch submission script that is intended to run on the JLab iFarm
0004 # This script creates batch job files and submits them, these jobs run the Process_EIC.csh script
0005 
0006 # This has been tested and works successfully
0007 
0008 echo "Running as ${USER}" # Checks who you're running this as
0009 
0010 # If 7 or 8 arguments not given, complain
0011 if [[ "$#" -ne 7 && "$#" -ne 8 ]]; then
0012     echo ""
0013     echo "!!! ERROR !!! - Expected 7 or 8 arguments - !!! ERROR !!!"
0014     echo "Expect - NumFiles NumEvents EBeamE HBeamE OutputType InteractionPoint Ejectile RecoilHadron(optional)"
0015     echo "See the Config_EIC.json file or the README for options and try again, exiting"
0016     echo "!!! ERROR !!! - Expected 7 or 8 arguments - !!! ERROR !!!"
0017     echo ""
0018     exit 0
0019 fi
0020 
0021 # Set variables equal to arguments provided
0022 NumFiles=$1
0023 NumEvents=$2
0024 EBeamE=$3
0025 HBeamE=$4
0026 OutputType=$5
0027 InteractionPoint=$6
0028 Ejectile=$7
0029 
0030 # If K+ specified, check the 8th argument, expect this to exist for K+, if it does NOT (case 1), set a default
0031 if [[ $Ejectile == "K+" && -z "$8" ]]; then
0032     echo "!!! WARNING !!! - For K+ production expect a hadron specified, defaulting to Lambda - !!! WARNING !!!"
0033     RecoilHadron="Lambda"
0034 elif [[ $Ejectile == "K+" && ! -z "$8" ]]; then # If 8th argument is not a blank string (i.e. it exists), set the RecoilHadron to this
0035     RecoilHadron=$8
0036 else # Any other case (non K+), set RecoilHadron to be a blank string. We don't actually care for Pi+, Pi0 production etc.
0037     RecoilHadron=""
0038 fi
0039 
0040 Workflow="EIC_DEMPGen_${USER}" # Change this as desired
0041 
0042 while true; do
0043     read -p "Do you wish to begin a new batch submission? (Please answer yes or no) " yn
0044     case $yn in
0045         [Yy]* )
0046             i=1
0047             (
0048                 while [[ $i -le $NumFiles ]]; do
0049                     # This is the name of the job submission script the shell script creates
0050                     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
0051                     echo "Running ${batch} for file ${i}"
0052                     cp /dev/null ${batch}
0053                     RandomSeed=$(od -An -N3 -i /dev/urandom)
0054                     echo "PROJECT: c-kaonlt"  >> ${batch} # Is eic a valid project?
0055                     echo "TRACK: analysis" >> ${batch}
0056                     echo "JOBNAME: DEMPGen_${EBeamE}on${HBeamE}_${Ejectile}${RecoilHadron}_${InteractionPoint}_${NumEvents}_${i}" >> ${batch}
0057                     echo "MEMORY: 2000 MB" >> ${batch} # Request 2GB RAM - probably too much
0058                     echo "CPU: 1" >> ${batch} # Request 1 CPU core per job
0059                     echo "COMMAND:/group/eic/users/${USER}/DEMPGen/Process_EIC_iFarm.csh ${i} ${NumEvents} ${EBeamE} ${HBeamE} ${RandomSeed} ${OutputType} ${InteractionPoint} ${Ejectile} ${RecoilHadron}" >> ${batch}
0060                     echo "MAIL: ${USER}@jlab.org" >> ${batch}
0061                     echo "Submitting batch"
0062                     eval "swif2 add-jsub ${Workflow} -script ${batch} 2>/dev/null" # Swif2 job submission, uses old jsub scripts
0063                     echo " "
0064                     i=$(( $i + 1 ))
0065                     sleep 2
0066                     rm ${batch}
0067                     if [ $i -gt $NumFiles ]; then
0068                         echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
0069                         echo " "
0070                         echo "###############################################################################################################"
0071                         echo "############################################ END OF JOB SUBMISSIONS ###########################################"
0072                         echo "###############################################################################################################"
0073                         echo " "
0074                     fi
0075                 done
0076             )
0077             eval 'swif2 run ${Workflow}'
0078             break;;
0079         [Nn]* ) 
0080             exit;;
0081         * ) echo "Please answer yes or no.";;
0082     esac
0083 done
0084