ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/scripts/BatchCern/submit
Revision: 1.1.1.1 (vendor branch)
Committed: Mon Sep 10 09:45:43 2007 UTC (17 years, 7 months ago) by auterman
Branch: tex, Demo, SusyScan, scripts, MAIN
CVS Tags: start, HEAD
Changes since 1.1: +0 -0 lines
Log Message:
CERN batch scripts

File Contents

# User Rev Content
1 auterman 1.1 #!/bin/bash
2     #CTA, HH, 09/15/007
3    
4     #TOTAL_JOBS=10
5     FILESPERJOB=20
6    
7     echo "...preparing jobs"
8    
9     #strip possible endings:
10     SAMPLE=`echo $1 | sed -e "s|.cfg| |"`
11     SAMPLE=`echo $SAMPLE | sed -e "s|.cfi| |"`
12     SAMPLE=`echo $SAMPLE | sed -e "s|.cff| |"`
13     SAMPLE=`echo $SAMPLE | sed -e "s|.dat| |"`
14    
15     #Get Path from Release directory to current
16     BASEPATH=`pwd`
17     CURRPATH=`pwd`
18     THISPATH=""
19     while [ -z `basename $CURRPATH | grep "src"` ]; do
20     CURRPATH=`pwd`
21     THISPATH=`basename $CURRPATH`/$THISPATH
22     cd ..
23     done
24     cd $BASEPATH
25     THISPATH=`echo "$THISPATH" | sed -e "s|src/| |"`
26    
27     POOLSOURCE=`grep "#PoolSource =" $1 | sed -e "s/#PoolSource = / /" | tr -d [\"]`
28     FULLSOURCE=`echo "$CMSSW_BASE/src/$POOLSOURCE" | tr -d [\ ]`
29    
30     # stage 'em
31     #ALL_FILES_ARRAY=`grep "root" $CMSSW_BASE/$POOLSOURCE | tr -d [\',]`
32     #for i in $ALL_FILES_ARRAY
33     #do
34     # #echo "stager_get -M $i"
35     # echo "."
36     #done
37    
38     # split sample to n jobs
39     grep "root" $FULLSOURCE > _majordomo
40     #grep "root" files.cfi > _majordomo
41     echo "," >> _majordomo
42     split -l $FILESPERJOB _majordomo _tmpfilelist_
43     FIL=1
44     for i in `ls _tmpfilelist_*`
45     do
46     echo "replace PoolSource.fileNames = {" > $SAMPLE.SUB$FIL.cfi
47     #Remove last comma
48     FILES=`cat $i`
49     FILES=${FILES%,}
50     for file in $FILES
51     do
52     echo $file >> $SAMPLE.SUB$FIL.cfi
53     done
54     echo "}" >> $SAMPLE.SUB$FIL.cfi
55     FIL=$(($FIL+1))
56     done
57    
58     #create new cfg files with above _tmpfilelist_*.cfi's
59     JOB=1
60     for i in `ls $SAMPLE.SUB*.cfi`
61     do
62     #the jobs cfg file
63     sed -e "s|$SAMPLE|$SAMPLE.$JOB|" $1 > _tmp$JOB.$1
64     THIS_CFI=`echo "\"$THISPATH$i\"" | tr -d [\ ]`
65     sed -e "s|#include_datafiles_here|include $THIS_CFI|" _tmp$JOB.$1 > job_$JOB.$1
66     #the jobs run script
67     sed -e "s|CFG_FILE|$SAMPLE|" run.sh > _tmp_$JOB.$1.sh
68     sed -e "s|JOB_NUMBER|$JOB|" _tmp_$JOB.$1.sh > run_$JOB.$1.sh
69     chmod a+x run_$JOB.$1.sh
70    
71     echo "...submitting job #"$JOB
72     bsub -R "mem>1001&&cpuf>1.1" -q 1nh run_$JOB.$1.sh
73     JOB=$(($JOB+1))
74     done
75     rm -f _majordomo
76     rm -f _tmp*
77     #rm -f _*
78     mkdir $SAMPLE
79     cp * $SAMPLE/.
80     #./clean
81