Visible to Intel only — GUID: GUID-7FAE9A2B-55E8-47D5-9CFC-2B224727D91D
Visible to Intel only — GUID: GUID-7FAE9A2B-55E8-47D5-9CFC-2B224727D91D
IMAGE_INDEX
Transformational Intrinsic Function (Generic): Converts cosubscripts to an image index.
result = IMAGE_INDEX (coarray, sub)
result = IMAGE_INDEX (coarray, sub, team)
result = IMAGE_INDEX (coarray, sub, team_number)
coarray |
(Input) Must be a coarray; it can be of any type. |
sub |
(Input) Must be a rank-one integer array of size equal to the corank of coarray. |
team |
(Input) Must be a scalar of type TEAM_TYPE defined in the intrinsic module ISO_FORTRAN_ENV. Its value must identify the current or an ancestor team. |
team_number |
(Input) Must be an integer scalar. It must identify the initial team (-1) or a team formed by the same execution of the FORM TEAM statement that created the current team (a sibling team of the current team). |
The result is default integer scalar. The result is the index of the corresponding image if the value of sub is a valid sequence of cosubscripts for coarray on the team specified by team or team_number, or for the current team if neither team nor team_number is specified. Otherwise, the result is zero.
If coarray D is declared as D [0:*] and coarray C is declared as C(5,10) [10, 0:9, 0:*], IMAGE_INDEX (D, [0]) has the value 1 and IMAGE_INDEX (C, [3, 1, 2]) has the value 213 (on any image).
Consider the following program:
PROGRAM main
USE, INTRINSIC :: ISO_FORTRAN_ENV
TYPE (TEAM_TYPE) :: initial, odd_even
REAL :: ca1[4:*], ca2[2, *]
INTEGER :: i, j, k, l
initial = GET_TEAM (CURRENT_TEAM)
FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even)
PRINT *, THIS_IMAGE()
PRINT *, THIS_IMAGE (coarray1)
PRINT *, THIS_IMAGE (coarray2, 2)
CHANGE TEAM (odd_even)
. . .
i = IMAGE_INDEX(ca1, [6], 2)
j = IMAGE_INDEX(ca1, [6], 1)
k = IMAGE_INDEX(ca2, [2, 4], initial)
l = IMAGE_INDEX(ca1, [12], -1)
. . .
END TEAM
. . .
END PROGRAM
If there are 10 images on the initial team, ca1[4] will be on image 1, ca1[5] on image 2, and ca1[13] will be on image 10. Similarly, ca2[1, 1] will be on image 1, ca[2, 1] on image 2, ending with ca2[2, 5] will be on image 10. The FORM TEAM statement divides the images into two teams, with team 1 having images [1, 3, 5, 7, 9] with image numbers [1, 2, 3, 4, 5] respectively, and team 2 having images [2, 4, 6, 8, 10] with image numbers [1, 2, 3, 4, 5] respectively.
After the 4 calls to IMAGE_INDEX, the value of i will be zero (ca1[6] is not on an image in team 2), j will have the value 2, k will have the value 8, and l will have the value 9. Note that the team number -1 always refers to the initial team. Note also that if the FORM TEAM does not specify NEW_INDEX, the image numbers on the new teams formed by the FORM TEAM are assigned in a processor-dependent manner.