LAMMPS installation using pgCC

Hello all,

I am trying to install LAMMPS [http://lammps.sandia.gov/ , The code is mostly in C++] using the pgi compiler we recently bought. Please find below, a Makefile and the corresponding error I get at the liniking stage.

Makefile:

SHELL = /bin/sh
export LM_LICENSE_FILE=/opt/pgi/license.dat
CC = pgCC
CCFLAGS = -O3 -I/home/pkc/tools/mpi-files/include \ -I/home/pkc/tools/fftw-files/include -DFFT_FFTW -DGZIP \ -DMPICH_IGNORE_CXX_SEEK
DEPFLAGS = -M
LINK = pgCC
LINKFLAGS = -O3 -L/home/pkc/tools/mpi-files/lib -L/home/pkc/tools/fftw-files/lib
#USRLIB = -lfftw -lfmpich -lmpich
USRLIB = -lfftw
ARCHIVE = ar
ARFLAGS = -rc
SIZE = size
$(EXE): $(OBJ)
$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
$(SIZE) $(EXE)
lib: $(OBJ)
$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
%.o:%.cpp
$(CC) $(CCFLAGS) -c $<
%.d:%.cpp
$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
DEPENDS = $(OBJ:.o=.d)
include $(DEPENDS)

Error I get:
"
write_restart.o(.text+0x4bb): In function WriteRestart::write(char *)': : undefined reference to MPI_Send’
write_restart.o(.text+0x4c8): In function WriteRestart::write(char *)': : undefined reference to MPI_Wait’
write_restart.o(.text+0x4da): In function WriteRestart::write(char *)': : undefined reference to MPI_Get_count’
write_restart.o(.text+0x554): In function WriteRestart::write(char *)': : undefined reference to MPI_Recv’
write_restart.o(.text+0x574): In function WriteRestart::write(char *)': : undefined reference to MPI_Rsend’
make[1]: *** […/lmp_linux] Error 2
make[1]: Leaving directory `/home/pkc/tools/lammps-1Oct06/src/Obj_linux’
make: *** [linux] Error 2
"

I did find a relevant topic at https://forums.developer.nvidia.com/t/mpi-with-pgf90-and-mpich-on-an-opteron-cluster/130165/1
and on using -lmpich , I got similar errors but this time with pthreading
"
/home/pkc/tools/mpi-files/lib/libmpich.a(info_getnth.o)(.text+0x320): In function PMPI_Info_get_nthkey': : undefined reference to pthread_setspecific’
"

What is going wrong here? What should/shouldn’t I do to get it running.
Any suggestions are greatly appreciated.

Thanks,
Pavan K. Ghatty

Hi Pavan,

LAMMPS is a MPI program so you need to link with the MPICH libraries (or other MPI implementation). For the second error, add the pthreads library “-lpthreads” to your USRLIB variable.

  • Mat