Problem compiling distributed memory code (MPI-MPICH)

Hi everybody!

I’m trying to compile the model WRF-CHEM model using the PGI compiler and the dmpar option (i.e.: distributed memory option using mpich). I’ve already installed MPICH following the PGI tutorial, and set the environmental variable MPI_ROOT pointing to the MPICH installation directory.

The problem is that the software does not compile correctly complaining that:

pgf90 -w -Mfree -byteswapio   -c  -I/home/modelstation/pgnetcdf/include -I../ioapi_share diffwrf.f
diffwrf io_netcdf is being built now. 
/usr/bin/ld: cannot find -lmpi
make[2]: [diffwrf] Error 2 (ignored)

What is -lmpi? is it a compiler flag? A header to include? In the MPICH folder I cannot find any file with that string in the name.

Sorry for the probably stupid question, I’m quite new at parallel computing.

Thanks in advance for all your help!

Hi AZaldei,

What is -lmpi?

“-l” is a compiler/linker flag stating the “libname.a” library should be linked with the user’s compiled code.

/usr/bin/ld: cannot find -lmpi

The linker can find where “libmpi.a” is located. You’re options are to use the “-L” to tell the linker the directory where this library is located, or use the “mpif90” driver instead of “pgf90”. “mpif90” is a wrapper which will automatically add the necessary MPI libraries.

If you are using the prebuilt MPICH libraries that we ship with the compilers, a third option would be to add the “-Mmpi=mpich” flag. This flag will set the appropriate “-L” and “-l” linker flags.

Hope this helps,
Mat

Thanks, Mat that was very helpful!

I was able to solve the problem following your suggestions!