• Keine Ergebnisse gefunden

PARAMETER STATEMENT

Im Dokument COMPUTER SYSTEMS (Seite 111-114)

20 FORMAT ("SAM'S NOT HERE") STOP

4.1.1 PARAMETER STATEMENT

A PARAMETER statement assigns a symbolic name to a constant.

PARAMETER (p=e[,p=e] .•. )

p e

Symbolic name of a constant

Constant expression. In an exponentiation operation x**y, y must be an integer.

The type of a symbolic name in a PARAMETER statement is specified by its appearance in a previous type statement, by a previous IMPLICIT statement specifying its first letter, or by default. A symbolic name p must be followed by an arithmetic expression containing only arithmetic constants or the names of arithmetic constants that have been previously defined in the same or an earlier PARAMETER statement. If the type of a symbolic constant is not its implicit type, it must appear in a type statement before the PARAMETER statement.

The length of a character constant must be specified in a type statement or an IMPLICIT statement before the first appearance of its name.

Otherwise, the length is assumed to be one. The length cannot be changed by subsequent statements. If the length is specified as (*), the

parameter length is the length of the actual character string.

Type conversion of an arithmetic expression in a PARAMETER statement follows the same rules as assignment statements, discussed in section 6.

A symbolic name p of type logical can be followed only by a logical constant expression. Similarly, a symbolic name p of type character can be followed only by a character constant expression. A symbolic name can be assigned an arithmetic or logical value only once in a program unit. Constants named in a PARAMETER statement can be referenced in any subsequent statement in the same program unit except in a format

specification or to form a part of any other constant, such as any part of a complex constant.

Examples:

PARAMETER (PI=3.1415926, C=1.86E5) PARAMETER (JOULE=10000000,KELVIN=-273) IMPLICIT LOGICAL(A-B)

PARAMETER (BOOLEAN=.TRUE.,ABOOLEAN=.FALSE.)

4.2 VARIABLES

A variable is a name whose value can be changed during program

execution; it is unsubscripted and is not an array or array element. The term subscripted variable is often used to apply to an array element, but should not be assumed to have the characteristics of other variables;

see subsection 4.3, Arrays. Scalar and simple variables are merely variables as defined above, as distinguished from arrays or array elements.

A static variable's storage is allocated before program execution and remains in one location during execution; the default storage type for all CFT variables is static. A stack variable is dynamically

allocated; that is, its storage is allocated at execution time. If stack mode is specified on the CFT control statement or command, all variables are stack variables except those appearing in COMMON, DATA, or SAVE statements, and any variables equivalenced to these variables.

A variable has one data type throughout a program, as specified by the rules governing symbolic names, described under the following heading, Types of Data. The value of a variable can be defined by means of the assignment operator (=) or used in operations according to the rules described in section 5.

A variable name has the following restrictions:

• It cannot appear in a PARAMETER, INTRINSIC, or EXTERNAL statement.

• It cannot be the name of an array, subroutine, main program, or block data subprogram, nor the entry name in an ENTRY statement for an external subroutine, or NAMELIST group name.

• A variable name can be followed by a left parenthesis only if it is preceded by the word FUNCTION in a FUNCTION statement or by the word ENTRY in an ENTRY statement; or if it begins a character substring name (see subsection 3.8, Character Type).

A variable name is local to a program unit; see under the heading later in this section, Scope of Symbolic Names.

A variable can have the same name as a common block. A variable or common block can have the same name as a dummy argument of a statement function, but the dummy argument name is local to the statement function definition statement. The data type is the same in these different uses, except the use as a common block name. If the type is character, the length is also the same. See the discussion of statement functions in section 2.

4.3 ARRAYS

An array is a nonempty, ordered sequence of data items, called array elements, that occupy consecutive locations in storage. An array name is the symbolic name of an array and obeys the same rules for data typing used for other symbolic names; all elements of a given array are of one type. An array element name identifies one element and consists of an array name with one or more subscripts indicating the element's position within the array. Each subscript corresponds to an array dimension.

An array declarator is a list item that specifies an array's symbolic name and the size of each dimension of the array.

An array name with no subscript identifies the entire array in contexts where such use is permitted (see subsection 4.3.8, Use of Array Names).

In an EQUIVALENCE statement, an array name with no subscript identifies the first element of the array.

An array element substring is a character substring of a character array element; see subsection 3.8, Character Type.

Arrays are classified as dummy or actual, depending on their use as dummy arguments; and as constant-size, adjustable, assumed-size, and pointee, depending on how the dimension sizes are determined and on their usage.

Im Dokument COMPUTER SYSTEMS (Seite 111-114)