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 user=$(whoami)
31 currentDir=$(pwd | xargs -i basename {})
32 currentDir=../$currentDir
33 
34 
35 # Au+Au
36  urqmdout=bmax10
37  energy=1230
38 
39  events=1000
40 part=all
41 
42 submmissionbase=/lustre/nyx/hades/user/${user}/sub
43 submissiondir=${submmissionbase}/urqmd
44  nFilesPerJob=1 # number of files to be analyzed by 1 job (default==1)
45  jobscript=${submissiondir}/jobScript_SL.sh # exec script (full path, call without dot, set it executable!)
46  #outputdir=/hera/hades/dstsim/apr12/urqmd/${urqmdout}/new/${part} # outputdir for files AND logFiles
47  outputdir=/lustre/nyx/hades/dstsim/apr12/urqmd/${urqmdout}/new/${part} # outputdir for files AND logFiles
48 pathoutputlog=${outputdir}/out # protocol from batch farm for each file
49  filename=testrun # filename of log file if nFilesPerJob > 1 (partnumber will be appended)
50 
51 par1=/cvmfs/hades.gsi.de/install/urqmd-3.3p2/urqmd # urqmd exe
52 #par1=/cvmfs/hades.gsi.de/install/urqmd-3.4/urqmd # urqmd exe
53 par2=/cvmfs/hades.gsi.de/install/convert-urqmd_1.3.7/convert-urqmd_1.3.7 # converter
54 par3="" # optional par3 : input file list
55 par4=${outputdir} # optional par4 : outputfile (part number will be appended (_num.root))
56 par5=$events # optional par5 : number of events
57 par6="" # optional random seed
58 par7=${submissiondir}/input/Au_Au_${energy}MeV_${urqmdout}.input # optional input file
59 resources="--mem=2000 --time=0-2:00:00" # runtime < 10h, mem < 2GB
60 jobarrayFile="urqmd_jobarray_${urqmdout}_${part}.dat"
61 
62 filelist=${currentDir}/all_files_${part}.list # file list in local dir! not in submissiondir!!!
63 
64 filepattern=Au_Au_${energy}MeV_${events}evts_
65 
66 createList=no # (yes/no) use this to create files list with generic names (for simulation, testing)
67 # use "no" if you have a filelist available
68 
69 
70 ######################################################################
71 
72 
73 #---------------------------------------------------------------------
74 # create a file list for submission (simulation, testing etc.)
75 # for real data you will have a filelist with real filenames
76 if [ "$createList" == "yes" ]
77 then
78  if [ -f $filelist ]
79  then
80  echo "===> REMOVING EXISTING FILELIST : $filelist"
81  rm -f $filelist
82  fi
83 
84  echo "===> CREATE FILELIST : $filelist"
85  ((start=${part}*10000-10000))
86  ((stop= $start+10000))
87 start=0
88 stop=10000
89  for ((ct=$start+1;ct<=$stop;ct++))
90  do
91  echo ${filepattern}${ct} >> $filelist
92  done
93 fi
94 #---------------------------------------------------------------------
95 
96 
97 
98 nFiles=$( cat $filelist | wc -l)
99 
100 #---------------------------------------------------------------------
101 # create needed dirs
102 if [ ! -d $submmissionbase ]
103 then
104  echo "===> CREATE SUBMISSIONBASEDIR : $submmissionbase"
105  mkdir -p $submmissionbase
106 else
107  echo "===> USE SUBMISSIONBASEDIR : $submmissionbase"
108 fi
109 
110 if [ ! -d $pathoutputlog ]
111 then
112  echo "===> CREATE LOGDIR : $pathoutputlog"
113  mkdir -p $pathoutputlog
114 else
115  echo "===> USE LOGDIR : $pathoutputlog"
116 fi
117 #---------------------------------------------------------------------
118 
119 
120 ctF=0 # counter for file number
121 ctJ=0 # counter for job number
122 partNumber=0 # counter for part number
123 
124 if [ -f $jobarrayFile ]
125 then
126  rm -f $jobarrayFile
127 fi
128 echo "===> CREATING JOB ARRAY FILE"
129 
130 #---------------------------------------------------------------------
131 # read the files list into an job array
132 declare -a jobarray
133 ct1=0
134 for file in $(cat $filelist)
135 do
136  jobarray[$ct1]=$file
137  ((ct1+=1))
138 done
139 #---------------------------------------------------------------------
140 
141 
142 #---------------------------------------------------------------------
143 # loop over the job array and submit parts with
144 # nFilesPerJob to GE
145 
146 while ((ctF<$nFiles))
147 do
148  #---------------------------------------------------------------------
149  # build comma separated file list
150  # per job
151  if [ $nFilesPerJob -gt 1 ]
152  then
153  infileList=${jobarray[${ctF}]}
154  ((ctF+=1))
155  for (( ctList=1;ctList<$nFilesPerJob; ctList++ ))
156  do
157  if [ $ctF -lt ${nFiles} ]
158  then
159  infileList="${infileList},${jobarray[${ctF}]}"
160  ((ctF+=1))
161  fi
162  done
163  else
164  infileList=${jobarray[${ctF}]}
165  ((ctF+=1))
166  fi
167  #---------------------------------------------------------------------
168 
169  ((partNumber+=1))
170 
171  logfile="${pathoutputlog}/${filename}_${partNumber}.log"
172 
173  if [ $nFilesPerJob -eq 1 ]
174  then
175  file=$(basename ${infileList})
176  logfile="${pathoutputlog}/${file}.log"
177  fi
178 
179  if [ -f ${logfile} ]
180  then
181  rm -f ${logfile}
182  fi
183 
184 # echo "-----------------------------------------------------------------------------"
185 # echo "add part ${partNumber} last file ${ctF} of $nFiles ====> add new job ${infileList}"
186 
187  ######################################################################
188  # SEND NEW JOB (USER SPECIFIC)
189 
190  par3=${infileList}
191  seed=0
192  seed=$(echo $par3 | sed "s/$filepattern//")
193 
194  #((seed=ctF * 1000 + 1))
195 
196  par6=$seed
197  #urqmd #convert filename outputdir nevents seed input
198  echo "${par1} ${par2} ${par3} ${par4} ${par5} ${par6} ${par7}" >> $jobarrayFile
199 
200 
201 
202  ######################################################################
203 
204 done
205 #---------------------------------------------------------------------
206 
207 #---------------------------------------------------------------------
208 # sync the local modified stuff
209 # to the submission dir
210 echo "===> SYNC CURENTDIR TO SUBMISSIONDIR : rsync -vHaz $currentDir ${submmissionbase}"
211 rsync -vHaz $currentDir ${submmissionbase}/
212 
213 syncStat=$?
214 
215 if [ ! $syncStat -eq 0 ]
216 then
217  echo "===> ERROR : SYNCHRONIZATION ENCOUNTERED PROBLEMS"
218 else
219 
220  echo "-------------------------------------------------"
221 
222  nFiles=$( cat $jobarrayFile | wc -l)
223  arrayoffset=0;
224  ctsend=0
225  block=1000
226  while ((${ctsend} * ${block} < ${nFiles}))
227  do
228  ((start=${ctsend}*${block}))
229  ((rest=${nFiles}-${start}))
230  if [ $rest -le $block ]
231  then
232  ((stop=$rest))
233  else
234  ((stop=$block))
235  fi
236  ((arrayoffset=${ctsend} * ${block}))
237  command="--array=1-${stop} ${resources} -D ${submissiondir} --output=${pathoutputlog}/slurm-%A_%a.out ${jobscript} ${submissiondir}/${jobarrayFile} ${pathoutputlog} ${arrayoffset}"
238  #echo $command
239  sbatch $command
240 
241  ((ctsend+=1))
242  done
243 
244  echo "${nFiles} jobs for day ${day} submitted"
245 fi
246 
247