use strict;
use Getopt::Long;
-use Pod::Usage;
+# use Pod::Usage;
=head1 NAME
--nodes nodes to use
--array array mode (one of 'chdir' or 'xargs' or '')
--array-from file to read arrays from (default STDIN)
+ --array-slot-limit
--ppn processors per node to use
--mem memory to request
--dir Directory to run the script in (default current directory)
'nodes=i',
'array=s',
'array_from|array-from=s',
+ 'array_slot_limit|array-slot-limit=i',
'ppn|processors-per-node=i',
'mem|memory=s',
'dir=s',
'debug|d+','help|h|?','man|m');
-pod2usage() if $options{help};
-pod2usage({verbose=>2}) if $options{man};
+# pod2usage() if $options{help};
+# pod2usage({verbose=>2}) if $options{man};
$DEBUG = $options{debug};
push @USAGE_ERRORS,"Don't provide commands when you're asking for an interactive shell";
}
-pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
+# pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
+print STDERR join("\n",@USAGE_ERRORS) and exit 1 if @USAGE_ERRORS;
# OK. Generate the options to qsub which we'll be using
my @qsub_options = generate_qsub_options(\%options);
if ($options{interactive}) {
- print STDERR 'running: qsub '.join(' ',@qsub_options) if $DEBUG:
+ print STDERR 'running: qsub '.join(' ',@qsub_options) if $DEBUG;
exec('qsub',@qsub_options);
} else {
my @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-'. scalar @array;
+ if ($options{array_slot_limit}) {
+ $qsub_options[$#qsub_options] .= '%'.$options{array_slot_limit};
+ }
}
call_qsub(\@qsub_options,write_qsub_script(\%options,\@ARGV,\@array));
}
$l[$#l] .= ':ppn='.$options->{ppn};
}
if ($options->{mem}) {
- push @l,'mem=',$options->{mem};
+ push @l,'mem='.$options->{mem};
}
push @qo,'-l',join(',',@l) if @l;
+ if ($options->{interactive}) {
+ push @qo,'-I';
+ }
+ return @qo;
}
sub read_array_options{
$fh = IO::File->new(defined $options->{array_from}) or
die "Unable to open $options->{array_from} for reading: $!";
}
- my @arrah;
+ my @array;
for (<$fh>) {
chomp;
push @array,$_;
# this script was written by dqsub
EOF
if (defined $opt->{array}) {
- die "--array is currently not implemented";
+ my $array_opt = join("\n",@{$array});
+ $script .= <<EOF;
+OPT=\$(sed -n -e "\$PBS_ARRAYID p"<<'_HERE_DOC_END_'
+$array_opt
+_HERE_DOC_END_
+)
+EOF
+ if ($opt->{array} eq 'chdir') {
+ $script .= <<EOF;
+cd "\$OPT";
+exec $command;
+EOF
+ } else {
+ $script .= <<EOF;
+exec $command "\$OPT";
+EOF
+ }
} else {
$script .= <<EOF;
# there's no array, so just executing the command with arguments