Zentrum für Datenverarbeitung (ZDV) (data center)

Batch scripts

The simple batch script

A simple batch script for a job that will be dispatched on a node with eight cores looks like this:

 

#!/bin/bash
#PBS -l nodes=1:ppn=8
#PBS -l walltime=0:10:0


#the main script have to begin after the PBS commands
#PBS commands should not interrupted with comments

cd $PBS_O_WORKDIR
./myprog my_param

 

The important parameters in a batch script are:

IMPORTANT: Request only the resources you really require!

If you only need 4 nodes, you can write "-l nodes=1:ppn=4. This prevents more processes starting than nodes have been reserved.

The simple batch script extended with more parameters

If you want to use a special compiler (or an other program), you need to load this compiler module in your batch script. For example, if you want to load the Intel Compiler 10.1, you need to insert the path in your "~/.bashrc" first

You see a template for such a script below:

 

#!/bin/bash
#PBS -l nodes=1:ppn=2
#PBS -l walltime=48:0:0
.~/.bashrc
module load intel/10.1
cd $PBS_O_WORKDIR
./myprog my_param

 

Of course you can insert multiple module files in one file, so that all modules will be loaded at once.

The simple batch script extended for a parllel job

Starting a prallel job (MPI job) on multiple nodes requires a declaration of the node number in the batch script. Additionally you need to load the appropriate MPI version in the module file.

In our example we want to dispatch a job on four nodes with eight processes on each node. See below for an example:

 

#!/bin/bash
#PBS -l nodes=4:ppn=8
#PBS -l walltime=48:0:0
.~/.bashrc
module load openmpi/1.2.6
#openmpi uses the TM Interface for communicating with torque. Thus you do not need to
#generate a host file, because it will be done automatically.

mpirun myprog arg1 arg2