compilation issue with COUPLE library

Dear developers:

I tried to compile the routines in the directory lammps-16Feb16/examples/COUPLE/library as a library following README in that folder, but got the following errors:

many2many.cpp: In constructor ‘Many2Many::Many2Many(MPI_Comm)’:

many2many.cpp:22:24: error: ‘NULL’ was not declared in this scope

src_own = dest_own = NULL;

^

many2many.cpp: In member function ‘void Many2Many::setup(int, int*, int, int*)’:

many2many.cpp:235:53: error: ‘sprintf’ was not declared in this scope

sprintf(str,“BAD SRC %d: %d %d\n”,me,i,work[i]);

^

many2many.cpp:245:54: error: ‘sprintf’ was not declared in this scope

sprintf(str,“BAD DEST %d: %d %d\n”,me,i,work[i]);

^

make: *** [many2many.o] Error 1

one2many.cpp: In member function ‘void One2Many::scatter(double*, int, double*)’:

one2many.cpp:49:14: error: ‘NULL’ was not declared in this scope

if (src == NULL) {

^

make: *** [one2many.o] Error 1

Then I included stdlib.h and stdio.h into many2many.cpp, and stdlib.h into one2many.cpp, and now it can compile. mpicxx (mvapich2.2b with gcc-4.9.3) was used for compilation in a cluster. I searched the bug fixes list and the mailing list but am not able to find any related issues.

One strange thing is that these routines can be compiled without any errors using mpicxx (openmpi-1.8.1 with gcc-4.8.4) on my desktop.

Regards,

-Xikai

Xikai Jiang
Postdoctoral Researcher
Materials Science Division, Argonne National Laboratory
[email protected]…12…3203… 1-630-252-5472

Dear developers:

I tried to compile the routines in the directory
*lammps-16Feb16/examples/COUPLE/library* as a library following README in
that folder, but got the following errors:

*many2many.cpp: In constructor ‘Many2Many::Many2Many(MPI_Comm)’:*

*many2many.cpp:22:24: error: ‘NULL’ was not declared in this scope*

* src_own = dest_own = NULL;*

* ^*

*many2many.cpp: In member function ‘void Many2Many::setup(int, int*, int,
int*)’:*

*many2many.cpp:235:53: error: ‘sprintf’ was not declared in this scope*

* sprintf(str,"BAD SRC %d: %d %d\n",me,i,work[i]);*

* ^*

*many2many.cpp:245:54: error: ‘sprintf’ was not declared in this scope*

* sprintf(str,"BAD DEST %d: %d %d\n",me,i,work[i]);*

* ^*

*make: *** [many2many.o] Error 1*

*one2many.cpp: In member function ‘void One2Many::scatter(double*, int,
double*)’:*

*one2many.cpp:49:14: error: ‘NULL’ was not declared in this scope*

* if (src == NULL) {*

* ^*

*make: *** [one2many.o] Error 1*

Then I included stdlib.h and stdio.h into many2many.cpp, and stdlib.h into
one2many.cpp, and now it can compile. mpicxx (mvapich2.2b with gcc-4.9.3)
was used for compilation in a cluster. I searched the bug fixes list and
the mailing list but am not able to find any related issues.

​thanks for reporting this. this is a bug.​

One strange thing is that these routines can be compiled without any
errors using mpicxx (openmpi-1.8.1 with gcc-4.8.4) on my desktop.

​this is not strange, but it just so happens, that the mpi.h file from
openmpi includes <stdio.h> and <stdlib.h>, while the corresponding header
from MPICH and its derivatives​ does not.

your suggested change is the correct approach. i'll integrate it and
forward the changes to steve at the next opportunity, so that it will be
corrected in future releases of LAMMPS.

thanks again,
    axel.

OK, I see. Thanks.

Xikai