3 # Submission script for GridEngine (GE). Each job will
4 # be executed via the jobScript.sh
5 # This jobScript supports up to 7 parameters. Edit
6 # the user specific part of the script according to
9 # Input to the script is a filelist with 1 file per line.
10 # For each file a job is started. With the parameter
11 # nFilesPerJob a comma separated filelist will be
12 # generated and handed to the job script. This feature
13 # is usefull when running many small jobs. Each
14 # job has its own logfile. All needed directories for the
15 # logfiles will be created if non existing.
17 # IMPORTANT: the hera/prometheus cluster jobs will only
18 # see the /hera file system. All needed scripts, programs
19 # and parameters have to be located on /hera or the job
20 # will crash. This script syncs your working dir to the submission
21 # dir on /hera . Make sure your scripts use the submission dir!
22 # Software should be taken from /cvmfs/hades.gsi.de/install/
24 # job log files will be named like inputfiles. If nFilesPerJob > 1
25 # the log files will contain the partnumber.
27 ######################################################################
34 currentDir=$(pwd | xargs -i basename {})
35 currentDir=../$currentDir
37 part=no_enhancement_gcalor
38 #part=minbias no_enhancement_gcalor
39 # p,d,pi-,pi+,lambda,K-,K+,K0S,phiKK,Xi-,w,phi,rho0,pi0,D+,wdalitz
41 # pi0 1*10e6 1-10000 0 1-10000 o o
42 # eta 1*10e6 1-10000 0 1-10000 o o
43 # w 1*10e6 1-10000 0 1-10000 o o
44 # phi 1*10e6 1-10000 10000 10001-20000 o o
45 # rho0 2*10e6 1-20000 20000 20001-40000 o o
46 # wdalitz 3*10e6 1-30000 40000 40001-70000 o o
47 # D+ 3*10e6 1-30000 70000 70001-100000 o o
50 # no_enhancement_gcalor 100*10^6 o o
57 # K0S 50*10^6 evts o o
58 # lambda 100*10^6 evts o o
59 # Xi- 10*10^6 evts o o
60 # phiKK 10*10^6 evts o o
68 submmissionbase=/lustre/nyx/hades/user/${user}/sub/apr12/gen8a/${part}
69 submissiondir=${submmissionbase}/dst
70 nFilesPerJob=50 # number of files to be analyzed by 1 job (default==1)
71 jobscript=${submissiondir}/jobScript_SL.sh # exec script (full path, call without dot, set it executable!)
72 outputdir=/lustre/nyx/hades/dstsim/apr12/gen8a/test/${part} # outputdir for files AND logFiles
73 pathoutputlog=${outputdir}/out # protocol from batch farm for each file
74 filename=testrun # filename of log file if nFilesPerJob > 1 (partnumber will be appended)
75 par1=/cvmfs/hades.gsi.de/install/5.34.34/hydra2-4.9m/defall.sh # gen8a optional par1 : environment script
76 par2=${submissiondir}/analysisDST # optional par2 : executable
77 par3="" # optional par3 : input file list
78 par4=${outputdir} # optional par4 : outputfile (part number will be appended (_num.root))
79 par5=100000 # optional par5 : number of events
80 par6="no" # optional par6
81 par7="no" # optional par7
82 resources="--mem=2000 --time=0-5:00:00" # runtime < 10h, mem < 2GB
84 jobarrayFile="gen8_${part}_jobarray.dat"
86 filelist=${currentDir}/all_files_${part}_${npart}files.list # file list in local dir! not in submissiondir!!!
88 createList=no # (yes/no) use this to create files list with generic names (for simulation, testing)
89 # use "no" if you have a filelist available
90 createJobarray=yes # create jobarry if yes
91 ######################################################################
94 #---------------------------------------------------------------------
95 # create a file list for submission (simulation, testing etc.)
96 # for real data you will have a filelist with real filenames
97 if [ "$createList" == "yes" ]
101 echo "===> REMOVING EXISTING FILELIST : $filelist"
105 echo "===> CREATE FILELIST : $filelist"
106 for ((ct=1;ct<=$nFiles;ct++))
108 echo /hera/hades/dstsim/apr12/hgeant/bmax9/Au_Au_1230MeV_omega_lambda_1000evts_${ct}_1.root >> $filelist
111 #---------------------------------------------------------------------
115 nFiles=$( cat $filelist | wc -l)
117 #---------------------------------------------------------------------
119 if [ ! -d $submmissionbase ]
121 echo "===> CREATE SUBMISSIONBASEDIR : $submmissionbase"
122 mkdir -p $submmissionbase
124 echo "===> USE SUBMISSIONBASEDIR : $submmissionbase"
127 #---------------------------------------------------------------------
131 if [ ! -d $outputdir ]
133 echo "===> CREATE OUTPUTDIR : $outputdir"
136 echo "===> USE OUTPUTDIR : $outputdir"
139 if [ ! -d $outputdir/root ]
141 mkdir -p $outputdir/root
144 if [ ! -d $outputdir/qa ]
146 mkdir -p $outputdir/qa
149 if [ ! -d $pathoutputlog ]
151 echo "===> CREATE LOGDIR : $pathoutputlog"
152 mkdir -p $pathoutputlog
154 echo "===> USE LOGDIR : $pathoutputlog"
157 #---------------------------------------------------------------------
162 ctF=0 # counter for file number
163 ctJ=0 # counter for job number
164 partNumber=0 # counter for part number
166 if [ "$createJobarray" == "yes" ]
169 if [ -f $jobarrayFile ]
174 echo "===> CREATING JOB ARRAY FILE"
175 #---------------------------------------------------------------------
176 # read the files list into an job array
179 for file in $(cat $filelist)
184 #---------------------------------------------------------------------
187 #---------------------------------------------------------------------
188 # loop over the job array and submit parts with
191 while ((ctF<$nFiles))
193 #---------------------------------------------------------------------
194 # build comma separated file list
196 if [ $nFilesPerJob -gt 1 ]
198 infileList=${jobarray[${ctF}]}
200 for (( ctList=1;ctList<$nFilesPerJob; ctList++ ))
202 if [ $ctF -lt ${nFiles} ]
204 infileList="${infileList},${jobarray[${ctF}]}"
209 infileList=${jobarray[${ctF}]}
212 #---------------------------------------------------------------------
216 logfile="${pathoutputlog}/${filename}_${partNumber}.log"
218 if [ $nFilesPerJob -eq 1 ]
220 file=$(basename ${infileList})
221 logfile="${pathoutputlog}/${file}.log"
229 #echo "-----------------------------------------------------------------------------"
230 #echo "add part ${partNumber} last file ${ctF} of $nFiles ====> add new job ${infileList}"
232 ######################################################################
233 # SEND NEW JOB (USER SPECIFIC)
237 # defall.sh prog filelist outdir nev
238 echo "${par1} ${par2} ${par3} ${par4} ${par5} ${par6} ${par7}" >> $jobarrayFile
241 ######################################################################
244 #---------------------------------------------------------------------
247 fi # end createJobarray
249 #---------------------------------------------------------------------
250 # sync the local modified stuff
251 # to the submission dir
252 echo "===> SYNC CURENTDIR TO SUBMISSIONDIR : rsync -vHaz $currentDir ${submmissionbase}"
253 rsync -vHaz $currentDir ${submmissionbase}/
257 if [ ! $syncStat -eq 0 ]
259 echo "===> ERROR : SYNCHRONIZATION ENCOUNTERED PROBLEMS"
262 echo "-------------------------------------------------"
264 nFiles=$( cat $jobarrayFile | wc -l)
268 while ((${ctsend} * ${block} < ${nFiles}))
270 ((start=${ctsend}*${block}))
271 ((rest=${nFiles}-${start}))
272 if [ $rest -le $block ]
278 ((arrayoffset=${ctsend} * ${block}))
279 command="--array=1-${stop} ${resources} -D ${submissiondir} --output=${pathoutputlog}/slurm-%A_%a.out ${jobscript} ${submissiondir}/${jobarrayFile} ${pathoutputlog} ${arrayoffset}"
286 echo "${nFiles} jobs for part ${part} submitted"