Job Scripts

This page documents the basics of how to write job scripts for the HPC clusters.
Cluster-specific details are kept in separate sub pages for each cluster.

Job Script Basics

To run a job on the cluster involves creating a shell script called
a job script. The job script is a plain-text file containing any
number of commands, including your main computational task, i.e., it
may copy or rename files, cd into the proper directory, etc., all
before doing the "real" work. The lines in the script file are the
commands to be executed, in the given order. Lines starting with a
# are ignored as comments, except lines that start with #SBATCH,
which are not executed, but contain special instructions to the queue
system.

If you are not familiar with shell scripts, they are simply a set of
commands that you could have typed at the command line. You can find
more information about shell scripts here: Introduction to Bash shell
scripts.

Parameters to the queue system may be specified on the sbatch
command line and/or in #SBATCH lines in the job script. There can
be as many #SBATCH lines as you want, and you can combine several
parameters on the same line. If a parameter is specified both on the
command line and in the job script, the parameter specified on the
command line takes precedence. The #SBATCH lines must precede any
commands in the script.

Which parameters are allowed or required depends the job type and
cluster, but two parameters must be present in (almost) any job:

--account, which specifies the project the job will run in.
Required by all jobs.

--walltime, which specifies how long a job should be allowed to
run. If it has not finished within that time, it will be cancelled.
Required by all jobs except optimist jobs, where it is forbidden.

The other parameters will be described in the sub pages for each cluster.

It is recommended to start the commands to set up the environment with

set -o errexit # Exit the script on any errorset -o nounset # Treat any unset variables as an error
module --quiet purge # Reset the modules to the system default

and will most likely include one or more

module load SomeProgram/SomeVersion

to set up environment variables like $PATH to get access to the
specified programs. It is recommended to specify the explicit version
in the module load command. We also recommend adding a

Download the script: generic_job.sh (you might have
to right-click and select Save Link As... or similar).

Wall Time Limit

The wall time limit (--walltime) is required for all jobs except
optimist jobs. Optimist jobs don't have any fixed wall time
limit, so --walltime is not allowed for them.

The most used formats for the walltime specification is DD-HH:MM:SS
and HH:MM:SS, where DD is days, HH hours, MM minutes and SS
seconds. For instance:

3-12:00:00: 3.5 days

7:30:00: 7.5 hours

We recommend you to be as precise as you can when specifying the wall
time limit as it will inflict on how fast your jobs will start to
run: It is easier for a short job to get started between two larger,
higher priority jobs (so-called backfilling). On the other hand, if
the job has not finished before the wall time limit, it will be
cancelled, so too long is better than too short due to lost work!