As shown in Example ,
page
, one sometimes needs to be able to
find the displacement, in bytes, of a structure component relative to the
structure start. In C, one can use the sizeof operator to
find the size of C objects; and one will be tempted to use the
& operator to compute addresses and then displacements.
However, the C standard does not require that (int)& be the
byte address of variable v: the mapping of pointers to
integers is implementation dependent. Some systems may have ``word''
pointers and ``byte'' pointers; other systems may have a segmented,
noncontiguous address space. Therefore, a portable mechanism has to be
provided by MPI to compute the ``address'' of a variable. Such a
mechanism is certainly needed in Fortran, which has no dereferencing
operator.
addressderived datatype, address
MPI_ADDRESS(location, address) IN location variable representing a memory location OUT address address of locationMPI_Address(void* location, MPI_Aint *address)
MPI_ADDRESS(LOCATION, ADDRESS, IERROR)<type> LOCATION(*)
INTEGER ADDRESS, IERROR
MPI_ADDRESS is used to find the address of a location in memory. It returns the byte address of location.