]> git.donarmstrong.com Git - uiuc_igb_scripts.git/commitdiff
allow for running all array items in one job
authorDon Armstrong <don@donarmstrong.com>
Wed, 5 Aug 2015 20:00:02 +0000 (13:00 -0700)
committerDon Armstrong <don@donarmstrong.com>
Wed, 5 Aug 2015 20:00:02 +0000 (13:00 -0700)
dqsub

diff --git a/dqsub b/dqsub
index f0e515e2ee4cdd4b0d81a87b4a21c54b850a434d..7fe5f9afd7949fd0d991321c97aec7b36b4b826c 100755 (executable)
--- a/dqsub
+++ b/dqsub
@@ -27,6 +27,7 @@ dqsub [options]
    --array array mode (one of 'chdir' or 'xargs' or '')
    --array-from file to read arrays from (default STDIN)
    --array-per-job number of array items to handle in each job (default 1)
+   --array-all-in-one-job Run all of the array items in one job
    --ppn processors per node to use
    --mem memory to request
    --dir Directory to run the script in (default current directory)
@@ -101,6 +102,7 @@ GetOptions(\%options,
            'array_from|array-from=s',
            'array_per_job|array-per-job=i',
            'array_slot_limit|array-slot-limit=i',
+           'array_all_in_one_job|array-all-in-one-job!',
            'ppn|processors-per-node=i',
            'mem|memory=s',
            'dir=s',
@@ -140,9 +142,13 @@ if ($options{interactive}) {
     if ($options{array}) {
         @array = read_array_options(\%options) if $options{array};
         # the -t option gives the range of elements for an array job
-        push @qsub_options,'-t','1-'. ceil(scalar @array / $options{array_per_job});
-        if ($options{array_slot_limit}) {
-            $qsub_options[$#qsub_options] .= '%'.$options{array_slot_limit};
+        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{array_slot_limit}) {
+                $qsub_options[$#qsub_options] .= '%'.$options{array_slot_limit};
+            }
         }
     }
     call_qsub(\@qsub_options,write_qsub_script(\%options,\@ARGV,\@array));
@@ -221,13 +227,13 @@ EOF
             $script .= <<EOF;
 for i in \$(seq 1 $opt->{array_per_job}); do
 # in some cases, the jobs aren't going to come out evenly. Handle that.
-JOBNUM=\$(( \$PBS_ARRAYID * $opt->{array_per_job} + \$i - $opt->{array_per_job} ))
+JOBNUM=\$(( \${PBS_ARRAYID:=1} * $opt->{array_per_job} + \$i - $opt->{array_per_job} ))
 if [ \$JOBNUM -le $max_array ]; then 
 OPT=\$(sed -n -e "\$JOBNUM p"<<'_HERE_DOC_END_'
 EOF
         } else {
             $script .= <<EOF;
-OPT=\$(sed -n -e "\$PBS_ARRAYID p"<<'_HERE_DOC_END_'
+OPT=\$(sed -n -e "\${PBS_ARRAYID:=1} p"<<'_HERE_DOC_END_'
 EOF
         }
         $script .= <<EOF;