Rookie HPC

Addressing

Datatypes

FORTRAN-legacy | FORTRAN-2008

MPI_ADDRESS_KIND

Definition

MPI_ADDRESS_KIND is the constant standing for the kind of integer in FORTRAN that represents a type able to contain a memory address. It is used in heterogeneous datatype creation routines for instance, such as MPI_Type_create_hindexed, MPI_Type_create_hindexed_block, MPI_Type_create_hvector and MPI_Type_create_struct. To see the C counterpart, please see MPI_Aint.

Example

Copy

Feedback

!> @brief Illustrate how to manipulate the MPI_ADDRESS_KIND datatype.
!> @details This application takes the address of elements at different
!> locations and calculates the distance, in bytes, between the two.
PROGRAM main
    USE mpi

    IMPLICIT NONE

    INTEGER :: ierror
    INTEGER :: a(0:9)
    INTEGER(KIND=MPI_ADDRESS_KIND) :: addr_1
    INTEGER(KIND=MPI_ADDRESS_KIND) :: addr_2
    INTEGER(KIND=MPI_ADDRESS_KIND) :: addr_gap

    CALL MPI_Init(ierror)

    CALL MPI_Get_address(a(2), addr_1, ierror)
    CALL MPI_Get_address(a(8), addr_2, ierror)
    addr_gap = MPI_Aint_diff(addr_2, addr_1)

    WRITE(*,'(A,A,I0,A)') 'Difference between the address of the 3rd int and 9th int', &
                        ' is ', addr_gap, ' bytes.'

    CALL MPI_Finalize(ierror)
END PROGRAM main