#!/usr/local/bin/ksh
#########################
#
# mpi.pbs
#
# PBS script to submit MPI jobs on hydra
#
# Lines starting with a '#' are shell comments, but if they begin with '#PBS'
# PBS reads them as PBS options.
#
#########################
##############################################################################
# Job name to be reported by qstat
##############################################################################
#PBS -N st_3.32.3200
##############################################################################
# Declare Job, non-rerunable
##############################################################################
#PBS -r n
##############################################################################
# Specify name for output log file
##############################################################################
#PBS -o st_3_3200.32.log
##############################################################################
# Join standard output and error so we only get one logfile
##############################################################################
#PBS -j oe
##############################################################################
# Mail to user onb a=abort, b=begin, e=end
##############################################################################
#PBS -m aeb
##############################################################################
# set the email address where job-related notifications will be sent
##############################################################################
#PBS -M peterp@ouzo.njit.edu
##############################################################################
# Number of nodes to run on (must specify mpi property)
##############################################################################
# Runs on 32 cpu's. For odd number of cpu's use, e.g., nodes=7:mpi:ppn=2+1 for
# a job requiring 15 cpu's. For the example below you can equivalently do
# nodes=32:mpi:ppn=1 but that's a waste of resources and you don't gain in
# terms of performance 
#
#PBS -l nodes=16:mpi:ppn=2
##############################################################################
# Select queue - queue name for Parallel (MPI) jobs MUST BE set to feeder
##############################################################################
#PBS -q feeder
##############################################################################
# Switch to the job's working directory, provided by PBS in PBS_O_WORKDIR
##############################################################################
cd ~/Test.d/stommel
##############################################################################
# A little useful information for the log file...
##############################################################################
echo Master process running on `hostname`
echo Directory is `pwd`
echo PBS has allocated the following nodes:
echo `cat $PBS_NBODEFILE`
#############################################################################
# Define number of processors to send to mpirun for MPICH
##############################################################################
NPROCS=`wc -l < $PBS_NODEFILE`
echo This job has allocated $NPROCS nodes
##############################################################################
# Specify CPU time needed
##############################################################################
## Specify 48 hours of CPU Time
#PBS -l cput=48:00:00
##############################################################################
# Put in a timestamp
##############################################################################
echo Starting executation at `date`
##############################################################################
# Run the executable
##############################################################################
/usr/rels/mpich/bin/mpiexec -verbose ./st_3d3200
##############################################################################
# Print the date again -- when finished
##############################################################################
echo Finished at `date`
##############################################################################