MPICH

From Peyton Hall Documentation
Jump to navigation Jump to search

MPICH is an implementation of the Message Passing Interface commonly used in large parallel jobs. A lot of people run code linked with MPICH on HPC clusters, though some people also have it installed on desktop machines for multiprocessor development.


Environment

When you call the mpich compiler wrappers (mpicc, mpiCC, mpif77 and mpif90), they will usually use a generic compiler. If you wish to override any of these settings, then before you run the script set the following variables depending on which compiler(s) or linker(s) you wish to override:

  • MPICH_CC and MPICH_CLINKER - Used for compiling/linking C code
  • MPICH_CCC and MPICH_CCLINKER - Used for compiling/linking C++ code
  • MPICH_F77 and MPICH_F77LINKER - Used for compiling/linking Fortran 77 code
  • MPICH_F90 and MPICH_F90LINKER - Used for compiling/linking Fortran 90 code


mpif.h

The MPICH wrappers will automatically create a link for mpif.h in the current directory when they run. Therefore your code only needs to include the file in the current directory, not a hard-coded path, with INCLUDE 'mpif.h'


Known compatibility issue

There's a known compatibility issue with MPICH and PGI's Fortran compiler. When users tried to compile .f90 codes that use MPI, they'd get the following errors:

/opt/mpich-1.2.1/lib/libmpich.a(farg.o): In function `mpir_iargc__':
farg.o(.text+0x7): undefined reference to `f__xargc'
make: *** [nongaus_mpi] Error 2

It seems that this is a known problem (bug?) of PGI compilers, as it is explained at http://www.pgroup.com/faq/link.htm

  • Recompile the file farg.f with 'pgf77 -c' and add the object to the link before -lmpich. If the second underscore is needed for global names, remember to include the second underscore option. The source for farg.f is:
     integer function mpir_iargc()
     mpir_iargc = iargc()
     return
     end
     subroutine mpir_getarg( i, s )
     integer       i
     character*(*) s
     call getarg(i,s)
     return
     end

To compile, the command is then 'pgf77 -Msecond_underscore -c farg.f'. Others have noted that apparently you need to compile ALL code that uses MPICH with the -Msecond_underscore option for it to work properly.