Questions on Compiling LAMMPS

One thing isn’t clear to me from section 3 in the manual: build with cmake. What packages are included with the command:
cmake --build .

Also, it says:
https://lammps.sandia.gov/doc/Build_cmake.html

Compilation can take a long time, since LAMMPS is a large project with many features. If your machine has multiple CPU cores (most do these days), you can speed this up by compiling sources in parallel with make -j N (with N being the maximum number of concurrently executed tasks).

Is
make -j N
The same as the above cmake command? Can they be used interchangeably?

Last, I installed and compiled LAMMPS from https://lammps.sandia.gov/doc/Howto_bash.html#compiling-lammps-in-bash-on-windows
In order to use CMAKE I used
make no-all purge
But this command does not work anywhere and the documentation does not say where to use this command so I used it in the /src folder.

After following the steps in section 3 and 8 I get to the point with:
cmake -C ../cmake/preset/minimal.cmake -D PKG_MSC=on ../cmake
And I get an error:
`CMake Error: Error processing file: …/cmake/preset/minimal.cmake
– Running check for auto-generated files from make-based build system
– Found OpenMP_CXX: -fopenmp
– Found OpenMP: TRUE
– Could NOT find FFMPEG (missing: FFMPEG_EXECUTABLE)
– Performing Test COMPILER_SUPPORTS-march=native
– Performing Test COMPILER_SUPPORTS-march=native - Success
– Generating style_angle.h…
– Generating style_atom.h…
– Generating style_body.h…
– Generating style_bond.h…
– Generating style_command.h…
– Generating style_compute.h…
– Generating style_dihedral.h…
– Generating style_dump.h…
– Generating style_fix.h…
– Generating style_improper.h…
– Generating style_integrate.h…
– Generating style_kspace.h…
– Generating style_minimize.h…
– Generating style_nbin.h…
– Generating style_npair.h…
– Generating style_nstencil.h…
– Generating style_ntopo.h…
– Generating style_pair.h…
– Generating style_reader.h…
– Generating style_region.h…
– Generating packages_angle.h…
– Generating packages_atom.h…
– Generating packages_body.h…
– Generating packages_bond.h…
– Generating packages_command.h…
– Generating packages_compute.h…
– Generating packages_dihedral.h…
– Generating packages_dump.h…
– Generating packages_fix.h…
– Generating packages_improper.h…
– Generating packages_integrate.h…
– Generating packages_kspace.h…
– Generating packages_minimize.h…
– Generating packages_nbin.h…
– Generating packages_npair.h…
– Generating packages_nstencil.h…
– Generating packages_ntopo.h…
– Generating packages_pair.h…
– Generating packages_reader.h…
– Generating packages_region.h…
– Generating lmpinstalledpkgs.h…
– The following tools and libraries have been found and configured:

  • Git
  • MPI
  • OpenMP
  • JPEG
  • PNG
  • ZLIB`

To add to this,
I just tried running the following tutorial:
https://icme.hpc.msstate.edu/mediawiki/index.php/LAMMPS_Help

Using the command:
mpirun -np 4 $LDir/lmp_mpi -in calc_fcc.in

And received the error:
LAMMPS (15 Apr 2020)
Lattice spacing in x,y,z = 4 4 4
Created orthogonal box = (0 0 0) to (4 4 4)
1 by 2 by 2 MPI processor grid
Lattice spacing in x,y,z = 4 4 4
Created 4 atoms
create_atoms CPU = 0.0007865 secs
Replicating atoms …
orthogonal box = (0 0 0) to (4 4 4)
1 by 2 by 2 MPI processor grid
4 atoms
replicate CPU = 0.0010602 secs
ERROR: Unrecognized pair style ‘eam/alloy’ is part of the MANYBODY package which is not enabled in this LAMMPS binary. (…/force.cpp:285)
Last command: pair_style eam/alloy

Ernesto,

I am confused about you being confused. The documentation is rather explicit and detailed as it is, especially considering that this is a documentation not about CMake itself. I can only speculate that you are skipping over parts or don’t read things all the way through the end before you start typing something.
All the questions you ask are answered in the two sets of html pages your are referring to, and the things that you say you cannot find are there.

It is not possible for me to give any further advice, since I don’t know how to explain differently what is already explained in the documentation. We are using CMake for compilation on a large variety of platforms with different settings and I myself use the “minimal” preset very often on very different Linux environments and on MacOSX (on occasion). You don’t provide sufficient information about the exact OS version and platform you are running on, the CMake version you are using and you are not showing any of the actual error output (only that there was an error, which is confusing, since the file that would be causing it has not caused any issues ever and is compatible even with CMake versions from the stone age).

The CMake configuration step will output a summary of which packages have been enabled and you can also see it when running your LAMMPS executable with the -h flag.
When CMake fails to configure it will not allow you to compile a new executable, so you could be using an older executable.
I suggest you create a new build folder, check that the preset file you want to use is exactly at the path you are providing, and start over.

Axel.

also, you may be better off selecting package manually through using the text mode UI or the graphical UI (ccmake or cmake-gui). Please see the CMake howto for details.

Axel,

Thanks for responding!
So this is what I followed your advice and did the following. First, here is my setup:

I am using:
OS: Windows 10 Windows Subsystem Linux Ubuntu 18.04.4 LTS
System: AMD Ryzen 5 1600, 16 GB RAM, 64-bit OS

CMake: CMake version 3.10.2

What I Tried:

1. Clean & Purge Directories
Grab directory for src
LDir= /home/ernyb/lammps/src

Delete any old stuff to start new in the above src directory
make no-all purge

Move to main lammps director: /home/ernyb/lammpsand delete previous build folder, make new build folder, and enter build folder:
rm -r build
mkdir build
cd build

2. Configure:

cmake -C …/cmake/preset/minimal.cmake -D PKG_MISC=on …/cmake

Output:
loading initial cache file …/cmake/preset/minimal.cmake
CMake Error: Error processing file: …/cmake/preset/minimal.cmake
– The CXX compiler identification is GNU 7.5.0
– Check for working CXX compiler: /usr/bin/c++
– Check for working CXX compiler: /usr/bin/c++ – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Found Git: /usr/bin/git (found version “2.17.1”)
– Running check for auto-generated files from make-based build system
– Found MPI_CXX: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so (found version “3.1”)
– Found MPI: TRUE (found version “3.1”)
– Looking for C++ include omp.h
– Looking for C++ include omp.h - found
– Found OpenMP_CXX: -fopenmp (found version “4.5”)
– Found OpenMP: TRUE (found version “4.5”)
– Found JPEG: /usr/lib/x86_64-linux-gnu/libjpeg.so
– Found PNG: /usr/lib/x86_64-linux-gnu/libpng.so (found version “1.6.34”)
– Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version “1.2.11”)
– Found GZIP: /bin/gzip
– Could NOT find FFMPEG (missing: FFMPEG_EXECUTABLE)
– Performing Test COMPILER_SUPPORTS-ffast-math
– Performing Test COMPILER_SUPPORTS-ffast-math - Success
– Performing Test COMPILER_SUPPORTS-march=native
– Performing Test COMPILER_SUPPORTS-march=native - Success
– Looking for C++ include cmath
– Looking for C++ include cmath - found
– Generating style_angle.h…
– Generating style_atom.h…
– Generating style_body.h…
– Generating style_bond.h…
– Generating style_command.h…
– Generating style_compute.h…
– Generating style_dihedral.h…
– Generating style_dump.h…
– Generating style_fix.h…
– Generating style_improper.h…
– Generating style_integrate.h…
– Generating style_kspace.h…
– Generating style_minimize.h…
– Generating style_nbin.h…
– Generating style_npair.h…
– Generating style_nstencil.h…
– Generating style_ntopo.h…
– Generating style_pair.h…
– Generating style_reader.h…
– Generating style_region.h…
– Generating packages_angle.h…
– Generating packages_atom.h…
– Generating packages_body.h…
– Generating packages_bond.h…
– Generating packages_command.h…
– Generating packages_compute.h…
– Generating packages_dihedral.h…
– Generating packages_dump.h…
– Generating packages_fix.h…
– Generating packages_improper.h…
– Generating packages_integrate.h…
– Generating packages_kspace.h…
– Generating packages_minimize.h…
– Generating packages_nbin.h…
– Generating packages_npair.h…
– Generating packages_nstencil.h…
– Generating packages_ntopo.h…
– Generating packages_pair.h…
– Generating packages_reader.h…
– Generating packages_region.h…
– Generating lmpinstalledpkgs.h…
– Building package: MISC
– The following tools and libraries have been found and configured:

  • Git
  • MPI
  • OpenMP
  • JPEG
  • PNG
  • ZLIB

– <<< Build configuration >>>
Build type: RelWithDebInfo
Install path: /home/ernyb/.local
Generator: Unix Makefiles using /usr/bin/make
– <<< Compilers and Flags: >>>
– C++ Compiler: /usr/bin/c++
Type: GNU
Version: 7.5.0
C++ Flags: -O2 -g -DNDEBUG
Defines: LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=3;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP
Options: -ffast-math;-march=native
– <<< Linker flags: >>>
– Executable name: lmp
– Static library flags:
– <<< MPI flags >>>
– MPI includes: /usr/lib/x86_64-linux-gnu/openmpi/include/openmpi;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include;/usr/lib/x86_64-linux-gnu/openmpi/include
– MPI libraries: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so;/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so;
– Configuring incomplete, errors occurred!
See also “/home/ernyb/lammps/build/CMakeFiles/CMakeOutput.log”.

At this point I do not see anything indicating MANYBODY was enabled or added. There is an error for FFMPEG that it could not find its executible. I am guessing I should just install it from here:
https://ffmpeg.org/download.html

Next: try to Build.

Try to build but won’t let me unless i configure the following:cmake …/cmake

which Outputs:
– Running check for auto-generated files from make-based build system
– Found OpenMP_CXX: -fopenmp
– Found OpenMP: TRUE
– Could NOT find FFMPEG (missing: FFMPEG_EXECUTABLE)
– Performing Test COMPILER_SUPPORTS-march=native
– Performing Test COMPILER_SUPPORTS-march=native - Success
– Generating style_angle.h…
– Generating style_atom.h…
– Generating style_body.h…
– Generating style_bond.h…
– Generating style_command.h…
– Generating style_compute.h…
– Generating style_dihedral.h…
– Generating style_dump.h…
– Generating style_fix.h…
– Generating style_improper.h…
– Generating style_integrate.h…
– Generating style_kspace.h…
– Generating style_minimize.h…
– Generating style_nbin.h…
– Generating style_npair.h…
– Generating style_nstencil.h…
– Generating style_ntopo.h…
– Generating style_pair.h…
– Generating style_reader.h…
– Generating style_region.h…
– Generating packages_angle.h…
– Generating packages_atom.h…
– Generating packages_body.h…
– Generating packages_bond.h…
– Generating packages_command.h…
– Generating packages_compute.h…
– Generating packages_dihedral.h…
– Generating packages_dump.h…
– Generating packages_fix.h…
– Generating packages_improper.h…
– Generating packages_integrate.h…
– Generating packages_kspace.h…
– Generating packages_minimize.h…
– Generating packages_nbin.h…
– Generating packages_npair.h…
– Generating packages_nstencil.h…
– Generating packages_ntopo.h…
– Generating packages_pair.h…
– Generating packages_reader.h…
– Generating packages_region.h…
– Generating lmpinstalledpkgs.h…
– Building package: MISC
– The following tools and libraries have been found and configured:

  • Git
  • MPI
  • OpenMP
  • JPEG
  • PNG
  • ZLIB

– <<< Build configuration >>>
Build type: RelWithDebInfo
Install path: /home/ernyb/.local
Generator: Unix Makefiles using /usr/bin/make
– <<< Compilers and Flags: >>>
– C++ Compiler: /usr/bin/c++
Type: GNU
Version: 7.5.0
C++ Flags: -O2 -g -DNDEBUG
Defines: LAMMPS_SMALLBIG;LAMMPS_MEMALIGN=64;LAMMPS_OMP_COMPAT=3;LAMMPS_JPEG;LAMMPS_PNG;LAMMPS_GZIP
Options: -ffast-math;-march=native
– <<< Linker flags: >>>
– Executable name: lmp
– Static library flags:
– <<< MPI flags >>>
– MPI includes: /usr/lib/x86_64-linux-gnu/openmpi/include/openmpi;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent;/usr/lib/x86_64-linux-gnu/openmpi/include/openmpi/opal/mca/event/libevent2022/libevent/include;/usr/lib/x86_64-linux-gnu/openmpi/include
– MPI libraries: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi_cxx.so;/usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so;
– Configuring done
– Generating done
– Build files have been written to: /home/ernyb/lammps/build

3. Build:
Next, I build it using:
cmake --build .

I have attached the output as a separate file to this email.

4. Navigate to Tutorial Directory
~/lammps/build$ cd …/

~/lammps$ cd examples/MSstateTutorials/Tutorial1

~/lammps/examples/MSstateTutorials/Tutorial1$ ls

Output
Al99.eam.alloy calc_fcc.in log.lammps

5. Run LAMMPS

I run the code as given in the manual:mpirun -np 4 $LDir/lmp_mpi -in calc_fcc.in

Output:
LAMMPS (15 Apr 2020)
Lattice spacing in x,y,z = 4 4 4
Created orthogonal box = (0 0 0) to (4 4 4)
1 by 2 by 2 MPI processor grid
Lattice spacing in x,y,z = 4 4 4
Created 4 atoms
create_atoms CPU = 0.0009034 secs
Replicating atoms …
orthogonal box = (0 0 0) to (4 4 4)
1 by 2 by 2 MPI processor grid
4 atoms
replicate CPU = 0.0011949 secs
ERROR: Unrecognized pair style ‘eam/alloy’ is part of the MANYBODY package which is not enabled in this LAMMPS binary. (…/force.cpp:285)
Last command: pair_style eam/alloy

BuildOutput.txt (41.4 KB)

CMakeOutput.log (52.7 KB)

Sorry, but you missed three crucial steps/suggestions.

  1. you did not verify that …/cmake/preset/minimal.cmake is a valid path. it isn’t. it has to be: …/cmake/presets/minimal.cmake. this is obviously a typo in the manual (these things happen) and can be easily found out by just looking at the contents of the folder …/cmake/

  2. you did not check the output of the CMake configuration run. it clearly tells that only the MISC package was enabled.

  3. you did not check the help message of the LAMMPS executable. it would also have also told you that only the MISC package is included.

…and - given your approach to problem solving - it would have really been much more straightforward for you to have used one of the UI versions of cmake instead. e.g. use: cd build; ccmake …/cmake; type ‘c’ to get an initial configuration. check the options available and select what you want, then type ‘c’ again until the ‘g’ appears. then type ‘g’ and compile.

Axel.