• Keine Ergebnisse gefunden

ELEMENTS, 3 ELEMENTS, AND

Im Dokument COMPUTER SYSTEMS (Seite 54-82)

DATA REPRESENTATION AND STORAGE 2

5 ELEMENTS, 3 ELEMENTS, AND

Figure 2-2. Array element arrangement and reference

SR-0009

Part 1

2-14 J

Table 2-3 illustrates the method for evaluating subscript expressions.

DUMMY AND ACTUAL ARRAYS

Table 2-3. Subscript evaluation n Dimension declarator Subscript

1 (jl:kl) (sl)

ADJUSTABLE ARRAYS AND ADJUSTABLE DIMENSIONS

Subscript value which dimension declarators can contain variables, array elements, or functions called adjustab~e dimensions. Array elements, if specified, must not be elements of the array being declared. The name of an

I

variables in common and any constants appearing in the dummy array declarator determine the size of the corresponding adjustable dimension

for that execution of the subprogram.

The sizes of the adjustable dimensions and of any constant dimensions appearing in an adjustable array declarator determine the number and order of elements in the array. Each reference to a subprogram can define different properties (size of dimensions, number of elements, element ordering) for each adjustable array in that subprogram. These properties depend on the values of any actual arguments and variables in common when the subprogram is referenced.

Adjustable array properties of dimension number and array size do not change during subprogram execution. Variables defining an adjustable dimension can be redefined or become undefined during execution of the subprogram with no effect on these properties.

USE OF ARRAY NAMES

In a program unit, each appearance of an array name must be as part of an array element name except when used in the following.

• List of dummy arguments

• COMMON statement

• Type statement

• Array declarator

• EQUIVALENCE statement

• DATA statement

• List of actual arguments in a reference to an external procedure

• List of an input/output statement if it is not an assumed-size dummy array

• Unit identifier for an internal file in an input/output statement if it is not an assumed-size dummy array

• Format identifier in an input/output statement

• NAMELIST statement

• Pointee in a POINTER statement

• SAVE statement

SR-0009

Part 1

2-17 J

I

CHARACTER SUBSTRINGS

A character

substping

consists of one or more contiguous characters within a character string. The substring name consists of a variable name or an array element name, followed by a

substping

designato~ of the format:

( [ix) : [iy) )

where

ix iy

is an integer expression that designates the first character position of the desired substring and is an integer expression that designates the last character position of the desired substring.

The value of

ix

must be at least one1 the value of

iy

must not be greater than the length of the string or less than

ix.

If

ix

is

omitted, the substring is assumed to begin at the first position of the string. If

iy

is omitted, the substring is assumed to end at the last position. Omitting both expressions designates the entire string as a substring. Some examples of substring use follow.

Examples:

STRINGA(6:9) designates the sixth through the ninth positions of character variable STRINGA.

STRINGB(2,6) (1:3) designates the first through the third positions of array element STRINGB(2,6) •

STRINGC(5,4) ( :7) designates the first through the seventh positions of array element STRINGC(5,4) •

STRINGD(4: ) designates the fourth through the last position of character variable STRINGD.

STORAGE AND ASSOCIATION

Storage sequences describe association among variables, array elements, common blocks, and arguments.

SR-0009

Part 1

2-18 J

STORAGE SEQUENCES

A

stopage sequence

is a sequence of storage units. A storage unit corresponds to the Cray Computer System word of 64 bits. An integer, real, Boolean, or logical data occupies one storage unit; a

double-precision or complex data occupies two storage units. A data requiring more than one storage unit in a storage sequence occupies consecutive locations in memory.

Character data are represented as 8-bit ASCII values, packed eight per word.

The ANSI FORTRAN Standard does not specify the relationship between storage units and computer words, or provide for character packing.

A storage sequence corresponds to a contiguously addressed set of memory locations.

The term storage sequence describes relationships associating variables, array elements, arrays, and common blocks.

Each array and each common block has a storage sequence. Two storage sequences are

associated

if they share at least one storage unit. The

size of a storage sequence

is the number of storage units it contains.

A storage unit contains one variable or array element of type integer, real, or logical.

A double-precision or complex variable or array element has a storage sequence of two storage units. In a double-precision storage sequence, the most significant and least significant parts of data are contained in the first and second storage units, respectively.

In a complex storage sequence, the real and the imaginary parts of data are contained in the first and second storage units, respectively. The storage size for character data depends on the length specification of the data.

ASSOCIATION OF ENTITIES

Association

occurs when data can be identified by different symbolic names or from different program units. Two entities are associated if their storage sequences are associated.

Totatty associated

entities share the same storage sequence.

Partiatty associated

entities share part but not all of a storage sequence.

SR-0009

Part 1

2-19 J

Partial association can exist between a double-precision or complex entity and a second entity of type integer, real, logical,

double-precision, or complex~ or between two character entities. Partial association occurs only by using the COMMON, EQUIVALENCE, or ENTRY

statements. Partial association must not occur through argument association.

Example:

INTEGER I REAL R(4) COMPLEX C(2)

DOUBLE PRECISION D

EQUIVALENCE (C(2), R(2), I), (R,D)

The third storage unit of C, the second storage unit of R and the storage unit of I are specified as the same. The storage sequences can be

illustrated in the following way.

Storage unit

1 2 3 4 5

Complex C (1) C(2)

Rea 1

I

R ( 1) 1 R ( 2)1 R ( 3) [ R ( 4)

I

Integer ~

Double precision D

I

R(2) and I are totally associated. The following are partially

associated: R(l) and C(l), R(2) and C(2), R(3) and C(2), I and C(2), R(l) and D, R(2) and D, I and D, C(l) and D, and C(2) and D. Although C(l) and C(2) are each associated with D, C(l) and C(2) are not

associated with each other.

The definition status and value of an entity affect the definition status and value of any associated entity or entities. An EQUIVALENCE

statement, a COMMON statement, or argument association in a procedure reference can cause the association of storage sequences. The

association of data in two different COMMON statements is illegal.

An EQUIVALENCE statement causes association of entities within a program unit unless one of the entities is also in a common block.

Arguments and COMMON statements cause entities in two or more program units to become associated.

SR-0009

Part 1

2-20 J

DEFINITION

During program execution, the content of a given variable or array element is either

defined

or

undefined.

A

defined

variable or array element contains a value. An

undefined

variable or array element does not contain a predictable value. Once defined, a variable or array element contains a specific value until it becomes undefined or is redefined with a different value.

All variables and array elements are initially undefined and remain so until action before or during program execution defines them. An

initially defined

variable or array element is one defined before program execution. Constants are always defined and are never

redefined. A function's value is defined only at that point in program execution where it is required.

Defined entities

Variables and array elements become defined in the following cases.

• Execution of an arithmetic, character, or logical assignment statement causes the entity to the left of the equal sign to become defined.

• When an input statement is executed, each entity is assigned a value and thus becomes defined.

• Execution of a DO statement causes the DO variable to become defined.

• Beginning execution of.actions specified by an implied-DO list in an input/output statement causes the implied-DO variable to become defined.

• A DATA statement causes entities to become initially defined when execution of a program begins.

• Execution of an ASSIGN statement causes the variable in the statement to become defined with a statement label value.

• When an entity of a given type becomes defined, all totally associated entities of the same type become defined. However, entities totally associated with the variable in an ASSIGN

statement become undefined when the ASSIGN statement is executed.

• A reference to a subprogram causes a dummy argument to become defined if the corresponding actual argument is defined.

SR-0009

Part 1

2-21 J

• Execution of an input/output statement that contains a status specifier causes the specified integer variable or array element to become defined.

• During the execution of an INQUIRE statement, any entity that is assigned a value becomes defined if no error condition exists.

• When a complex entity becomes defined, all partially associated real entities become defined.

• When both parts of a complex entity become defined as a result of partially associated real or complex entities becoming defined,

the complex entity becomes defined.

• When all characters of a character entity become defined, the character entity becomes defined.

Undefined entities

Variables and array elements become undefined in the following cases.

• All entities are undefined at the beginning of program execution except those entities initially defined by DATA statements.

• When an entity of a given type becomes defined, all totally associated entities of different type become undefined.

• Execution of an ASSIGN statement causes the variable in the statement to become undefined as an integer. Entities of type integer that are associated with the variable are also undefined as integers.

• When a noncharacter type entity becomes defined, all partially associated entities become undefined. However, when an entity of type real is partially associated with an entity of type complex, the complex entity does not become undefined when the real entity becomes defined and the real entity does not become undefined when the complex entity becomes defined. When an entity of type

complex is partially associated with another entity of type complex, definition of one entity does not cause the other to

become undefined.

• If the value of a function is not needed to determine the value of the expression in which the function is referenced, the function argument or the entity in common becomes undefined.

SR-0009

Part 1

2-22 J

• The execution of a RETURN or END statement within a subprogram causes all entities within the subprogram to become undefined, except for the following.

Entities in blank common Initially defined entities

Entities specified by SAVE statements

Entities in a named common block appearing in both the subprogram and another program unit that references the subprogram

• When an error condition or an end-of-file condition occurs during execution of an input statement, all items in the input list of the statement become undefined.

• Execution of a direct access input statement that specifies a record not previously written causes all input list entities to become undefined.

• Execution of an INQUIRE statement might cause entities to become undefined.

• When any character of a character entity becomes undefined, the character entity becomes undefined.

• When an entity becomes undefined as a result of conditions described in the five preceding items, all totally associated entities become undefined and all partially associated entities except those of type character become undefined.

SYMBOLIC NAMES

A symbolic name is the name of a constant, a variable, an array, a common block, a main program, a subprogram, an intrinsic function, a statement function, a block data subprogram, or a procedure. A symbolic name

consists of from one to eight alphanumeric characters, the first of which must be a letter. Some sequences of characters, such as format edit descriptors and keywords that uniquely identify certain statements (GO TO, READ, FORMAT, etc.) are not symbolic names, nor do they form the first characters of symbolic names in such occurrences.

The ANSI FORTRAN Standard provides for symbolic names of up to six alphanumeric characters.

SR-0009

Part I

2-23 J

SCOPE OF SYMBOLIC NAMES

The scope of a symbolic name is an executable program, a program unit, or a statement function statement.

The name of the main program and the names of block data subprograms, external functions, subroutines, and common blocks have a scope of an executable program and are global to that program.

The names of variables, arrays, constants, statement functions, and intrinsic functions have the scope of a program unit.

The names of variables that appear as dummy arguments in a statement function statement have a scope of that statement.

Global entities

The main program, common blocks, subprograms, and external procedures are global entities of an executable program. A symbolic name that

identifies a global entity must not be used to identify any other global entity in the same executable program.

A global entity is identified by a symbolic name appearing in one of the following classes.

• Common block

• External function

• Subroutine

• Main program

• Block data subprogram Local entities

The scope of a symbolic name of a local entity is a single program unit.

A symbolic name that identifies a member in one class of entities local to a program unit must not also identify a member in another class of entities local to that same program unit. However, a symbolic name that

identifies a local entity can, in a different program unit, identify an entity of any class that is either local to that program unit or is global to the executable program. A symbolic name that identifies a global entity in a program unit must not also identify a local entity in

that program unit except as noted for common block and external function names in the subsection, Classes of Symbolic Names, later in this section.

SR-0009

Part I

2-24 J

A local entity is identified by a symbolic name appearing in one of the following classes.

• Array

• Variable

• Constant

• Statement function

• Intrinsic function

A symbolic name used as a dummy argument in a procedure identifies a variable, an array, or another procedure. This specification and usage must not violate the respective class rules.

CLASSES OF SYMBOLIC NAMES

In a program unit, a symbolic name must not correspond to more than one class except as noted in the following paragraphs. All restrictions on the appearances of the same symbolic name in different program units of an executable program are also noted here.

Cornmon blocks

A symbolic name is the name of a cornmon block if it appears as a block name in a COMMON statement. A common block name is global to the executable program.

A common block name in a program unit can also be the name of a local entity other than a constant, intrinsic function, or a local variable that is also an external function in a function subprogram. If a name is used for both a cornmon block and a local entity, the appearance of that name in any context other than as a common block name in a COMMON or SAVE statement only identifies the local entity.

External functions

A symbolic name is the name of an external function if one of the following conditions exists.

• The name appears immediately following the keyword FUNCTION or ENTRY in a FUNCTION or ENTRY statement.

SR-0009

Part 1

2-25 J

• The name is not an array name, statement function name, intrinsic function name, subroutine name, or dummy argument and every

appearance is followed by a left parenthesis except in a type statement, in an EXTERNAL statement, or as an actual argument.

The name of a function subprogram that appears immediately after the keyword FUNCTION or ENTRY in a FUNCTION or ENTRY statement must be the name of a variable in that subprogram. An external function name is global to the executable program.

Subroutines

A symbolic name is the name of a subroutine if one of the following conditions exists.

• The name appears immediately following the keyword SUBROUTINE or ENTRY in a SUBROUTINE or ENTRY statement.

• The name appears immediately following the keyword CALL in a CALL statement and is not a dummy argument.

A subroutine name is global to the executable program.

The main program

A symbolic name is the main program name if it appears in a PROGRAM statement in the main program. A main program name is global to the executable program.

Block data subprograms

A symbolic name is the name of a block data subprogram if it appears in a BLOCK DATA statement. A block data subprogram name is global to the

executable program.

Arrays

A symbolic name is the name of an array if it appears as the array name in an array declarator in a DIMENSION, COMMON, or type statement. An array name is local to a program unit and can be the same as a common block name.

SR-0009

Part 1

2-26 J

I

Variables

A symbolic name is the name of a variable if it meets all of the following conditions.

• The name does not appear in a PARAMETER, INTRINSIC, or EXTERNAL statement.

• The name is not the name of one of the following.

An array A subroutine A main program

A block data subprogram

• The name appears as a name other than one of the following.

An external function in a FUNCTION statement A common block

An entry name in an ENTRY statement in an external function

• The name is not immediately followed by a left parenthesis unless one of the following conditions exists.

It is immediately preceded by the word FUNCTION in a FUNCTION statement.

It is immediately preceded by the word ENTRY in an ENTRY statement.

It is at the beginning of a character substring name.

A variable name can be a parameter enclosed in parentheses in a FUNCTION statement. (See the FUNCTION statement in part 2, section 7.)

A variable name is local to a program unit. A variable name in the dummy argument list of a statement function statement is local to the statement function statement where it occurs.

A statement function dummy argument name can also be the name of a

variable or common block in the same program unit. The appearance of the name in any context other than as a dummy argument of the statement

function identifies a local variable or common block. The statement function dummy argument name and local variable name have the same type.

If the type is character, they also have the same length. A variable can have the same name as a common block.

Constants

A symbolic name is the name of a constant if it appears as a symbolic name in a PARAMETER statement. A constant name is local to a program unit. A constant can have the same name as a common block.

SR-0009

Part 1

2-27 J

Statement functions

A symbolic name is the name of a statement function if it is not an array name and if a statement function statement specifies that symbolic name.

A statement function name is local to a program unit. A statement function name can be the same as a common block name.

Intrinsic functions

A symbolic name is the name of an intrinsic function if the following conditions exist.

• The name is not an array name, statement function name, subroutine name, or dummy argument name.

• Every appearance of the symbolic name, except in a type statement, an INTRINSIC statement, or as an actual argument, is immediately followed by an actual argument list enclosed in parentheses.

An intrinsic function name is local to a program unit. (See Appendix B for intrinsic function list.)

Dummy procedures

A symbolic name is the name of a dummy procedure if the name appears in the dummy argument list of a FUNCTION, SUBROUTINE, or ENTRY statement and meets one or more of the following conditions.

• It appears in an EXTERNAL statement.

• It appears as the name of the called subroutine in a CALL statement.

• It is not an array name or character variable name and it is immediately followed by a left parenthesis, except in the following cases.

In a type statement In an EXTERNAL statement

In a type statement In an EXTERNAL statement

Im Dokument COMPUTER SYSTEMS (Seite 54-82)