File indexing completed on 2025-01-18 10:18:31
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 SimDir="/group/eic/users/${USER}/ePIC/"
0011 echo "Running as ${USER}"
0012 echo "Assuming simulation directory - ${SimDir}"
0013 if [ ! -d $SimDir ]; then
0014 echo "!!! WARNING !!!"
0015 echo "!!! $SimDir - Does not exist - Double check pathing and try again !!!"
0016 echo "!!! WARNNING !!!"
0017 exit 1
0018 fi
0019
0020 NumFiles=$1
0021 if [[ -z "$1" ]]; then
0022 echo "I need a number of files to run!"
0023 echo "Please provide a number of files to run as the first argument"
0024 exit 2
0025 fi
0026 NumEvents=$2
0027 if [[ -z "$2" ]]; then
0028 echo "I need a number of events to generate per file!"
0029 echo "Please provide a number of event to generate per file as the second argument"
0030 exit 3
0031 fi
0032
0033 if [[ -z "$3" ]]; then
0034 Arg3=10
0035 echo "Arg3 not specified, defaulting to 10"
0036 fi
0037
0038
0039 if [[ -z "$4" ]]; then
0040 Arg4=10
0041 echo "Arg4 not specified, defaulting to 10"
0042 fi
0043
0044
0045 echo; echo; echo "!!!!! NOTICE !!!!!"; echo "For now, the outputs generated by jobs from this script will go to a directory under /volatile, change this if you want to keep the files for longer!"; echo "!!!!! NOTICE !!!!!"; echo; echo;
0046 if [ ! -d "/volatile/eic/${USER}" ]; then
0047 read -p "It looks like you don't have a directory in /volatile/eic, make one? <Y/N> " prompt
0048 if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
0049 echo "Making a directory for you in /volatile/eic"
0050 mkdir "/volatile/eic/${USER}"
0051 else
0052 echo "If I don't make the directory, I won't have anywhere to output files!"
0053 echo "Ending here, modify the script and change the directories/paths if you actually want to run this script!"
0054 exit 4
0055 fi
0056 fi
0057
0058 OutputPath="/volatile/eic/${USER}"
0059 if [ ! -d $OutputPath ]; then
0060 echo "It looks like the output path doesn't exist."
0061 echo "The script thinks this should be - ${OutputPath}"
0062 read -p "Make this directory? <Y/N> " prompt2
0063 if [[ $prompt2 == "y" || $prompt2 == "Y" || $prompt2 == "yes" || $prompt2 == "Yes" ]]; then
0064 echo "Making directory - ${OutputPath}"
0065 mkdir $OutputPath
0066 else
0067 echo "If I don't make the directory, I won't have anywhere to output files!"
0068 echo "Ending here, modify the script and change the directories/paths if you actually want to run this script!"
0069 exit 5
0070 fi
0071 fi
0072
0073 Timestamp=$(date +'%d_%m_%Y')
0074 Workflow="ePIC_Sim_${USER}_${Timestamp}"
0075 export EICSHELL=${SimDir}/eic-shell
0076
0077 Disk_Space=$(( (($NumEvents +(5000/2) ) /5000) +1 ))
0078 for (( i=1; i<=$NumFiles; i++ ))
0079 do
0080 Output_tmp="$OutputPath/Sim_${i}_${NumEvents}_${Arg3/./p}_${Arg4/./p}"
0081 if [ ! -d "${Output_tmp}" ]; then
0082 mkdir $Output_tmp
0083 else
0084 if [ "$(ls -A $Output_tmp)" ]; then
0085 echo "!!!!! Warning, ${Output_tmp} directory exists and is not empty! Files may be overwritten! !!!!!"
0086 fi
0087 fi
0088 batch="${SimDir}/Sim_${i}_${NumEvents}_${Arg3}_${Arg4}.txt"
0089 echo "Running ${batch}"
0090 cp /dev/null ${batch}
0091 echo "PROJECT: eic" >> ${batch}
0092 echo "TRACK: analysis" >> ${batch}
0093 echo "JOBNAME: ePIC_Sim_${i}_${NumEvents}_${Arg3}_${Arg4}" >> ${batch}
0094 if [[ $NumEvents -ge 15000 ]]; then
0095 echo "MEMORY: 6000 MB" >> ${batch}
0096 else
0097 echo "MEMORY: 4000 MB" >> ${batch}
0098 fi
0099 echo "DISK_SPACE: ${Disk_Space} GB" >> ${batch}
0100 echo "CPU: 1" >> ${batch}
0101 echo "TIME: 1440" >> ${batch}
0102
0103 echo "COMMAND:${SimDir}/JLab_Farming_Job.sh ${i} ${NumEvents} ${Arg3} ${Arg4}" >> ${batch}
0104 echo "MAIL: ${USER}@jlab.org" >> ${batch}
0105 echo "Submitting batch job"
0106 eval "swif2 add-jsub ${Workflow} -script ${batch} 2>/dev/null"
0107 echo " "
0108 sleep 2
0109 rm ${batch}
0110 done
0111
0112 eval 'swif2 run ${Workflow}'
0113
0114 exit 0