this_image

Date:

06-19-2023

NAME

THIS_IMAGE - Returns the index of, or cosubscripts related to, the invoking Coarray Fortran image

SYNOPSIS

THIS_IMAGE([[ARRAY=]array[,[DIM=]dim]])

STANDARDS

Fortran extension

DESCRIPTION

THIS_IMAGE is a Coarray Fortran intrinsic function that allows an image to retrieve its own image number. It returns the index of or cosubscripts related to the invoking image. It is an inquiry function.

THIS_IMAGE accepts the following arguments:

array

The name of a coarray

dim

A cosubscript

RETURN VALUES

The results differ, as follows, depending on the optional arguments specified:

  • If array is absent, the result is a default integer scalar with a value equal to the index of the invoking image.

  • If array is present with a corank of one and dim is absent, the result is a default integer scalar with a value equal to the cosubscript of the elements of array that reside on the invoking image.

  • If array is present with a corank greater than one and dim is absent, the result is a rank one default integer array of a size equal to the corank of array. Element k of the result has a value equal to the cosubscript k of the elements of array that reside on the invoking image.

  • If array and dim are present, the result is a default integer scalar with value equal to cosubscript dim of the elements of array that reside on the invoking image.

EXAMPLES

Assume that the following declaration exists in a program:

REAL :: A(100)[8,4]

The following table lists various THIS_IMAGE calls and the values they return on images 3 and 13:

Call                    Image 3                 Image 13
----                    -------                 --------
THIS_IMAGE()            3                       13
THIS_IMAGE(A)           (/ 3, 1 /)              (/ 5, 2 /)
THIS_IMAGE(A,1)         3                       5
THIS_IMAGE(A,2)         1                       2

SEE ALSO

num_images(3i)