From 2051f76c3a53881a1d524e7923bb2592798534d4 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Wed, 5 Aug 2015 13:00:02 -0700 Subject: [PATCH] allow for running all array items in one job --- dqsub | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dqsub b/dqsub index f0e515e..7fe5f9a 100755 --- 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 .= <{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 .= <