# 
#  This is a sample PBS script, run by qsub.  Directives to PBS are specified
#  on lines beginning with #PBS, the rest is interpreted by the shell.
#

#
#  We want to redirect stdout and stderr to files, i.e. standard error and
#  output will be written to a file Jobname.eoJobID
#

#PBS -j oe

#
#  This is the number of nodes you are requesting.  If you want to run jobs
#  on the dual processor machines, use '-l nodes=4:ppn=2' (uses 8cpus total)
#  to submit to a certain 'type' of machines, you must specify 'property', 
#  which (for our cluster) is either 'twinCuMine' or 'athlon14', e.g.:
#  '-l nodes=4:twinCuMine' or '-l nodes=4:athlon14' (uses 4 cpus total)
#

#PBS -l nodes=4

#
#  When PBS crashes, we don's want it to rerun the jobs. Linux doesn't support
#  checkpointing. Amber jobs aren't difficult to rerun anyway...
#

#PBS -r n

#
#  Put the amount of wallclock time you are requesting here.  Lower wallclock
#  jobs will get executed first, but if a job goes overtime, it will be killed.
#  You may skip this altogether and no limits should be applied (because there
#  are none in our only queue 'md')
#

#PBS -l walltime=hours:mins:seconds

#
# These should be self explanatory.  -M is for specifying a username (e.g.
# comprot) to email when the job finishes.  -N specifies your jobname 
# identifier, which shouldn't be longer than 15 characters and canno have
# any spaces (example: dhfr_bench)
#

#PBS -M  #PBS -N 

cat $PBS_NODEFILE  
echo '------------------'
# this will place the names of the nodes your job is running
# on at the head of the stdout file.

#
# You would replace the rest of this with your real mpirun line.
# A possible example could go like this:
#

cd /share/people/comprot/benchmarks/dhfr

set mpich_run = "/usr/lib/mpich/bin/mpirun"
set sander = "/share/programs/amber.g77_mpich/exe/sander"

$mpich_run -machinefile $PBS_NODEFILE -np `wc -l < $PBS_NODEFILE` $sander \
-O -i mdin -c md12.x -o mdout.2cpu.g77_mpich