#!/usr/bin/perl # cvs id: $Id: qsub_hum,v 1.7 2007/02/14 19:58:51 trn Exp $ # quick and dirty handling of command line arguments to scripts # submitted via qsub on PBS (humboldt) # Assumes that the first argument starting with "/" is the name of the # script to be submitted - will work as long as the absolute path of the script # is used, and none of the arguments (options) to qsub start with "/" use strict; use File::Basename; my $tmp=basename($0); $tmp=$tmp.$$; open(TMP,">$tmp") or die "Cannot open >$tmp\n"; print TMP "#!/bin/csh -f\n"; print TMP "# PBS script created by $0 at: ".scalar(localtime)."\n"; print TMP 'echo -n "Starting with cd $PBS_O_WORKDIR at: "'."\n"; print TMP 'date'."\n"; print TMP 'cd $PBS_O_WORKDIR'."\n"; print TMP 'echo PBS_NODEFILE: $PBS_NODEFILE'."\n"; print TMP 'cat $PBS_NODEFILE'."\n"; print TMP 'setenv MPIRUN "mpirun -machinefile $PBS_NODEFILE"'."\n"; my $pref="qsub -V"; my @args=@ARGV; my $have_pref; foreach my $test (@args) { if (!$have_pref) { if (substr($test,0,1) eq '/') { $have_pref=1; print TMP " ".$test; } else { $pref=$pref." ".$test; } } else { print TMP " ".$test; } } print TMP "\n"; print TMP 'echo -n "Finished at: "'."\n"; print TMP 'date'."\n"; close(TMP) or die "Could not close >$tmp\n"; my $cmd="cat $tmp | $pref"; #print "At ".scalar(localtime)." running: $cmd\n"; system($cmd); 1;