General-Scripts: qsub

File qsub, 2.1 KB (added by (none), 12 years ago)
Line 
1#!/usr/bin/perl -w
2
3#
4# Configuration
5#
6
7use strict;
8use Getopt::Std;
9our ($opt_V,$opt_N,$opt_e,$opt_o,$opt_d,$opt_q);
10
11my $CONDOR_DIR = "/home/condor/release/bin/" ;
12my $TEMP_DIR = "/tmp" ;
13
14#
15# Fonctions
16#
17
18sub 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
42getopts('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
50my $path = `pwd`;
51chomp ($path=$path);
52my $executable = $path."\/".$ARGV[0];
53
54#output
55my $output = "/dev/null";
56if(defined($opt_o))
57{
58 #print "debug\n";
59 $output = $opt_o;
60}
61
62#print $output;
63
64#error
65my $error = "/dev/null";
66if(defined($opt_e))
67{
68 $error = $opt_e;
69}
70
71#log
72my $log = "/tmp/log_condor";
73
74#condor arguments
75my $arguments = " ";
76my $requirements = "(MADGRAPH == True)";
77my $queue = "1";
78
79my $filename=$TEMP_DIR."/".uniqueId();
80
81open (FILE,">$filename");
82
83print FILE "#Submission file generated by pbs-condor wrapper\n";
84#Initial diretory
85if(defined($opt_d))
86{
87 print FILE "initialdir =" . $opt_d."\n";
88}
89else
90{
91 print FILE "initialdir =" . $path."\n";
92}
93print FILE "universe = vanilla\n";
94print FILE "executable =" . $executable."\n";
95print FILE "output =". $output."\n";
96print FILE "error =" . $error."\n";
97print FILE "log =" . $log."\n";
98print FILE "arguments =" . $arguments."\n";
99print FILE "requirements =" . $requirements."\n";
100print FILE "queue =" . $queue."\n";
101print FILE "notification = Never\n";
102
103if($opt_V)
104{
105 print FILE "getenv = True\n";
106}
107
108close(FILE);
109
110my $cmd = $CONDOR_DIR."/condor_submit ".$filename . ">".$filename.".out";
111system($cmd);
112
113my $cmd2 = "cat ".$filename.".out | tail -1 | cut -d \" \" -f 6 ";
114
115my $rc = `$cmd2`;
116
117my $index = index($rc,".");
118
119system("rm -f ".$filename."*");
120
121print substr($rc,0,$index)."\n";
122