J3/05-273 Date: 21 October 2005 To: J3 From: Bill Long Subject: Specification, syntax and edits for contiguous attribute References: Feature j3-043, 05-149r2, 05-186, 05-235r3 ---------------------------------------------------------------------- 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 that is contiguous or that an assumed-shape dummy argument is contiguous. 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. A contiguous pointer may be a structure component as well as a named variable. An object is contiguous 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 result is .true. if the argument is contiguous, 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. ..................................................................... [xiii] Introduction, the list of new Fortran 2008 features should include "Performance enhancements: CONTIGUOUS attribute." ..................................................................... In section 1.6 Compatibility, there are no changes needed. ..................................................................... [50:7+] In the list of allowed (R441) add: or CONTIGUOUS ..................................................................... [50:31+] Add a new constraint: C443a (R440) If the CONTIGUOUS attribute is specified, the POINTER attribute shall be specified. ..................................................................... [71:20+] In the list of allowed (R503) add: or CONTIGUOUS ..................................................................... [72:29+] Add two new constraints: C512a (R501) An entity with the CONTIGUOUS attribute shall also have the POINTER attribute or shall be an assumed-shape array. C512b (R501) An entity with the CONTIGUOUS attribute shall be a data object. ..................................................................... [78:2-] Add a new subsection: 5.1.2.4a CONTIGUOUS attribute The <> specifies that an assumed-shape array is contiguous and is sequence associated with its associated actual argument, or that the target of an associated pointer is contiguous. A pointer with the CONTIGUOUS attribute shall become associated only by means of allocation or by pointer assignment to a target that is contiguous. An object is <> if it is not the real or imaginary part of an array of type complex, and is: (1) an object with the CONTIGUOUS attribute, (2) a scalar object, (3) an explicit-shape, assumed-size, or allocatable array, (4) an array allocated with an ALLOCATE statement, (5) an assumed-shape array that is argument associated with an array that is contiguous, (6) a pointer associated with a contiguous target, (7) an array with zero or one elements, or (8) an non-zero sized array section (6.2.2) with the following properties: (a) Its base object is contiguous. (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). (e) Only its final has nonzero rank. Note 5.10a If a derived type has only one component, it is processor-dependent whether a structure component of a contiguous array of that type is contiguous. If each of the elements of an array occupies no storage, it is processor-dependent whether a section of that array with non-unit stride is contiguous. [end Note] Note 5.10b 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, the rank and shape". ..................................................................... [296:15+] Add a new function to the list in 13.5.8 of Other inquiry functions: IS_CONTIGUOUS(A) Contiguity status ..................................................................... [325:7+] Add a description for a new intrinsic function: 13.7.56a IS_CONTIGUOUS(A) Description: Determine whether an object is contiguous (5.1.2.4a). Class: Inquiry function. Argument: A may be of any type. 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 A is contiguous the result value is .true., and is .false. otherwise.