1

Is there a practical difference between MPI's MPI_REAL8 and MPI_DOUBLE_PRECISION? In other words, is there any modern machine architecture for which these two types aren't guaranteed to occupy the same amount of memory? Can they be used interchangeably?

francescalus
  • 30,576
  • 16
  • 61
  • 96
Joe Todd
  • 814
  • 6
  • 13

1 Answers1

2

MPI_REAL8 and MPI_DOUBLE_PRECISION are not interchangeable.

For one reason, MPI_REAL8 is an optional named constant and so may not exist in your implementation at all.

Beyond that, MPI_REAL8, if it exists, maps to a REAL*8 "Fortran" object, and MPI_DOUBLE_PRECISION maps to a DOUBLE PRECISION object. These needn't be the same thing: with gfortran consider the compile-time option -fdefault-real-8 and the following program:

 implicit none

 real*8 x
 double precision y

 print*, STORAGE_SIZE(x), STORAGE_SIZE(y)
end

More generally, you can use techniques in answer to this related question to avoid worrying about which MPI named constant to use for your Fortran objects.

francescalus
  • 30,576
  • 16
  • 61
  • 96
  • 2
    It might be worth mentioning in Modern Fortran a good way to determine what to use is via MPI_TYPE_CREATE_REAL (and related), as this can be used to match directly onto the compilers kind values. – Ian Bush Jan 05 '21 at 13:48