J3/05-235r3 Date: 11 August 2005 To: J3 From: Rob James Subject: Specification, syntax and edits for contiguous attribute References: Feature j3-043, 05-149r2, 05-186 ---------------------------------------------------------------------- Summary: -------- Provide a method to indicate that the target of a pointer or a dummy argument is contiguous. Specification and Syntax: ------------------------- Provide a declaration attribute, CONTIGUOUS, that specifies that the pointer being declared will only be associated with a target occupying contiguous storage or that the elements of an assumed-shape dummy argument occupy contiguous storage. The processor may need to make a contiguous copy of an entity associated with a dummy argument with the contiguous attribute. For example, real, pointer, contiguous :: sptr(:) real, contiguous, dimension(:,:) :: d A corresponding CONTIGUOUS :: statement is also provided. An object occupies contiguous storage if it is zero-size, a scalar, or an array with its elements occupying consecutive memory locations in array element order. An intrinsic function, IS_CONTIGUOUS(A), is provided. The argument is an array or array section. The result is .true. if the argument occupies contiguous storage, and .false. otherwise. Edits: ------ Note: < and > are used to delimit italic font. << and >> are used to delimit bold font. All page and line numbers refer to j3/04-007. ..................................................................... In the Introduction section (page xiii), the list of new Fortran 2008 features should include Performance enhancements: CONTIGUOUS attribute ..................................................................... In section 1.6 Compatibility, there are no changes needed. ..................................................................... 71:20+. In the list of allowed (R503) add: or CONTIGUOUS ..................................................................... 72:29+. Add four new constraints: C512a (R501) If the CONTIGUOUS attribute is specified, the POINTER attribute shall also be specified, or the shall be an assumed-shape array. C512b (R501) If the CONTIGUOUS and POINTER attributes are specified, the shall be a data object. C512c (R501) The CONTIGUOUS attribute shall not be specified for an object that is allocatable, or an object with a declared type with allocatable components. C512d (R501) The CONTIGUOUS attribute shall not be specified for an object of a derived type that has length type parameters. ..................................................................... 78:2-. Add a new subsection: 5.1.2.4a CONTIGUOUS attribute The <> specifies that an assumed-shape array occupies contiguous storage and is sequence associated with its associated actual argument, or that the target of an associated pointer occupies contiguous storage. A pointer with the CONTIGUOUS attribute shall become associated only by successful execution of an ALLOCATE statement referencing the pointer or by pointer-assignment to a target with the CONTIGUOUS attribute or a target that occupies contiguous storage. An object occupies <> if it has no allocatable components, is not a derived type with length type parameters, and is: (1) a scalar object, (2) an explicit-shape array, an assumed-size array, (3) an array allocated with an ALLOCATE statement, (4) an assumed-shape array that is argument associated with an array that occupies contiguous storage, (5) a zero-sized array, or (6) an array section (6.2.2) with the following properties: (a) Its base object occupies contiguous storage. (b) It does not have a vector subscript. (c) The elements of the section are a subset of the base object elements that are consecutive in array element order. (d) If the array is of type character and a appears, the specifies all of the characters of the (6.1.1). (d) Only its final has nonzero rank. Note 5.10a The CONTIGUOUS attribute allows a processor to enable optimizations that depend on the memory image of the object occupying a contiguous block of memory. Examples of CONTIGUOUS attribute specifications are: REAL, POINTER, CONTIGUOUS :: SPTR(:) REAL, CONTIGUOUS, DIMENSION(:,:) :: D [end Note] ..................................................................... 87:12+. Add a new subsection: 5.2.4a CONTIGUOUS statement R523a is CONTIGUOUS [::] The CONTIGUOUS statement specifies the CONTIGUOUS attribute (5.1.2.4a) for a list of objects. ..................................................................... 270:5-6. Replace "either a scalar or an assumed-shape array" with "either a scalar or an assumed-shape array that does not have the CONTIGUOUS attribute." ..................................................................... 270:13-14. Replace "is an explicit-shape array or is an assumed-size array" with "is an assumed-shape array with the CONTIGUOUS attribute, an explicit-shape array, or an assumed-size array". ..................................................................... 272:19-20. Replace "if the dummy argument is an explicit-shape or assumed-size array" with "if the dummy argument is an assumed-shape array with the CONTIGUOUS attribute, an explicit-shape array, or an assumed-size array". ..................................................................... 272:20. Replace "The rank and shape" with "If the dummy argument is not an assumed-shape array, then the rank and shape". ..................................................................... 296:15+. Add a new function to the list in 13.5.8 of Other inquiry functions: IS_CONTIGUOUS(ARRAY) Storage contiguity status ..................................................................... 325:7+. Add a description for a new intrinsic function: 13.7.56a IS_CONTIGUOUS(ARRAY) Description: Determine whether an array occupies contiguous storage (5.1.2.4a). Class: Inquiry function. Argument: ARRAY may be of any type. It shall not be a scalar. If it is allocatable, it shall be allocated. If it is a pointer, it shall be associated. Result Characteristics: Default logical scalar. Result Value: If ARRAY occupies contiguous storage the result is .true., and is .false. otherwise.