Skip to content
NAISS Logo Allocations Support Training Software naiss.se

Gromacs

Arrhenius

How to use

Example job script for CPU job:

#!/bin/bash
#SBATCH -A XXXX-XX-XX     # Project ID   
#SBATCH -J gromacs-job    # Job name                             
#SBATCH -t 02:50:00       # Wall time               
#SBATCH -p cpu            # CPU partition                     
#SBATCH -n 4              # 4 MPI ranks
#SBATCH -c 7              # 7 OpenMP threads

# load the Gromacs module                         
ml purge > /dev/null 2>&1
ml buildtool-easybuild/5.2.1-hpca3ef7d197  GCC/14.3.0  OpenMPI/5.0.8
ml GROMACS/2025.3 

export MDRUN='gmx_mpi mdrun'
gmx grompp -o gromacs_input.tpr ...
srun $MDRUN -v -deffnm gromacs_input -resethway

Example job script for GPU job:

#!/bin/bash
#SBATCH -A XXXX-XX-XX     # Project ID   
#SBATCH -J gromacs-job    # Job name                             
#SBATCH -t 02:50:00       # Wall time               
#SBATCH -p gpu            # GPU partition
#SBATCH --gpus=1          # Nr. of GPU cards                     
#SBATCH -n 1              # 1 MPI ranks should match the nr. of GPU cards
#SBATCH -c 7              # 7 OpenMP threads

# load the Gromacs module                         
ml purge > /dev/null 2>&1
ml GPU/GROMACS/2026.3-gcccuda-2026.03-cu13.0-es

export MDRUN='gmx_mpi mdrun'
gmx_mpi grompp -o gromacs_input.tpr ...
srun $MDRUN -v -deffnm gromacs_input -resethway

Example for a GPU job with PLUMED functionality:

#!/bin/bash
#SBATCH -A XXXX-XX-XX     # Project ID   
#SBATCH -J gromacs-job    # Job name                             
#SBATCH -t 02:50:00       # Wall time               
#SBATCH -p gpu            # GPU partition
#SBATCH --gpus=1          # Nr. of GPU cards                     
#SBATCH -n 1              # 1 MPI ranks should match the nr. of GPU cards
#SBATCH -c 7              # 7 OpenMP threads

# load the Gromacs module                         
ml purge > /dev/null 2>&1
ml GPU/PLUMED/2.10.1-gcccuda-2026.03-cu13.0-es
ml GPU/GROMACS/2026.3-plumed-gcccuda-2026.03-cu13.0-es

export MDRUN='gmx_mpi mdrun'
gmx_mpi grompp -o gromacs_input.tpr ...
srun -n 1 $MDRUN -s gromacs_input.tpr -plumed plumed.dat -nsteps 1000000 -resethway -deffnm test

In these templates, 4 MPI ranks and 7 OpenMP threads are used. However, depending on the simulation, a different combination of MPI ranks and OpenMP threads may provide better performance. Therefore, it is highly recommended to run short test simulations using different combinations and evaluate the scaling behavior before starting long production runs. During the benchmarking, the option -resethway is recommended. It will reset the performance counters halfway during the simulation.