Intel® Fortran Compiler 16.0 User and Reference Guide

VOLATILE

Statement and Attribute: Specifies that the value of an object is entirely unpredictable, based on information local to the current program unit. It prevents objects from being optimized during compilation.

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

Type Declaration Statement:

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

Statement:

VOLATILE [::] object[, object] ...

type

Is a data type specifier.

att-ls

Is an optional list of attribute specifiers.

object

Is the name of an object, or the name of a common block enclosed in slashes.

A variable or COMMON block must be declared VOLATILE if it can be read or written in a way that is not visible to the compiler. For example:

If an array is declared VOLATILE, each element in the array becomes volatile. If a common block is declared VOLATILE, each variable in the common block becomes volatile.

If an object of derived type is declared VOLATILE, its components become volatile.

If a pointer is declared VOLATILE, the pointer itself becomes volatile.

A VOLATILE statement cannot specify the following:

The VOLATILE attribute must not be specified for a coarray that is accessed by use or host association. A noncoarray object that has the VOLATILE attribute can be associated with an object that does not have the VOLATILE attribute, including by use or host association.

Example

The following example shows a type declaration statement specifying the VOLATILE attribute:

  INTEGER, VOLATILE :: D, E 

The following example shows a VOLATILE statement:

  PROGRAM TEST
  LOGICAL(KIND=1) IPI(4)
  INTEGER(KIND=4) A, B, C, D, E, ILOOK
  INTEGER(KIND=4) P1, P2, P3, P4
  COMMON /BLK1/A, B, C
  VOLATILE /BLK1/, D, E
  EQUIVALENCE(ILOOK, IPI)
  EQUIVALENCE(A, P1)
  EQUIVALENCE(P1, P4)

The named common block, BLK1, and the variables D and E are volatile. Variables P1 and P4 become volatile because of the direct equivalence of P1 and the indirect equivalence of P4.

See Also