5.18 TARGET Attribute and Statement

The TARGET attribute specifies that an object can become the target of a pointer (it can be pointed to).

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

Type Declaration Statement:

type, [att-ls,] TARGET [, att-ls] :: object [(a-spec)] [, object [(a-spec)]]...

Statement:

TARGET [::] object [(a-spec)] [, object [(a-spec)]]...

type
Is a data type specifier.

att-ls
Is an optional list of attribute specifiers.

object
Is the name of the object. The object must not be declared with the PARAMETER attribute.

a-spec
Is an array specification.

Rules and Behavior

A pointer is associated with a target by pointer assignment or by an ALLOCATE statement.

If an object does not have the TARGET attribute or has not been allocated (using an ALLOCATE statement), no part of it can be accessed by a pointer.

Examples

The following example shows type declaration statements specifying the TARGET attribute:

TYPE(SYSTEM), TARGET :: FIRST
REAL, DIMENSION(20, 20), TARGET :: C, D

The following is an example of a TARGET statement:

TARGET :: C(50, 50), D

For More Information:


Previous Page Next Page Table of Contents