B.5 Alternative Syntax for the PARAMETER Statement

The PARAMETER statement discussed here is similar to the one discussed in Section 5.14; they both assign a name to a constant. However, this PARAMETER statement differs from the other one in the following ways:

This PARAMETER statement takes the following form:

PARAMETER c = expr [, c = expr]...

c
Is the name of the constant.


expr
Is an initialization expression. It can be of any data type.

Rules and Behavior

Each name c becomes a constant and is defined as the value of expression expr. Once a name is defined as a constant, it can appear in any position in which a constant is allowed. The effect is the same as if the constant were written there instead of the name.

The name of a constant cannot appear as part of another constant, except as the real or imaginary part of a complex constant. For example:

 PARAMETER I=3
 PARAMETER M=I.25            ! Not allowed
 PARAMETER N=(1.703, I)      ! Allowed

The name used in the PARAMETER statement identifies only the name's corresponding constant in that program unit. Such a name can be defined only once in PARAMETER statements within the same program unit.

The name of a constant assumes the data type of its corresponding constant expression. The data type of a parameter constant cannot be specified in a type declaration statement. Nor does the initial letter of the constant's name implicitly affect its data type.

Examples

The following are valid examples of this form of the PARAMETER statement:

  PARAMETER PI=3.1415927, DPI=3.141592653589793238D0
  PARAMETER PIOV2=PI/2, DPIOV2=DPI/2
  PARAMETER FLAG=.TRUE., LONGNAME='A STRING OF 25 CHARACTERS'

For More Information:

For details on compile-time constant expressions, see Section 5.14.


Previous Page Next Page Table of Contents