To: J3 J3/17-196
From: A. Shterenlikht
Subject: C.6.7 Accessing coarrays in sibling teams - omission
Date: 2017 September 25
References: N2137
Introduction:
~~~~~~~~~~~~~
Appendix C.6.7 shows how a programmer can
access coarrays in sibling teams.
The example program uses coarray-association
in the CHANGE TEAM construct.
The program is assumed to be run on 16 images.
The program logic crucially depends on a
particular image index numbering order
inside the CHANGE TEAM construct.
However, the FORM TEAM statement [562:17]
does not specify image indices in new teams,
i.e. the NEW_INDEX specifier is not used.
Therefore, the new indices will
be processor dependent, and might look e.g. like this:
team UL team UR
+---+---+ +---+---+
| 1 | 3 | | 4 | 3 |
+---+---+ +---+---+
| 4 | 2 | | 2 | 1 |
+---+---+ +---+---+
team LL team LR
+---+---+ +---+---+
| 3 | 1 | | 2 | 4 |
+---+---+ +---+---+
| 2 | 4 | | 1 | 3 |
+---+---+ +---+---+
Therefore the code in lines [562:32] and [562:34]
will not work as intended, because
NEWPE==3 and NEWPE==4 in team UL
are not guaranteed to be the 2 images
on the right boundary of the grid.
I think the use of NEW_INDEX in FORM TEAM [562:17]
is necessary to make the code work as expected.
I think extra code is needed, something like this:
integer new_ind, ind(2,2), oe1, oe2
ind = this_image( a )
oe1 = mod( ind(1), 2 )
oe2 = mod( ind(2), 2 )
if ( oe1 .eq. 1 .and. oe2 .eq. 1 ) new_ind = 1 ! odd1 odd2
if ( oe1 .eq. 0 .and. oe2 .eq. 1 ) new_ind = 2 ! even1 odd2
if ( oe1 .eq. 1 .and. oe2 .eq. 0 ) new_ind = 3 ! odd1 even2
if ( oe1 .eq. 0 .and. oe2 .eq. 0 ) new_ind = 4 ! even1 even2
FORM TEAM( TEAMNUM, T, new_ind )
which will produce the desired image numbering in the new teams:
team UL team UR
+---+---+ +---+---+
| 1 | 3 | | 1 | 3 |
+---+---+ +---+---+
| 2 | 4 | | 2 | 4 |
+---+---+ +---+---+
team LL team LR
+---+---+ +---+---+
| 1 | 3 | | 1 | 3 |
+---+---+ +---+---+
| 2 | 4 | | 2 | 4 |
+---+---+ +---+---+
Edit to N2137:
~~~~~~~~~~~~~~
Add at the end of line [562:6] (4 more integer variables):
", NEW_IND, IND(2,2), OE1, OE2"
Insert after [562:16] new code to define new_index on
all images:
IND = THIS_IMAGE( A )
OE1 = MOD( IND(1), 2 )
OE2 = MOD( IND(2), 2 )
IF ( OE1 .EQ. 1 .AND. OE2 .EQ. 1 ) NEW_IND = 1 ! ODD1 ODD2
IF ( OE1 .EQ. 0 .AND. OE2 .EQ. 1 ) NEW_IND = 2 ! EVEN1 ODD2
IF ( OE1 .EQ. 1 .AND. OE2 .EQ. 0 ) NEW_IND = 3 ! ODD1 EVEN2
IF ( OE1 .EQ. 0 .AND. OE2 .EQ. 0 ) NEW_IND = 4 ! EVEN1 EVEN2
Replace [562:17]
FORM TEAM (TEAMNUM, T)
with
FORM TEAM (TEAMNUM, T, NEW_IND)