Command to run gromacs in parallel

GROMACS version: 2023.2
GROMACS modification: Yes/No
Here post your question

Hello all. I have used CHARMM-GUI solvent builder to print out a script I can use in a protein simulation. I am able to run the script successfully, but would like to run the full script in parallel. I am using my university HPC facility and have multiple cores available for tasking, and I know that is capable of MPI parallelizing. I am confused on the command that the script has commented out for running in parallel "mpirun -np $NUM_CPU gmx mdrun -ntomp 1". What parts of the script do I need to add the command to and/or parts that I should replace with the commented out command? Thank you! I will paste the script below.

 Generated by CHARMM-GUI (http://www.charmm-gui.org) v3.7
#
# This folder contains GROMACS formatted CHARMM36 force fields, " a pre-optimized PDB structure, and GROMACS inputs.
# All input files were optimized for GROMACS 2019.2 or above, so lower version of GROMACS can cause some errors.
# We adopted the Verlet cut-off scheme for all minimization, equilibration, and production steps because it is 
# faster and more accurate than the group scheme. If you have a trouble with a performance of Verlet scheme while 
# running parallelized simulation, you should check if you are using appropriate command line.
# For MPI parallelizing, we recommand following command:
# mpirun -np $NUM_CPU gmx mdrun -ntomp 1

set init = step3_input
set mini_prefix = step4.0_minimization
set equi_prefix = step4.1_equilibration
set prod_prefix = step5_production
set prod_step   = step5

# Minimization
# In the case that there is a problem during minimization using a single precision of GROMACS, please try to use 
# a double precision of GROMACS only for the minimization step.
gmx grompp -f ${mini_prefix}.mdp -o ${mini_prefix}.tpr -c ${init}.gro -r ${init}.gro -p topol.top -n index.ndx -maxwarn -1
gmx_d mdrun -v -deffnm ${mini_prefix} 


# Equilibration
gmx grompp -f ${equi_prefix}.mdp -o ${equi_prefix}.tpr -c ${mini_prefix}.gro -r ${init}.gro -p topol.top -n index.ndx
gmx mdrun -v -deffnm ${equi_prefix}


# Production
set cnt    = 1
set cntmax = 10

while ( ${cnt} <= ${cntmax} )
    @ pcnt = ${cnt} - 1
    set istep = ${prod_step}_${cnt}
    set pstep = ${prod_step}_${pcnt}

	if ( ${cnt} == 1 ) then
        set pstep = ${equi_prefix}
        gmx grompp -f ${prod_prefix}.mdp -o ${istep}.tpr -c ${pstep}.gro -p topol.top -n index.ndx
	else
        gmx grompp -f ${prod_prefix}.mdp -o ${istep}.tpr -c ${pstep}.gro -t ${pstep}.cpt -p topol.top -n index.ndx
	endif
	gmx mdrun -v -deffnm ${istep}
	@ cnt += 1
end

Most times, the parallelized gmx usually comes with gmx_mpi…

check your available gromacs, load it and use which to access it.


module load gromacs 

$(which gmx_mpi) mdrun -deffnm ${equi_prefix}

Thank you so much. I got it to work with your advice!

1 Like