@@ -106,17 +106,10 @@ getlock(){
106106}
107107
108108
109- run_spool_megazip (){ # max_jobs_to_submit
109+ run_spool_megazip (){
110110
111111 megaZip=1
112112
113- if [ -z " $1 " -o " $1 " = " 0" ] ; then
114- local max_jobs=" "
115- else
116- local max_jobs=" $1 "
117- local complete=0
118- fi
119-
120113 find " $spooldirUpload " -mmin +5 -name " *.zip" | (
121114 while read workBatch ; do
122115 unzip -t $workBatch > /dev/null 2>&1
@@ -136,13 +129,6 @@ run_spool_megazip(){ # max_jobs_to_submit
136129 # process the desc files
137130 if submit_descfile " $descfile " ; then
138131 logstudy " Submitted $WUname "
139- # stop after max_jobs (0=unlimited)
140- if [ -n " $max_jobs " ] ; then
141- complete=$(( $complete + 1 ))
142- if [ $complete -ge $max_jobs ] ; then
143- break 2
144- fi
145- fi
146132 else
147133 logstudy " Problem submitting $WUname "
148134 fi
@@ -155,39 +141,61 @@ run_spool_megazip(){ # max_jobs_to_submit
155141 )
156142}
157143
158- run_spool (){ # max_jobs_to_submit
144+ run_spool (){ # max_jobs_to_submit, max_jobs_perStudy, specific_study
159145
160146 megaZip=0
161147
162- if [ -z " $1 " -o " $1 " = " 0" ] ; then
163- local max_jobs=" "
148+ local max_jobs=" $1 "
149+ local complete=0
150+ local lMaxJobs=false
151+ [ -z " ${max_jobs} " -o " ${max_jobs} " = " 0" ] || lMaxJobs=true
152+
153+ local max_jobs_perStudy=" $2 "
154+ local lMaxJobsPerStudy=false
155+ [ -z " ${max_jobs_perStudy} " -o " ${max_jobs_perStudy} " = " 0" ] || lMaxJobsPerStudy=true
156+
157+ if [ -z " $3 " ] ; then
158+ # find the work dirs 2 levels down
159+ local allWorkDirs=` find " $spooldir " -maxdepth 2 -type d -name " work" `
164160 else
165- local max_jobs= " $1 "
166- local complete=0
161+ # target a specific study
162+ local allWorkDirs= $spooldir / $3 /work
167163 fi
168164
169- # find the work dirs 2 levels down
170- find " $spooldir " -maxdepth 2 -type d -name " work " | (
165+ # main loop
166+ echo " ${allWorkDirs} " | (
171167 while read workdir ; do
172- origPath= $workdir
173- # check for desc files in the work dirs
174- find " $workdir " -maxdepth 1 -type f -name ' *.desc' | (
168+ local complete_perStudy=0
169+ # check for desc files in the current work dir, and subfolders
170+ find " $workdir " -maxdepth 2 -type f -name ' *.desc' | (
175171 while read descfile ; do
176172 # process the desc files
173+ origPath=` dirname ${descfile} `
177174 if submit_descfile " $descfile " ; then
178175 logstudy " Submitted $WUname "
179176 # stop after max_jobs (0=unlimited)
180- if [ -n " $max_jobs " ] ; then
177+ if ${lMaxJobs} ; then
181178 complete=$(( $complete + 1 ))
182179 if [ $complete -ge $max_jobs ] ; then
180+ log " reached ${max_jobs} in total"
183181 break 2
184182 fi
185183 fi
184+ if ${lMaxJobsPerStudy} ; then
185+ complete_perStudy=$(( ${complete_perStudy} + 1 ))
186+ if [ ${complete_perStudy} -ge ${max_jobs_perStudy} ] ; then
187+ # continue with next study
188+ log " reached ${max_jobs_perStudy} in ${workdir} "
189+ break 1
190+ fi
191+ fi
186192 else
187193 logstudy " Problem submitting $WUname "
188194 fi
189195 done
190- )
196+ )
197+ # remove temp dirs in work
198+ find ${workdir} -mindepth 1 -maxdepth 1 -type d -empty -delete -print | log
191199 done
192200 )
193201}
@@ -411,15 +419,19 @@ if [ -x /usr/bin/ionice ] ; then
411419fi
412420
413421maxjobs=0
422+ maxjobs_perStudy=0
414423keepzip=0
424+ studyName=" "
415425
416- while getopts " :hn:k" OPT
426+ while getopts " :hn:m:d: k" OPT
417427do
418428 # Debug
419429 # echo "OPT is $OPT. OPTIND is $OPTIND. OPTARG is $OPTARG."
420430case " $OPT " in
421431h) printhelp ; exit 0 ;;
432+ m) maxjobs_perStudy=" $OPTARG " ;;
422433n) maxjobs=" $OPTARG " ;;
434+ d) studyName=" $OPTARG " ;;
423435k) keepzip=1 ;;
424436:|? ) error ' Invalid Argument(s)' ; printhelp; exit 0 ;;
425437esac
@@ -433,10 +445,10 @@ cd $boincdir
433445
434446getlock
435447# Klog
436- log run_spool $maxjobs
437- run_spool $maxjobs
448+ log run_spool $maxjobs $maxjobs_perStudy $studyName
449+ run_spool $maxjobs $maxjobs_perStudy $studyName
438450
439- log run_spool_megazip $maxjobs
440- run_spool_megazip $maxjobs
451+ log run_spool_megazip
452+ run_spool_megazip
441453
442454log FINISHING
0 commit comments