Navigation and service

Error message ‘Invalid communicator’ when using BLACS and MPI

When BLACS (Basic Linear Algebra Communication Subprograms) is used in FORTRAN together with MPI the routine BLACS_GRIDINIT expects among others an MPI communicator as input argument. Leaving the routine, this communicator is overwritten by an internal BLACS context number. This context number is in general not a valid MPI communicator anymore. Using it for MPI routines might eventually result in an error message like:

Fatal error in MPI_Attr_get: Invalid communicator, error stack

You should save the corresponding MPI communicator before calling BLACS_GRIDINIT to use it for further MPI calls in order to avoid this error.

Hint: This error might be difficult to detect. On a number of systems the MPI_COMM_WORLD communicator is set to 0 (zero). Incidentally, the BLACS context number is zero on many systems, too. Therefore, the code might run just fine on such systems, since the communicator and the context number have identical values. However, on the BG/P the MPI_COMM_WORLD is set to 0x44 and the code aborts.