Skip to content

Submitting Gaussian Jobs With Slurm

This script is an example of launching individual Gaussian jobs on the Kennesaw State VHPC Cluster.

Slurm Shell Script

In our example, we saved the following Slurm script as run_gaussian.slurm (making sure to change netid@kennesaw.edu and account_name in the script to the correct values for your job):

run_gaussian.slurm
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
#SBATCH --partition="defq"
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16
#SBATCH --time=01:00:00
#SBATCH --export="ALL"
#SBATCH --mail-type="BEGIN,END,FAIL"
#SBATCH --mail-user="netid@kennesaw.edu" (1)
#SBATCH --mem=10G
#SBATCH --account="account_name" (2)

# Make sure $FILE exists before going too far...
if [[ -z "$FILE" || ! -f "$FILE" ]]; then
    echo "ERROR: FILE is not set or does not exist: $FILE"
    exit 1
fi

# Load the Gaussian Modules
module load Gaussian

# cd to the SUBMIT_DIR (probably not required)
cd "$SLURM_SUBMIT_DIR" || exit 1

# Create unique scratch directory
export GAUSS_SCRDIR="$(mktemp -d "${HOME}/work/gscratch/gaussian.${SLURM_JOB_ID:-manual}${SLURM_ARRAY_TASK_ID:+_${SLURM_ARRAY_TASK_ID}}.XXXXXX")" || exit 1

# Log it (helps with debugging and cleanup visibility)
echo "Using GAUSS_SCRDIR=$GAUSS_SCRDIR"

# Cleanup on exit
cleanup() {
    if [[ -n "$GAUSS_SCRDIR" && -d "$GAUSS_SCRDIR" ]]; then
        rm -rf "$GAUSS_SCRDIR"
    fi
}
trap cleanup EXIT

datestamp=$(date +%Y-%m-%d.%H%M%S)

g16 -p=${SLURM_CPUS_PER_TASK} ${FILE} > ${FILE%.*}.${datestamp}.out
  1. 🙋‍♂️ Make sure to change netid@kennesaw.edu on this line to your KSU email address or you won't receive emails when the job starts and stops.
  2. 🙋‍♂️ Make sure to change account_name on this line to the VHPC billing account your job should be charged to.

Usage

Assuming you saved the Slurm script from above as run_gaussian.slurm, and the name of your Gaussian script is my_script.com, you can submit your Gaussian job with the following command:

[barney@vhpc ~]$ sbatch --export=ALL,FILE=${PWD}/my_script.com run_gaussian.slurm