08-277r2 To: J3 From: Malcolm Cohen Subject: Revised edits for in Date: 2008 November 18 Reference: 08-203r1 1. Introduction This paper contains editorial and fixes minor technical omissions in the description of the DO CONCURRENT statement. No change in technical content is intended. 2. Discussion 08-203r1 observes that the possibility that a might appear in the of a DO CONCURRENT construct has not been considered in 8.1.7.6.1p7. It proposes to insert a paragraph very much like 7.2.4.1p2 in 8.1.7.1 after C819 and delete 8.1.7.6.1p7. This violates the Weaver Rule. The (almost) correct paragraph, which is very much like 7.2.4.1p2, is already in 16.4p7, which is the correct place, so 7.2.4.1p2 also violates the Weaver rule. It would be better to replace 7.2.4.1p2 and 8.1.7.6 by notes that refer to 16.4, and adjust 16.4p7 to apply both to FORALL and DO CONCURRENT. JOR agrees in principle with the edits in 08-277 but notes that their application would leave 7.2.4.1 with six consecutive notes occupying one and a half pages which describe FORALL by example rather than by normative text. All but one of the sample program fragments should be moved to Annex C.4.5. 3. Edits to 08-007r2 [162: 7.2.4.1 C744+] Insert new paragraph "The scope and attributes of an in a are described in 16.4." {16.4 is called "Statement and construct entities".} [162-163: 7.2.4.1 Notes 7.53 and 7.54] -------------------------------- Editor: Delete Notes 7.53 and 7.54 [163: 7.2.4.1p2] ------------------------------------------------------- Editor: Delete the paragraph. [163-164 7.2.4.1 Notes 7.55 and 7.56] ---------------------------------- Editor: Delete Notes 7.55 and 7.56 [175:8.1.7.1p2] After "DO WHILE).", change "Except ... construct" to "The execution order of the iterations can be left indeterminate (DO CONCURRENT); except in this case,". {Give a decent definition of what it means to be DO CONCURRENT, don't just give one of its limitations.} [176:8.1.7.1p4] Replace with "The scope and attributes of an in a are described in 16.4." {The perfect position for this, replacing the empty and unnecessary "definition".} [178: 8.1.7.6.1p7] ----------------------------------------------------- Editor: Delete the paragraph (which is in the wrong place anyway). [442: 16.4p7] In the middle of the paragraph, After "that includes the FORALL" (before the comma) Insert "or DO CONCURRENT". {DO CONCURRENT missing from this sentence.} [480: C.4.5] ---------------------------------------------------------- Editor: Replace clause title "<>" by "<>" [480: 0+] ------------------------------------------------------------ Editor: Insert: Example 1: An assignment statement that is a FORALL body construct may be a scalar or array assignment statement, or a defined assignment statement. The variable being defined will normally use each index name in the . For example, FORALL (I = 1:N, J = 1:N) A(:, I, :, J) = 1.0 / REAL(I + J - 1) END FORALL broadcasts scalar values to rank-two subarrays of A. Example 2: An example of a FORALL construct containing a pointer assignment statement is: TYPE ELEMENT REAL ELEMENT_WT CHARACTER (32), POINTER :: NAME END TYPE ELEMENT TYPE(ELEMENT) CHART(200) REAL WEIGHTS (1000) CHARACTER (32), TARGET :: NAMES (1000) . . . FORALL (I = 1:200, WEIGHTS (I + N - 1) > .5) CHART(I) % ELEMENT_WT = WEIGHTS (I + N - 1) CHART(I) % NAME => NAMES (I + N - 1) END FORALL The results of this FORALL construct cannot be achieved with a WHERE construct because a pointer assignment statement is not permitted in a WHERE construct. Example 3: The use of variables in a FORALL construct does not affect variables of the same name, for example: INTEGER :: X = -1 REAL A(5, 4) J = 100 . . . FORALL (X = 1:5, J = 1:4) ! Note that X and J are local to the FORALL. A (X, J) = J END FORALL After execution of the FORALL, the variables X and J have the values -1 and 100 and A has the value 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 Example 4: The type and kind of the variables may be declared independently of the type of any normal variable in the scoping unit. For example, in SUBROUTINE s(a) IMPLICIT NONE INTEGER, PARAMETER :: big = SELECTED_INT_KIND(18) REAL a(:,:), x, theta ... FORALL ( INTEGER(big) :: x=1:SIZE(a,1,big), y=1:SIZE(a,2,big), a(x,y)/=0 ) a(x,y) = 1 / a(x,y)**2 END FORALL ... the kind of the s X and Y is selected to be big enough for subscript values even if the array A has more than 231 elements. Since the type of the s X and Y in the FORALL construct are declared explicitly in the FORALL header, it is not necessary for integer variables of the same names to be declared in the containing scoping unit. In this example, there is a variable X of type real declared in the containing scoping unit, and no variable Y declared in the containing scoping unit. Example 5: Example of a FORALL construct containing a WHERE construct. ===END===