Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 6/24/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

CONTIGUOUS

Statement and Attribute: Specifies that the target of a pointer or an assumed-sized array is contiguous.

The CONTIGUOUS attribute can be specified in a type declaration statement or an CONTIGUOUS statement, and takes one of the following forms:

Type Declaration Statement:

type, [att-ls,] CONTIGUOUS [, att-ls] :: object [, object] ...

Statement:

CONTIGUOUS [::] object [, object] ...

type

Is a data type specifier.

att-ls

Is an optional list of attribute specifiers.

object

Is an assumed-shape array or an array pointer.

Description

This attribute explicitly indicates that an assumed-shape array is contiguous or that a pointer will only be associated with a contiguous object.

An entity can be contiguous even if CONTIGUOUS is not specified. An object is contiguous if it is one of the following:

  • An object with the CONTIGUOUS attribute

  • A nonpointer whole array that is not assumed-shape

  • An assumed-shape array that is argument associated with an array that is contiguous

  • An array allocated by an ALLOCATE statement

  • An pointer associated with a contiguous target

  • A nonzero-sized array section in which the following is true:

    • Its base object is contiguous.

    • It does not have a vector subscript.

    • The elements of the section, in array element order, are a subset of the base object elements that are consecutive in array element order.

    • If the array is of type character and a substring-range appears, the substring-range specifies all of the characters of the parent-string.

    • Only its final reference to a structure component, if any, has nonzero rank

    • It is not the real or imaginary part of an array of type complex.

An object is not contiguous if it is an array subobject, and all of the following are true:

  • The object has two or more elements.

  • The elements of the object in array element order are not consecutive in the elements of the base object.

  • The object is not of type character with length zero.

  • The object is not of a derived type that has no ultimate components other than zero-sized arrays and characters with length zero.

The CONTIGUOUS attribute can make it easier to enable optimizations that rely on the memory layout of an object occupying a contiguous block of memory.

An array variable is considered to be simply contiguous if and only if it is a simply contiguous array designator, or a reference to a function that returns a pointer that has the CONTIGUOUS attribute. An array designator is simply contiguous if and only if it is one of the following:

  • An object name that has the CONTIGUOUS attribute

  • An object that is not assumed-rank, assumed shape, or a pointer

  • A component of a derived type whose final part-name is an array, and is either not a pointer, or it has the CONTIGUOUS attribute

  • An array section that complies with these rules:

    • It does not have a substring range

    • It is not a complex-part designator

    • Its final part-ref has a nonzero rank

    • Its rightmost part-name has the CONTIGUOUS attribute or is neither assumed-shape or a pointer

    • It does not have a section-subscript list, or if it does, it has a section-subscript list that specifies a simply contiguous section

A section-subscript list specifies a simply contiguous array section if and only if it does not have a vector subscript and the following is true:

  • All but the last subscript-triplets are a colon (the last can also be a colon)

  • The last subscript-triplet does not specify a stride

  • No subscript triplet is preceded by a section-subscript that is simply a subscript

Examples

The following examples show valid CONTIGUOUS statements:

REAL, CONTIGUOUS, DIMENSION(:,:) :: A
REAL, POINTER, CONTIGUOUS :: MY_POINTER(:)