8.281 THIS_IMAGE — Function that returns the cosubscript index of this image

Synopsis:
RESULT = THIS_IMAGE([TEAM])
RESULT = THIS_IMAGE(COARRAY [, DIM][, TEAM])
Description:

Returns the cosubscript for this image.

Class:

Transformational function

Arguments:
TEAM(optional, intent(in)) The team for which the index of this image is desired. The current team is used, when no team is given.
COARRAYCoarray of any type (optional; if DIM present, required).
DIMdefault integer scalar (optional). If present, DIM shall be between one and the corank of COARRAY.
Return value:

Default integer. If COARRAY is not present, it is scalar; if TEAM is not present, its value is the image index on the invoking image for the current team; if TEAM is present, returns the image index of the invoking image as given to the FORM TEAM (..., NEW_INDEX=..) call, or a implementation specific unique number, when NEW_INDEX= was absent from FORM TEAM. Otherwise when the COARRAY is present, if DIM is not present, a rank-1 array with corank elements is returned, containing the cosubscripts for COARRAY specifying the invoking image (in the team when TEAM is present). If DIM is present, a scalar is returned, with the value of the DIM element of THIS_IMAGE(COARRAY).

Example:
INTEGER :: value[*]
INTEGER :: i
value = THIS_IMAGE()
SYNC ALL
IF (THIS_IMAGE() == 1) THEN
  DO i = 1, NUM_IMAGES()
    WRITE(*,'(2(a,i0))') 'value[', i, '] is ', value[i]
  END DO
END IF

! Check whether the current image is the initial image
IF (THIS_IMAGE(GET_TEAM(INITIAL_TEAM)) /= THIS_IMAGE())
  error stop "something is rotten here"
Standard:

Fortran 2008 and later. With TEAM argument, Fortran 2018 or later

See also:

NUM_IMAGES — Function that returns the number of images,
IMAGE_INDEX — Function that converts a cosubscript to an image index