--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
'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');
if (not defined $options{batch}) {
qx/which sbatch/;
- if ($?) {
+ if ($? == 0) {
$options{batch} = 'slurm'
} else {
$options{batch} = 'pbs'
if ($options{interactive}) {
- print STDERR 'running: qsub '.join(' ',@qsub_options) if $DEBUG;
- exec('qsub',@qsub_options);
+ print STDERR 'running: '.$JOB_SUBMITTER.' '.join(' ',@qsub_options) if $DEBUG;
+ exec($JOB_SUBMITTER,@qsub_options);
} else {
my @array = ();
if ($options{array}) {
}
}
}
+ if ($options{batch} eq 'pbs') {
+ push @qsub_options,'-';
+ }
call_qsub(\@qsub_options,write_qsub_script(\%options,\@ARGV,\@array));
}
return @qo;
}
-sub generate_slrum_options{
+sub generate_slurm_options{
my ($options,$args) = @_;
my @qo;
if (defined $options->{queue} and length $options->{queue}) {
);
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';
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;
}
sub call_qsub {
my ($qsub_options,$script) = @_;
my $qsub_fh;
- open $qsub_fh,'|-',$JOB_SUBMITTER,@{$qsub_options},'-' or
+ open $qsub_fh,'|-',$JOB_SUBMITTER,@{$qsub_options} or
die "Unable to start $JOB_SUBMITTER: $!";
print {$qsub_fh} $script or
die "Unable to print to $JOB_SUBMITTER: $!";
$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});