Submitting 'command file' jobs with Slurm

The example scripts below show how to submit a Slurm job using a multiple program configuration file, which is similar to the command file in this PBS example.

Command/configuration file

Each line of the configuration file specifies commands to run on one or more cores. First assign task numbers, either in a list ( e.g., 0,1,2) or in a range (e.g., 0-2), followed by white space. Next, indicate the command to be executed and any desired arguments and input/output redirection. Here is one example of the basic syntax to use when each of four commands is to run once on a single core:

0 ./cmd1.exe < input1 > output1
1 ./cmd2.exe < input2 > output2
2 ./cmd3.exe < input3 > output3
3 ./cmd4.exe < input4 > output4

Submission scripts

Customize these examples by substituting your own job name, project code, user name, and so on. When your script is ready, run sbatch to submit the job.

sbatch script_name

tcsh script

#!/bin/tcsh
#SBATCH -J job_name
#SBATCH -n 4
#SBATCH --ntasks-per-node=4
#SBATCH -t 01:00
#SBATCH -A project_code
#SBATCH -p dav
#SBATCH -o cmdfile.out

### Initialize the Slurm environment
source /glade/u/apps/opt/slurm_init/init.csh

setenv TMPDIR /glade/scratch/username/temp
mkdir -p $TMPDIR

### Use the multiple program flag to specify command file job
srun --multi-prog ./tasks.conf

bash script

#!/bin/bash
#SBATCH -J job_name
#SBATCH -n 4
#SBATCH --ntasks-per-node=4
#SBATCH -t 01:00
#SBATCH -A project_code
#SBATCH -p dav
#SBATCH -o cmdfile.out

### Initialize the Slurm environment
source /glade/u/apps/opt/slurm_init/init.sh

export TMPDIR=/glade/scratch/username/tmp
mkdir -p $TMPDIR

### Use the multiple program flag to specify command file job
srun --multi-prog ./tasks.conf