Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
E77790.pdf
Скачиваний:
2
Добавлен:
16.05.2024
Размер:
1.29 Mб
Скачать

4.3 Cray Pointers

4.3Cray Pointers

A Cray pointer is a variable whose value is the address of another entity, called the pointee.

f95 supports Cray pointers; Standard Fortran 95 does not.

4.3.1Syntax

The Cray POINTER statement has the following format:

POINTER ( pointer_name, pointee_name [array_spec] ), …

Where pointer_name, pointee_name, and array_spec are as follows:

pointer_name

Pointer to the corresponding pointee_name.

 

pointer_name contains the address of pointee_name.Must be a scalar

 

variable name (but not a derived type).Cannot be: a constant, a name of a

 

structure, an array, or a function.

pointee_name

Pointee of the corresponding pointer_name

 

Must be: a variable name, array declarator, or array name

array_spec

If array_spec is present, it must be explicit shape, (constant or non-

 

constant bounds), or assumed-size.

For example, we can declare Cray pointers to two pointees:

POINTER ( p, b ), ( q, c )

The above example declares Cray pointer p and its pointee b, and Cray pointer q and its pointee c.

We can also declare a Cray pointer to an array:

POINTER ( ix, x(n, 0:m) )

The above example declares Cray pointer ix and its pointee x; and declares x to be an array of dimensions n by m+1.

4.3.2Purpose of Cray Pointers

You can use pointers to access user-managed storage by dynamically associating variables to particular locations in a block of storage.

Chapter 4 • Oracle Developer Studio Fortran Features and Extensions

175

4.3 Cray Pointers

Cray pointers allow accessing absolute memory locations.

4.3.3Declaring Cray Pointers and Fortran 95 Pointers

Cray pointers are declared as follows:

POINTER ( pointer_name, pointee_name [array_spec] )

Fortran 95 pointers are declared as follows:

POINTER object_name

The two kinds of pointers cannot be mixed.

4.3.4Features of Cray Pointers

Whenever the pointee is referenced, f95 uses the current value of the pointer as the address of the pointee.

The Cray pointer type statement declares both the pointer and the pointee.

The Cray pointer is of type Cray pointer.

The value of a Cray pointer occupies one storage unit on 32-bit processors, and two storage units on 64-bit processors.

The Cray pointer can appear in a COMMON list or as a dummy argument.

The Cray pointee has no address until the value of the Cray pointer is defined.

If an array is named as a pointee, it is called a pointee array. Its array declarator can appear in:

A separate type statement

A separate DIMENSION statement

The pointer statement itself

If the array declarator is in a subprogram, the dimensioning can refer to:

Variables in a common block, or

Variables that are dummy arguments

The size of each dimension is evaluated on entrance to the subprogram, not when the pointee is referenced.

176 Oracle Developer Studio 12.6: Fortran User's Guide • July 2017

4.3 Cray Pointers

4.3.5Restrictions on Cray Pointers

pointee_name must not be a variable typed CHARACTER*(*).

If pointee_name is an array declarator, it must be explicit shape, (constant or non-constant bounds), or assumed-size.

An array of Cray pointers is not allowed.

A Cray pointer cannot be:

Pointed to by another Cray pointer or by a Fortran pointer.

A component of a structure.

Declared to be any other data type.

A Cray pointer cannot appear in:

A PARAMETER statement or in a type declaration statement that includes the PARAMETER attribute.

A DATA statement.

4.3.6Restrictions on Cray Pointees

A Cray pointee cannot appear in a SAVE, DATA, EQUIVALENCE, COMMON, or PARAMETER statement.

A Cray pointee cannot be a dummy argument.

A Cray pointee cannot be a function result variable.

A Cray pointee cannot be a structure name or a structure component.

The type of a Cray pointee cannot be finalizable.

4.3.7Usage of Cray Pointers

Cray pointers can be assigned values as follows:

Set to an absolute address Example: q = 0

Assigned to or from integer variables, plus or minus expressions

Example: p = q + 100

Cray pointers are not integers. You cannot assign them to a real variable.

The LOC function (nonstandard) can be used to define a Cray pointer.

Chapter 4 • Oracle Developer Studio Fortran Features and Extensions

177

Соседние файлы в предмете Информационные и сетевые технологии