HYDRA_development_version
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sendScript_SL.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
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
7 # your program.
8 #
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.
16 #
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/
23 #
24 # job log files will be named like inputfiles. If nFilesPerJob > 1
25 # the log files will contain the partnumber.
26 #
27 ######################################################################
28 # CONFIGURATION
29 
30 
31 nFiles=20000
32 
33 user=$(whoami)
34 currentDir=$(pwd | xargs -i basename {})
35 currentDir=../$currentDir
36 
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
40  # PLUTO offset UrQMD
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
48 
49 # minbias 10*10^6
50 # no_enhancement_gcalor 100*10^6 o o
51 # p 10*10^6 evts o o
52 # d 100*10^6 evts o o
53 # pi- 50*10^6 evts o
54 # pi+ 50*10^6 evts o
55 # K- 10*10^6 evts o o
56 # K+ 10*10^6 evts 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
61 
62 # white
63 # pi- 10*10^6 evts o
64 # e- 10*10^6 evts o
65 # e+- 10*10^6 evts o
66 
67 npart=2
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
83 
84 jobarrayFile="gen8_${part}_jobarray.dat"
85 
86 filelist=${currentDir}/all_files_${part}_${npart}files.list # file list in local dir! not in submissiondir!!!
87 
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 ######################################################################
92 
93 
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" ]
98 then
99  if [ -f $filelist ]
100  then
101  echo "===> REMOVING EXISTING FILELIST : $filelist"
102  rm -f $filelist
103  fi
104 
105  echo "===> CREATE FILELIST : $filelist"
106  for ((ct=1;ct<=$nFiles;ct++))
107  do
108  echo /hera/hades/dstsim/apr12/hgeant/bmax9/Au_Au_1230MeV_omega_lambda_1000evts_${ct}_1.root >> $filelist
109  done
110 fi
111 #---------------------------------------------------------------------
112 
113 
114 
115 nFiles=$( cat $filelist | wc -l)
116 
117 #---------------------------------------------------------------------
118 # create needed dirs
119 if [ ! -d $submmissionbase ]
120 then
121  echo "===> CREATE SUBMISSIONBASEDIR : $submmissionbase"
122  mkdir -p $submmissionbase
123 else
124  echo "===> USE SUBMISSIONBASEDIR : $submmissionbase"
125 fi
126 
127 #---------------------------------------------------------------------
128 # output dirs
129 
130 
131 if [ ! -d $outputdir ]
132 then
133  echo "===> CREATE OUTPUTDIR : $outputdir"
134  mkdir -p $outputdir
135 else
136  echo "===> USE OUTPUTDIR : $outputdir"
137 fi
138 
139 if [ ! -d $outputdir/root ]
140 then
141  mkdir -p $outputdir/root
142 fi
143 
144 if [ ! -d $outputdir/qa ]
145 then
146  mkdir -p $outputdir/qa
147 fi
148 
149 if [ ! -d $pathoutputlog ]
150 then
151  echo "===> CREATE LOGDIR : $pathoutputlog"
152  mkdir -p $pathoutputlog
153 else
154  echo "===> USE LOGDIR : $pathoutputlog"
155 fi
156 
157 #---------------------------------------------------------------------
158 
159 
160 
161 
162 ctF=0 # counter for file number
163 ctJ=0 # counter for job number
164 partNumber=0 # counter for part number
165 
166 if [ "$createJobarray" == "yes" ]
167 then
168 
169 if [ -f $jobarrayFile ]
170 then
171  rm -f $jobarrayFile
172 fi
173 
174 echo "===> CREATING JOB ARRAY FILE"
175 #---------------------------------------------------------------------
176 # read the files list into an job array
177 declare -a jobarray
178 ct1=0
179 for file in $(cat $filelist)
180 do
181  jobarray[$ct1]=$file
182  ((ct1+=1))
183 done
184 #---------------------------------------------------------------------
185 
186 
187 #---------------------------------------------------------------------
188 # loop over the job array and submit parts with
189 # nFilesPerJob to GE
190 
191 while ((ctF<$nFiles))
192 do
193  #---------------------------------------------------------------------
194  # build comma separated file list
195  # per job
196  if [ $nFilesPerJob -gt 1 ]
197  then
198  infileList=${jobarray[${ctF}]}
199  ((ctF+=1))
200  for (( ctList=1;ctList<$nFilesPerJob; ctList++ ))
201  do
202  if [ $ctF -lt ${nFiles} ]
203  then
204  infileList="${infileList},${jobarray[${ctF}]}"
205  ((ctF+=1))
206  fi
207  done
208  else
209  infileList=${jobarray[${ctF}]}
210  ((ctF+=1))
211  fi
212  #---------------------------------------------------------------------
213 
214  ((partNumber+=1))
215 
216  logfile="${pathoutputlog}/${filename}_${partNumber}.log"
217 
218  if [ $nFilesPerJob -eq 1 ]
219  then
220  file=$(basename ${infileList})
221  logfile="${pathoutputlog}/${file}.log"
222  fi
223 
224  if [ -f ${logfile} ]
225  then
226  rm -f ${logfile}
227  fi
228 
229  #echo "-----------------------------------------------------------------------------"
230  #echo "add part ${partNumber} last file ${ctF} of $nFiles ====> add new job ${infileList}"
231 
232  ######################################################################
233  # SEND NEW JOB (USER SPECIFIC)
234 
235  par3=${infileList}
236 
237  # defall.sh prog filelist outdir nev
238  echo "${par1} ${par2} ${par3} ${par4} ${par5} ${par6} ${par7}" >> $jobarrayFile
239 
240 
241  ######################################################################
242 
243 done
244 #---------------------------------------------------------------------
245 
246 
247 fi # end createJobarray
248 
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}/
254 
255 syncStat=$?
256 
257 if [ ! $syncStat -eq 0 ]
258 then
259  echo "===> ERROR : SYNCHRONIZATION ENCOUNTERED PROBLEMS"
260 else
261 
262  echo "-------------------------------------------------"
263 
264  nFiles=$( cat $jobarrayFile | wc -l)
265  arrayoffset=0;
266  ctsend=0
267  block=500
268  while ((${ctsend} * ${block} < ${nFiles}))
269  do
270  ((start=${ctsend}*${block}))
271  ((rest=${nFiles}-${start}))
272  if [ $rest -le $block ]
273  then
274  ((stop=$rest))
275  else
276  ((stop=$block))
277  fi
278  ((arrayoffset=${ctsend} * ${block}))
279  command="--array=1-${stop} ${resources} -D ${submissiondir} --output=${pathoutputlog}/slurm-%A_%a.out ${jobscript} ${submissiondir}/${jobarrayFile} ${pathoutputlog} ${arrayoffset}"
280  #echo $command
281  sbatch $command
282 
283  ((ctsend+=1))
284  done
285 
286  echo "${nFiles} jobs for part ${part} submitted"
287 fi