Gaussian

Gaussian 16 software

Gaussian 16 (G16) is the world’s most widely used quantum chemistry software. It calculates the electronic structure of molecules using methods ranging from Hartree-Fock to coupled cluster, DFT, and multireference methods. On duhpc (High Performance Computing Cluster commissioned in HPCC Lab, Department of Chemistry, University of Delhi), Gaussian 16 is installed on the compute nodes and is accessed through the SLURM batch system.

SLURM Job Submission for Gaussian

The Golden Rule — NProcShared Must Match SLURM

In .com fileIn SLURM script
%NProcShared=8#SBATCH –cpus-per-task=8
%Mem=32GB#SBATCH –mem=36G

⛔ WARNING: If %NProcShared=24 but –cpus-per-task=8, Gaussian tries to use 24 cores but SLURM only allocated 8 — other users’ jobs are disrupted. If %Mem > –mem, the job is killed by the OS. Always match them.

★ IMPORTANT: Set –mem slightly HIGHER than %Mem to account for Gaussian’s own overhead. Rule: if %Mem=32GB then –mem=36G. Never set them equal.

Template for Gaussian Job Script:

#!/bin/bash
#============================================================
# Gaussian16 Job Script - duhpc Cluster
# Partition: compute (NEVER use gpu partition for Gaussian)
# Usage: sbatch gaussian_job.sh
#============================================================

#SBATCH --job-name=Gaussian
#SBATCH --partition=compute         # CPU partition - DO NOT change to gpu
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=16          # Match %NProcShared in .com file (max 48)
#SBATCH --mem=36G                   # Match %Mem in .com file
#SBATCH --time=3-00:00:00           # Max 3 days on compute partition
#SBATCH --output=%x_%j.out          # Output file (%x=jobname, %j=jobid)
#SBATCH --error=%x_%j.err
#SBATCH --mail-type=BEGIN,END,FAIL
#SBATCH --mail-user=your@email.com  # Change to your email

#------------------------------------------------------------
# USER SETTINGS - Edit these
#------------------------------------------------------------
JobFile=molecule           # Input filename WITHOUT .com extension
#------------------------------------------------------------

# IMPORTANT: %NProcShared in your .com file must match --cpus-per-task (16)
# IMPORTANT: %Mem in your .com file must be less than --mem (use 36GB in .com)

echo "============================================="
echo "Gaussian16 Job - duhpc Cluster"
echo "Job ID     : $SLURM_JOBID"
echo "User       : $USER"
echo "Node       : $SLURMD_NODENAME"
echo "CPUs       : $SLURM_CPUS_PER_TASK"
echo "Memory     : $SLURM_MEM_PER_NODE MB"
echo "Input file : ${JobFile}.com"
echo "Start      : $(date)"
echo "============================================="

# Load Gaussian
export g16root=/scratch/apps/gaussian
export PATH=$g16root/g16:$PATH
export LD_LIBRARY_PATH=$g16root/g16:$LD_LIBRARY_PATH
source $g16root/g16/bsd/g16.profile

ulimit -s unlimited

# Per-job scratch on Lustre
export GAUSS_SCRDIR=/scratch/gaussian/$USER/$SLURM_JOBID
mkdir -p $GAUSS_SCRDIR
echo "Scratch    : $GAUSS_SCRDIR"
echo ""

# Check input file
if [ ! -f ${JobFile}.com ]; then
    echo "ERROR: Input file ${JobFile}.com not found!"
    echo "Make sure you are submitting from the correct directory"
    exit 1
fi

# Fix Windows line endings
sed -i 's/\r//g' ${JobFile}.com

# Show key settings from input file
echo "--- Input file settings ---"
grep -i "NProcShared\|Mem\|Chk\|%nproc\|%mem\|%chk" ${JobFile}.com

# Warn if NProcShared does not match SLURM CPUs
NPROC=$(grep -i "NProcShared\|%nproc" ${JobFile}.com | grep -o '[0-9]*' | head -1)
if [ -n "$NPROC" ] && [ "$NPROC" != "$SLURM_CPUS_PER_TASK" ]; then
    echo ""
    echo "WARNING: %NProcShared=$NPROC in .com file but --cpus-per-task=$SLURM_CPUS_PER_TASK in job script!"
    echo "         These should match. Edit job script or .com file to match."
fi
echo ""

# Run Gaussian
echo "--- Starting Gaussian16 ---"
START=$(date +%s)

g16 ${JobFile}.com

EXIT=$?
END=$(date +%s)

# Copy checkpoint back BEFORE cleaning scratch
CHK_FILE=$(grep -i "%chk" ${JobFile}.com | awk -F= '{print $2}' | tr -d ' \r')
if [ -n "$CHK_FILE" ]; then
    if [ -f "$GAUSS_SCRDIR/${CHK_FILE}" ]; then
        cp $GAUSS_SCRDIR/${CHK_FILE} ./
        echo "Checkpoint copied: ${CHK_FILE}"
    elif [ -f "$GAUSS_SCRDIR/${CHK_FILE}.chk" ]; then
        cp $GAUSS_SCRDIR/${CHK_FILE}.chk ./
        echo "Checkpoint copied: ${CHK_FILE}.chk"
    fi
fi

# Results
echo ""
echo "============================================="
if [ $EXIT -eq 0 ] && grep -q "Normal termination" ${JobFile}.log 2>/dev/null; then
    echo "Status     : COMPLETED SUCCESSFULLY"
    echo "Wall time  : $((END-START)) seconds"
    echo ""
    grep -E "SCF Done|CCSD|MP2" ${JobFile}.log 2>/dev/null | tail -5
else
    echo "Status     : FAILED or did not terminate normally"
    echo "Check      : ${JobFile}.log for details"
    echo ""
    echo "Last 10 lines of log:"
    tail -10 ${JobFile}.log 2>/dev/null
fi
echo "End time   : $(date)"
echo "============================================="

# Cleanup scratch
rm -rf $GAUSS_SCRDIR
echo "Scratch cleaned."


⚠ NOTE: Gaussian is NOT available on gpu1. Always submit to the compute partition (cn01–cn03). Gaussian does not support GPU acceleration in G16.

Useful SLURM Commands for Gaussian Jobs

TaskCommand
Submit jobsbatch gaussian_job.sh
Check job statussqueue -u $USER
Cancel jobscancel JOBID
Live outputtail -f molecule.log