Sample SGE Script

From NBCR Public Wiki

Below are sample SGE submission scripts with basic options. SGE specific options are denoted by "#$". Each submission script will vary slightly depending on the parallel environment. Three that are available are mpi, mpich, and lammpi (more information on compiling programs for these environments can be found here (https://nbcr.net/pub/wiki/index.php?title=MPI_Applications)). Please also check out the Rocks sample batch script for running Linpack SGE batch job submission for Rocks 4.1 (http://www.rocksclusters.org/roll-documentation/sge/4.1/submitting-batch-jobs.html)

If you have a problem with "libraries not found", then check your LD_LIBRARY_PATH and use the "-V" option in the submission script to transfer your environmental variables.

Table of contents

Useful Resource Selection Criteria

  1. walltime
    -l h_rt=24:00:00
  2. queue
    -l short (16 hr walltime)
    -l medium (24 hr)
    -l long (48 hr)

notification

  1. -M <email address>
  2. -m beas

Users running large parallel jobs may consider using the

qsub -R y <jobscript>

option for resource reservation. Up to 20 reservations are supported currently.


Parallel Jobs

MPI & MPICH

#!/bin/bash
#$ -N job_name
#$ -S /bin/bash
#$ -l h_rt=00:30:00 #30 min run
#MPI is also available. Simply substitute "mpi" for "mpich"
#$ -pe mpich 4           
#$ -cwd
#$ -o job_name.out
#$ -e job_name.err
#$ -notify

/opt/mpich/gnu/bin/mpirun -np $NSLOTS -machinefile $TMPDIR/machines $YOUR_PROG $ARGS

LAM/MPI

#!/bin/bash
#$ -N job_name
#$ -pe lammpi 4           
#$ -cwd
#$ -o job_name.out
#$ -e job_name.err    
#$ -notify

/opt/lam/intel/bin/mpirun C $YOUR_PROG $ARGS

NOTE: mpi and mpich jobs must be compiled by a MPICH compiler, and lammpi by a LAM/MPI compiler. You must also use a mpirun from the same mpi installation you chose to compile with.

Single Processor/Serial Jobs

#!/bin/bash
#$ -N job_name          
#$ -cwd
#$ -o job_name.out
#$ -e job_name.err       

$YOUR_PROG $ARGS


Explanation of above submission options:

-N    The name you want to give the job.
-pe   The parallel environment of the job.  This can be mpi, mpich, or lammpi.
      You must also specify the number of processors.  This can be 2 or more.
-cwd  Runs the job from the directory of submission.
-o    File to send standard output.
-e    File to send standard error.
-V    Transfer all your environment variables
-v    Transfer specified environment variables

Finally, check out Submitting jobs to different queues using SGE