Problems in Compiling Gromacs

When I trying to compile Gromacs-3.2.1, there are two errors occured:

pgcc -DHAVE_CONFIG_H -I. -I. -I…/…/src -I…/…/include
-DGMXLIBDIR="/public/bin/gromacs/share/top" -I/usr/mpich-gm-pgi60/include
-I/opt/gm/binary/include -I/opt/gm/include -I/public/bin/fftw2.1.5/include
-I/usr/include/libxml2 -tp=k8-64 -I/usr/include/libxml2 -c tpxio.c -o tpxio.o
PGC-W-0095-Type cast required for this conversion (tpxio.c: 997)
PGC-S-0090-Scalar data type required for logical expression (tpxio.c: 1322)
PGC/x86-64 Linux/x86-64 6.0-2: compilation completed with severe errors
make[3]: *** [tpxio.lo] Error 1
make[3]: Leaving directory
/public/home/develop/software/gromacs-3.2.1/src/gmxlib' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory /public/home/develop/software/gromacs-3.2.1/src’
make[1]: Leaving directory `/public/home/develop/software/gromacs-3.2.1/src’
make: *** [all-recursive] Error 1

I have checked the source code of the program,
In the file tpxio.c: line 997 is:
The third parameter in the prototype of function pr_block is “const char*”

tpxio.c: line 1322 is: if (*box) copy_mat(,box);

This program can be compiled with GNU C compiler. But throughout errors with pgcc. Is there any compiling options that can told the compiler not to do the check? Thanks._


What is the type for formal argument #3 in the pr_block prototype? Is it char*? If so, when I tried a similar example with gcc I also received a warning. The program still compiled and ran with this warning, although it is probably a good idea to include a type case to eliminate this warning. As for the error, what is the type for box? I could not recreate an example that gave the same error that you received.


The type for formal argument #3 in the pr_block prototype is “const char*”

“box” is a parameter of the function. The prototype is defined as a matrix. But I can’t find the definition of matrix.
void read_tpx(char *fn,int *step,real *t,real *lambda,
t_inputrec *ir, matrix box,int *natoms,
rvec *x,rvec *v,rvec *f,t_topology *top)

By the way, Gromacs can be compiled smoothly with GCC,and running well.

The definition of matrix is in …/include/types/simple.h
It is a 2D array of real elements.

typedef real matrix[DIM][DIM];


I was not able to reproduce the warning on the pr_box case. I could only produce it if I was passing a const char * actual argument to a char * formal argument. Nonetheless, it seems the important issue is the severe error you are getting on the “if (*box)” expression.

The box object is declared a matrix which, according to you, is typedef to a statically allocated two dimensional array. The way *box gets interpretted is implementation defined. For example, gcc and the Sun compiler do not complain. Perhaps they interpret box[DIM][DIM] as an array of pointers rather than an array of arrays. Our compiler interprets box[DIM][DIM] as an array of arrays. Therefore, *box is semantically giving you an array rather than a pointer to an array. Hence, the error. ICC seems to interpret this the same way too, as it generates a warning. Perhaps our compiler should just generate a warning too.

My guess is that once upon a time this code used dynamic memory allocation for the matrix and the expression “if (box)" is checking to make sure the second dimension is not NULL. Otherwise, I can’t figure out why this check is there in the first place – it’s always true with statically allocated arrays. Anyway, to work around this problem, you can add a cast (e.g., "if ( (matrix) *box)”) and the code should compile without issue on any C compiler.


Thanks very much Mark, The problem is solved by adding an explicit convertion of the pointer (matrix*). I think there must be a bug of the program, because the ‘box’ according to its definition matrix which is a static real 2D array rather than an dynamically allocated array of arrays.

I encountered another problem. The ‘–rpath’ option was not recognized by the pgcc compiler. Is there any other options in pgcc that perform the function of the --rpath? Thanks for your help.

Please try using -Wl,–rpath,(your path)

Also as a follow-up to your previous question… We are looking into fixing the “error message” that your program exposed for the next release of pgcc. We may issue a warning or just do what GCC does and just ignore it. Thanks for bringing this issue to our attention.