#!/bin/bash # # Script Name : psub # Purpose : PBS batch job submission with command line input executables # generated with default compiler. On our system, gcc is the # system default compiler. User may use "module" to choose # the default compiler. ( a companion psubi is written # specifically for executables created with Intel compiler; # if intel compiler is chosen as default compiler via "module", # psub and psubi would be fully equivalent) # The problem with directly submitting a batch job thru PBS qsub # is the fact that qsub does not accept command line input other # than a run script. As a result, unless you always run the same # executable with same runtime and same number of processors, you # will inevitably have to create many runscripts to cater to # different situations. # This script circumvent that by acting as an interface. Running of # this script, which accepts command line input, such as exec name, # number of processors, etc., and generate a temp script that # include all those command line input into the script and submit # it via qsub. This temp script is called "psub.USERID", where USERID # is the user's own ID. # Usage: # cootie % psub exec-name numprocs [-l walltime=xx:xx:xx ...] # # Examples: (examples below override the script's default of # 30 mins walltime and per processor node ppn=1) # cootie % psub ../../a.out 4 "-l walltime=00:45:00" # cootie % psub ../../a.out 4 "-l walltime=00:45:00 -l nodes=2:ppn=2" # # The output files from using this script are: # 1) psub.USERID -- the temp script # 2) psub.USERID.ennnnn -- PBS error file # 3) psub.USERID.onnnnn -- PBS output file # 4) psub.JOBID.out -- stdout file (output to "terminal") # # Author : Kadin Tseng, SCV, Boston University # Date : April 23, 2005 if [ $# -ge 2 ] then script="psub.${USER}" echo "#!/bin/bash" > $script echo '#' >> $script echo '# All lines starting with "#PBS" are PBS commands' >> $script echo '#' >> $script echo "# Request $2 nodes with 1 processor per node" >> $script echo '#' >> $script echo "#PBS -l nodes=$2:ppn=1" >> $script echo '#' >> $script echo '# Set wall clock time to 0 hours, 30 minutes and 0 seconds' >> $script echo '#PBS -l walltime=00:30:00' >> $script echo '#' >> $script echo 'GMCONF=`/usr/local/pbs/util/mknodes`' >> $script echo "cd \$PBS_O_WORKDIR" >> $script echo "#PBS $3" >> $script MPIRUN="/usr/local/IT/mpichgm-1.2.6..14b/gcc/bin/mpirun" if [ -f mystdin ] then echo "$MPIRUN -machinefile \$GMCONF -np $2 $1 < mystdin > psubi.\$PBS_JOBID.out" >> $script else echo "$MPIRUN -machinefile \$GMCONF -np $2 $1 > psubi.\$PBS_JOBID.out" >> $script fi echo "exit 0" >> $script chmod +x $script qsub $script $3 else echo "Usage: psub a.out num-procs ['optional PBS parameters']" fi