]> git.donarmstrong.com Git - uiuc_igb_scripts.git/blobdiff - dqsub
silence "which sbatch" checking
[uiuc_igb_scripts.git] / dqsub
diff --git a/dqsub b/dqsub
index d9963d33d4c944c02d6e3320e77d325cac474bdc..0a04f2d2396c208b0ebdd613b948b8f05e2c07d4 100755 (executable)
--- a/dqsub
+++ b/dqsub
@@ -34,6 +34,7 @@ dqsub [options]
    --account, -A Account name to use
    --join, -J join error and output streams (default)
    --name, -N Name of the job
+   --precommand Optional command to run before each command
    --debug, -d debugging level (Default 0)
    --help, -h display this help
    --man, -m display manual
@@ -131,6 +132,7 @@ GetOptions(\%options,
            'pmem|process_mem|process-mem=s',
            'pvmem|process_virtual_mem|process-virtiual-mem=s',
            'max_file|max-file|file=s',
+           'precommand|pre-command|pre_command=s',
            'dir=s',
            'name=s',
            'debug|d+','help|h|?','man|m');
@@ -156,7 +158,7 @@ if ($options{interactive} and @ARGV) {
 }
 
 if (not defined $options{batch}) {
-    qx/which sbatch/;
+    qx{which sbatch >/dev/null 2>&1};
     if ($? == 0) {
         $options{batch} = 'slurm'
     } else {
@@ -191,7 +193,7 @@ if ($options{batch} eq 'pbs') {
 
 
 if ($options{interactive}) {
-    print STDERR 'running: qsub '.join(' ',@qsub_options) if $DEBUG;
+    print STDERR 'running: '.$JOB_SUBMITTER.' '.join(' ',@qsub_options) if $DEBUG;
     exec($JOB_SUBMITTER,@qsub_options);
 } else {
     my @array = ();
@@ -201,7 +203,12 @@ if ($options{interactive}) {
         if ($options{array_all_in_one_job}) {
             $options{array_per_job} = scalar @array;
         } else {
-            push @qsub_options,'-t','1-'. ceil(scalar @array / $options{array_per_job});
+            if ($options{batch} eq 'pbs') {
+                push @qsub_options,'-t';
+            } else {
+                push @qsub_options,'-a';
+            }
+            push @qsub_options,'1-'. ceil(scalar @array / $options{array_per_job});
             if ($options{array_slot_limit}) {
                 $qsub_options[$#qsub_options] .= '%'.$options{array_slot_limit};
             }
@@ -282,11 +289,11 @@ sub generate_slurm_options{
         );
     for my $k (keys %options_map) {
         if ($options->{$k}) {
-            push @qo,'--'.$options_map{$k}.'=',$options{$k};
+            push @qo,'--'.$options_map{$k}.'='.$options{$k};
         }
     }
     if ($options{mem}) {
-        push @qo,'--mem=',$options{mem};
+        push @qo,'--mem='.$options{mem};
     }
     if ($options->{interactive}) {
         push @qo,'-I';
@@ -298,10 +305,6 @@ sub generate_slurm_options{
                            map {my $a = $_; $a =~ s/[^a-zA-Z0-9]*//g; $a;}
                           @{$args}[0..min($#{$args},2)]);
     }
-    # join error and output streams
-   if ($options->{join}) {
-        push @qo,'-j','oe';
-    }
     return @qo;
 }
 
@@ -339,6 +342,14 @@ sub write_qsub_script {
         $script .= <<EOF;
 # this script was written by dqsub
 EOF
+    # if there is a precommand, write it out
+    if ($opt->{precommand}) {
+        $script .=<<EOF;
+# this is the precommand _BEGIN_
+$opt->{precommand}
+# precommand _END_
+EOF
+    }
     my $directory = getcwd;
     if (defined $opt->{dir}) {
         $directory = abs_path($opt->{dir});