1 | #!/usr/bin/perl -w
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Configuration
|
---|
5 | #
|
---|
6 |
|
---|
7 | use strict;
|
---|
8 | use Getopt::Std;
|
---|
9 | our ($opt_V,$opt_N,$opt_e,$opt_o,$opt_d,$opt_q);
|
---|
10 |
|
---|
11 | my $CONDOR_DIR = "/home/condor/release/bin/" ;
|
---|
12 | my $TEMP_DIR = "/tmp" ;
|
---|
13 |
|
---|
14 | #
|
---|
15 | # Fonctions
|
---|
16 | #
|
---|
17 |
|
---|
18 | sub uniqueId()
|
---|
19 | {
|
---|
20 | my $length=16;
|
---|
21 | my $uniqueId="";
|
---|
22 |
|
---|
23 | for(my $i=0 ; $i< $length;)
|
---|
24 | {
|
---|
25 | my $j = chr(int(rand(127)));
|
---|
26 |
|
---|
27 | if($j =~ /[a-zA-Z0-9]/)
|
---|
28 | {
|
---|
29 | $uniqueId .=$j;
|
---|
30 | $i++;
|
---|
31 | }
|
---|
32 | }
|
---|
33 |
|
---|
34 | return $uniqueId;
|
---|
35 | }
|
---|
36 |
|
---|
37 | #
|
---|
38 | # Main
|
---|
39 | #
|
---|
40 |
|
---|
41 | #Recuperation of args
|
---|
42 | getopts('VN:e:o:d:q:');
|
---|
43 |
|
---|
44 | #print $opt_V,$opt_N,$opt_e,$opt_o,$opt_d,$opt_q;
|
---|
45 |
|
---|
46 | # qsub -N pythia_run -e pythia.err -o pythia.log -d $main -V -q madgraph
|
---|
47 | # pythia.pbs >> ../running_jobs
|
---|
48 |
|
---|
49 |
|
---|
50 | my $path = `pwd`;
|
---|
51 | chomp ($path=$path);
|
---|
52 | my $executable = $path."\/".$ARGV[0];
|
---|
53 |
|
---|
54 | #output
|
---|
55 | my $output = "/dev/null";
|
---|
56 | if(defined($opt_o))
|
---|
57 | {
|
---|
58 | #print "debug\n";
|
---|
59 | $output = $opt_o;
|
---|
60 | }
|
---|
61 |
|
---|
62 | #print $output;
|
---|
63 |
|
---|
64 | #error
|
---|
65 | my $error = "/dev/null";
|
---|
66 | if(defined($opt_e))
|
---|
67 | {
|
---|
68 | $error = $opt_e;
|
---|
69 | }
|
---|
70 |
|
---|
71 | #log
|
---|
72 | my $log = "/tmp/log_condor";
|
---|
73 |
|
---|
74 | #condor arguments
|
---|
75 | my $arguments = " ";
|
---|
76 | my $requirements = "(MADGRAPH == True)";
|
---|
77 | my $queue = "1";
|
---|
78 |
|
---|
79 | my $filename=$TEMP_DIR."/".uniqueId();
|
---|
80 |
|
---|
81 | open (FILE,">$filename");
|
---|
82 |
|
---|
83 | print FILE "#Submission file generated by pbs-condor wrapper\n";
|
---|
84 | #Initial diretory
|
---|
85 | if(defined($opt_d))
|
---|
86 | {
|
---|
87 | print FILE "initialdir =" . $opt_d."\n";
|
---|
88 | }
|
---|
89 | else
|
---|
90 | {
|
---|
91 | print FILE "initialdir =" . $path."\n";
|
---|
92 | }
|
---|
93 | print FILE "universe = vanilla\n";
|
---|
94 | print FILE "executable =" . $executable."\n";
|
---|
95 | print FILE "output =". $output."\n";
|
---|
96 | print FILE "error =" . $error."\n";
|
---|
97 | print FILE "log =" . $log."\n";
|
---|
98 | print FILE "arguments =" . $arguments."\n";
|
---|
99 | print FILE "requirements =" . $requirements."\n";
|
---|
100 | print FILE "queue =" . $queue."\n";
|
---|
101 | print FILE "notification = Never\n";
|
---|
102 |
|
---|
103 | if($opt_V)
|
---|
104 | {
|
---|
105 | print FILE "getenv = True\n";
|
---|
106 | }
|
---|
107 |
|
---|
108 | close(FILE);
|
---|
109 |
|
---|
110 | my $cmd = $CONDOR_DIR."/condor_submit ".$filename . ">".$filename.".out";
|
---|
111 | system($cmd);
|
---|
112 |
|
---|
113 | my $cmd2 = "cat ".$filename.".out | tail -1 | cut -d \" \" -f 6 ";
|
---|
114 |
|
---|
115 | my $rc = `$cmd2`;
|
---|
116 |
|
---|
117 | my $index = index($rc,".");
|
---|
118 |
|
---|
119 | system("rm -f ".$filename."*");
|
---|
120 |
|
---|
121 | print substr($rc,0,$index)."\n";
|
---|
122 |
|
---|