Monday, October 1, 2012

Compiling LAMMPS with Intel Composer and OpenMPI

A typical problem which one faces trying to compile LAMMPS using Intel Composer XE 2011 is the following link error:
write_restart.o: In function `LAMMPS_NS::WriteRestart::command(int, char**)':
write_restart.cpp:(.text+0x2b9): undefined reference to `__intel_sse2_strchr'
write_restart.cpp:(.text+0x4b1): undefined reference to `__intel_sse2_strchr'
write_restart.cpp:(.text+0x586): undefined reference to `__intel_sse2_strchr'
write_restart.cpp:(.text+0x10e3): undefined reference to `__intel_sse2_strchr'
write_restart.cpp:(.text+0x125a): undefined reference to `__intel_sse2_strcpy'
write_restart.o: In function `LAMMPS_NS::WriteRestart::write(char*)':
write_restart.cpp:(.text+0x28d7): undefined reference to `__intel_sse2_strchr'
write_restart.cpp:(.text+0x29ab): undefined reference to `__intel_sse2_strchr'
write_restart.cpp:(.text+0x34fe): undefined reference to `__intel_sse2_strchr'


And so on. This error was discussed on Intel forums, so I followed the advice by _samuel_ and modified src/Makefile.openmpi as follows:

LINKFLAGS = -O -L/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64 -lifcoremt -Bstatic -lirc -Bdynamic

This solved the problem and after running make openmpi I finally got a binary. If you don't really know where is your Composer installed, this command will (probably) show the path:
$which icc
/opt/intel/composer_xe_2011_sp1.7.256/bin/intel64/icc

Installing MEAM
To use Modified Embedded Atom Method, one should compile LAMMPS with MEAM package:
make yes-meam

After that go to ../lib/meam and compile MEAM library:
make -f Makefile.ifort

After successful compilation modify Makefile.lammps to specify the proper libraries and path:
meam_SYSINC = 
meam_SYSLIB = -lifcore -lsvml -liompstubs5 -limf
meam_SYSPATH = -L/opt/intel/composer_xe_2011_sp1.7.256/compiler/lib/intel64


Only after that you can compile LAMMPS once again:
make clean-openmpi
make openmpi