Gromacs
Gromacs is a molecular dynamics package. It is available on Hamilton via a software module that must be loaded in order to make the software accessible. To list the versions available and then load one of them, type e.g:
module avail gromacsmodule load gromacs/2025.4
Current versions (later than 2021.4)
Sample job scripts are included below; please also look at the Running Jobs page for further advice on how to configure jobs.
Example GPU job
Module versions 2025.4 and above are able to make use of GPU hardware.
#!/bin/bash# example script for Gromacs#SBATCH -p cuda # Slurm queue/partition.#SBATCH -gres=gpu:1 # GPU resources. See Hamilton web pages for options#SBATCH -t 00-01:00:00 # job time limit, in format dd-hh:mm:ss. Default: 1 hour.# Do not request CPU, memory or temporary disk space separately, they will be# allocated automatically from the GPU resources requested. module purgemodule load gromacs/2025.4 # Use 'gmx' for single precision and 'gmx_d' for double precision gmx mdrun <gromacs options>
Example MPI job
#!/bin/bash# example job script for Gromacs (mdrun)#SBATCH -p shared # Slurm queue/partition. Default is 'shared'.#SBATCH -t 00-01:00:00 # job time limit, in format dd-hh:mm:ss. Default: 1 hour.#SBATCH --mem=1G # RAM required per node, in units k,M,G or T.# Define how the job is parallelised, with (-n) MPI ranks and (-c) threads per rank# distributed over (-N) nodes. Experiment if necessary to find a configuration that# best suits your case. Note that Gromacs has a limit of 64 threads per rank.#SBATCH -n 1#SBATCH -c 1#SBATCH -N 1module purgemodule load gromacs/2025.4# Launch mdrun. The numbers of MPI ranks and threads per rank are set automatically# using the configuration requested above, so they need not be specified below.
# 'gmx_mpi' is for single precision, use 'gmx_mpi_d' for double precisionmpirun gmx_mpi mdrun <gromacs options>
Example non-MPI job
#!/bin/bash# example script for Gromacs (no MPI)#SBATCH -p shared # Slurm queue/partition. Default is 'shared'.#SBATCH -t 00-01:00:00 # job time limit, in format dd-hh:mm:ss. Default: 1 hour.#SBATCH --mem=1G # RAM required per node, in units k,M,G or T.module purgemodule load gromacs/2025.4
# Use 'gmx' for single precision, 'gmx_d' for double precisiongmx mdrun <gromacs options>
Versions up to 2021.4
Older versions of Gromacs can be run in two ways:
- For all mdrun jobs, use mpirun mdrun_mpi (or mpirun mdrun_mpi_d for double precision) instead of gmx mdrun, even for non-parallel cases.
- Other Gromacs functionality is available via the commands gmx (for single precision) and gmx_d (double precision).
Sample job scripts are included below; please also look at the Running Jobs page for further advice on how to configure jobs.
Example job for mdrun
#!/bin/bash# example job script for Gromacs (mdrun)#SBATCH -p shared # Slurm queue/partition. Default is 'shared'.#SBATCH -t 00-01:00:00 # job time limit, in format dd-hh:mm:ss. Default: 1 hour.#SBATCH --mem=1G # RAM required per node, in units k,M,G or T.# Define how the job is parallelised, with (-n) MPI ranks and (-c) threads per rank# distributed over (-N) nodes. Experiment if necessary to find a configuration that# best suits your case. Note that Gromacs has a limit of 64 threads per rank.#SBATCH -n 1#SBATCH -c 1#SBATCH -N 1module purgemodule load gromacs/2021.4# Launch mdrun. The numbers of MPI ranks and threads per rank are set automatically# using the configuration requested above, so they need not be specified below.mpirun mdrun_mpi <gromacs options>
Example job for gmx (ie. not mdrun)
#!/bin/bash# example script for Gromacs (not mdrun)#SBATCH -p shared # Slurm queue/partition. Default is 'shared'.#SBATCH -t 00-01:00:00 # job time limit, in format dd-hh:mm:ss. Default: 1 hour.#SBATCH --mem=1G # RAM required per node, in units k,M,G or T.module purgemodule load gromacs/2021.4# For all mdrun jobs, use 'mpirun mdrun_mpi' (single precision) or 'mpirun mdrun_mpi_d'# (double precision) instead of 'gmx mdrun', even for non-parallel cases.gmx <gromacs options>