The GNU Fortran Compiler: THIS_IMAGE

Next: TIME, Previous: TANH, Up: Intrinsic Procedures [Contents][Index]

### 9.266 `THIS_IMAGE` — Function that returns the cosubscript index of this image

Description:

  Returns the cosubscript for this image.

Standard:

  Fortran 2008 and later. With DISTANCE argument, Technical Specification (TS) 18508 or later

Class:

  Transformational function

Syntax:

  `RESULT = THIS_IMAGE()`
  `RESULT = THIS_IMAGE(DISTANCE)`
  `RESULT = THIS_IMAGE(COARRAY [, DIM])`

Arguments:

  DISTANCE | (optional, intent(in)) Nonnegative scalar integer (not permitted together with COARRAY).
  COARRAY | Coarray of any type (optional; if DIM present, required).
  DIM | default 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 DISTANCE is not present or has value 0, its value is the image index on the invoking image for the current team, for values smaller or equal distance to the initial team, it returns the image index on the ancestor team which has a distance of DISTANCE from the invoking team. If DISTANCE is larger than the distance to the initial team, the image index of the initial team is returned. 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. 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(HUGE(1)) /= THIS_IMAGE())
        error stop "something is rotten here"

See also:

  NUM_IMAGES, IMAGE_INDEX

Next: TIME, Previous: TANH, Up: Intrinsic Procedures [Contents][Index]