J3/13-216 To: J3 From: Van Snyder Subject: Array as bounds specification for explicit-shape array Date: 2013 December 19 Reference: 04-136, 04-196; 2004 hate-dislike-like-love score 0-0-11-1 Title: Array as bounds specification for explicit-shape array Submitted by: Van Snyder Status: For consideration Basic functionality: Allow a rank-one explicit-shape array with constant shape as a bounds specification for an explicit-shape array. Rationale: For arrays with more than a few dimensions, it is tedious to specify their bounds in specification expressions individually if they are available as an array. One example is where they are the bounds of other arrays. It is impossible, not tedious, if all the bounds are calculated by one function reference and returned as an array, because function results cannot be subscripted. Estimated impact: Minor Markham M6 conformance: Remove simple deficiency and discrepancy. Detailed specification: Allow a rank-one explicit-shape array with constant shape as a bounds specification for an explicit-shape array. The rank of the declared array is the extent of the bounds array. Draft edits: To estimate scope of project Add an alternative to R515 R515 <> <> <> ... Add definition of to 5.3.8.2, near C531: R518a <> [ : ] R518b <> R518c <> C531a (R518a) If does not appear, shall be a rank-one constant-extent array. C531b (R518a) If both and appear, either one or both shall be rank-one constant-extent arrays, and their shapes shall conform. C531c (R518a) Each and shall be (1) a specification expression, (2) an array constructor with elements that are specification expressions and every is a constant expression, or (3) a reference to a standard intrinsic function other than NULL, or a specification function, with arguments that are specification expressions. An array is a constant-extent array if its bounds are constant expressions. Split 5.3.8.2p3 into 5.3.8.2p3 and 5.3.8.2p5 after "lower bound is 1". Add a paragraph 5.3.8.2p4 between those separated paragraphs: The values of and determine the bounds, and hence the extents, of all dimensions of an array. If appears it specifies the lower bounds; otherwise the lower bound of every dimension is 1. The rank of the array is the extent of if it is an array, and otherwise. Add a note at the end of 5.3.8.2: NOTE 5.12a Example of : SUBROUTINE EXA ( A ) REAL, INTENT(INOUT) :: A(:,:,:,:) REAL :: B(SHAPE(A)), C(FINDLOC(A,42)) The array B is an automatic array that has the same shape as A. The array C is an automatic array that has a shape determined by the first occurrence in array-element order of 42 in the array A.