Rookie HPC

Addressing

C | FORTRAN-legacy | FORTRAN-2008

MPI_Get_address

Definition

MPI_Get_address retrieves the memory address of of the element given.

Copy

Feedback

int MPI_Get_address(const void* location,
                    MPI_Aint* address);

Parameters

location
The element to obtain the address of.
address
The variable in which store the address of the element passed.

Returned value

The error code returned from the memory address retrieval.

MPI_SUCCESS
The routine successfully completed.

Example

Copy

Feedback

#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>

/**
 * @brief Illustrate how to obtain the address of an element.
 **/
int main(int argc, char* argv[])
{
    MPI_Init(&argc, &argv);

    int a[10];

    MPI_Aint addr;
    MPI_Get_address(&a[2], &addr);

    printf("The address of the third element is %ld.\n", addr);

    MPI_Finalize();

    return EXIT_SUCCESS;
}