CMake¶
CMake Example: Serial LAMMPS Build¶
Note
This is a minimal example using the command line version of CMake to build LAMMPS with no add-on packages enabled and no customization.
To allocate an interactive job on compute node type:
srun -p short --pty -N 1 -n 28 /bin/bash
For LAMMPS, you will need to create and use the build directory with the following command:
mkdir build cd build/
Load the CMake module and use CMake to generate a build environment in a new directory.
module load cmake/3.23.2 cmake ../cmake
Next, you will work on the compilation and linking of all objects, libraries, and executables using the selected build tool.
cmake --build . make install
The
cmake --build
command will launch the compilation, which, if successful, will ultimately generate an executablelmp
inside thebuild
folder. Now you can start running LAMMPS using./lmp
.
CMake Example: Parallel LAMMPS Build¶
See also
The following instructions to build LAMMPS using cmake.
Running LAMMPS in parallel is possible using a domain decomposition parallelization. In order to build the MPI version, first allocate an interactive job on compute node by typing:
srun -N 1 -n 28 --constraint=ib --pty /bin/bash
Load the required modules required for building LAMMPS:
module load openmpi/4.0.5 module load cmake/3.23.2
For LAMMPS, you will need to create and use the build directory with the following command:
mkdir build cd build/
In the build directory, run the following commands with
DBUILD_MPI=yes
to build the MPI version :cmake ../cmake -DBUILD_MPI=yes cmake --build . make install
The instructions above will create a lmp
inside the build
directory.
Note
When compiled with MPI, the binaries expect mpirun
or mpiexec
with the number of tasks to run.
Now, you can start running LAMMPS using mpirun -n 1 ./lmp -h
.