Compiling gromacs 5.1.4 static for cluster usage



GROMACS is a package to perform molecular dynamics for systems with hundreds to millions of particles. In this tutorial we are going to prepare a binary of gmx_mpi for cluster usage. The compilation will be done with Ubuntu, if you don't use Ubuntu try to follow this steps using a Virtual Machine. When we have our binary file ready, all the files will be uploaded to the cluster using scp or rsync.

Step 1: Requirements installation

sudo apt-get install cmake mpi-default-dev

Step 2: Download, Prepare and compile

As the time of writting this tutorial the latest stable version was 5.1.4, please check the download page for a newer one.

wget ftp://ftp.gromacs.org/pub/gromacs/gromacs-5.1.4.tar.gz
tar xf gromacs-5.1.4.tar.gz
cd gromacs-5.1.4
mkdir build
cd build

Now we are going to use cmake to continue with the compilation.

make install

Let's see what every options means:

First we export CMAKE_EXE_LINKER_FLAGS with -static to build completely static binaries.

  • DGMX_DOUBLE=OFF will disable double precision.
  • DCMAKE_INSTALL_PREFIX path where you want to install gromacs. For this tutorial we are going to copy this directory to the cluster.
  • DGMX_MPI enables MPI, this will build the command gmx_mpi.
  • DCMAKE_CXX_COMPILER path to the mpicxx binary.
  • DCMAKE_C_COMPILER path to the mpicc binary.
  • DGMX_BUILD_SHARED_EXE The most important flag of this tutorial, this will force the compilation to be static (no shared libs).

When the make command finishes and you execute make install, you will have several new files in /opt/gromacs, all those files need to be copied to the cluster and change your scripts to use that gmx_mpi binary instead of the installed one (if you have one installed).