• Aucun résultat trouvé

STORAGE UNITS AND SEQUENCES

Dans le document CRAY® COMPUTER SYSTEMS (Page 146-150)

DATA STRUCTURES, STORAGE,

4.5 STORAGE AND ASSOCIATION

4.5.1 STORAGE UNITS AND SEQUENCES

A numeric storage unit is a Cray word of 64 bits; a character storage unit is an 8-bit byte. A storage sequence is a contiguous group of storage units with a consecutive series of addresses. Each array and each common block is stored in a storage sequence. The size of a storage sequence is the number of storage units it contains. Two storage

sequences are associated if they share at least one storage unit.

An integer, real, or logical value occupies one numeric storage unit.

A character value is represented as an 8-bit ASCII code, packed eight characters per word; the storage size depends on the value's length specification. A double-precision or complex value uses a storage sequence of two numeric storage units, with the first storage unit containing the most significant bits of a double-precision value or the real part of a complex value, and the second storage unit containing the least significant bits of a double-precision value or the imaginary part of a complex value.

The ANSI Fortran Standard does not specify the relationship between storage units and computer words, nor does i t specify any relation between numeric and character storage units.

4.5.2 STATIC AND STACK STORAGE

with static storage, any variable that is allocated memory occupies the same address throughout program execution. Allocation is determined before program execution. Code using static storage is not reentrant and does not adapt to multitasking.

A stack is an area of memory where storage for variables is allocated when a subprogram or procedure begins execution and is released when execution completes. The stack expands and contracts as procedures are entered and exited. The amount of memory available for the stack is determined by the STACK directive available with SEGLDR; see the Segment Loader (SEGLDR) Reference Manual, publication SR-0066.

Variables are allocated to storage according to the following criteria:

User variables appearing in COMMON statements are always allocated in the order they appear in the source program.

User variables that are defined or referenced in a program unit, and that also appear in SAVE or DATA statements, are allocated to static storage, but not necessarily in the order shown in your source program.

Other referenced user variables are assigned to the stack if -a stack is on the cft77 command line, ALLOC=STACK is on the CFT77 control statement, or CDIR$ ALLOC=STACK appears in the program. If you have not specified stack storage, referenced variables are allocated to static storage. This allocation does not necessarily depend on the order in which the variables appear in your source program.

• Compiler-generated variables are assigned to a register or to memory (to the stack if stack storage is specified, to static memory otherwise) depending on how the variable is used.

Compiler-generated variables include DO-loop trip counts, dummy argument addresses, temporaries used in expression evaluation, argument lists, and variables storing adjustable dimension bounds at entries.

• In either allocation mode, heap allocation is used for TASK COMMON variable and some compiler-generated temporary data such as

automatic arrays and array temporaries. A heap is memory that is dynamically by the system as a program runs.

NOTE

Unreferenced user variables not appearing in COMMON statements are not allocated.

4.5.3 DEFINITION

A defined variable or array element has a value. An undefined variable or array element does not have a predictable value. Once defined, a variable or array element keeps a value until it becomes undefined or redefined.

All variables and array elements are initially undefined and can be defined before or during program execution. They can be defined in the following ways:

• By an assignment statement (see 5.1.1, 5.2.1, and 5.4.1)

• By an input statement (see section 7)

• By a DATA statement (see 4.4)

• Through association with other entities (see 4.5.5)

• When used as a dummy argument in a subprogram, when the subprogram is called and the corresponding actual argument is defined

(see 2.5)

• By an ASSIGN statement (only for a variable representing a statement label); see 6.4.4.

In addition, DO variables, implied-DO variables, and specifiers in 1/0 statements become defined when these statements and constructs are used.

An initially defined variable or array element is assigned a value in a DATA statement. Constants are always defined and are never redefined. A function's value is defined only when i t is evaluated.

When an entity of a given type becomes defined, all totally associated entities of different types become undefined. When an entity not of character type becomes defined, all partially associated entities become undefined. However, if two partially associated entities are of types real and complex, one entity can become defined without causing the other to become undefined.

If one array element is redefined, the whole array is considered redefined. This can affect optimization.

4.5.4 SAVE STATEMENT

A SAVE statement retains the definition status of specified entities after the execution of a RETURN or END statement in a subprogram. The entity remains defined in the current program unit only. The SAVE

statement must appear before any executable statement in a program unit.

When a subprogram is called recursively (directly or indirectly), inputs to the recursive invocation should be passed as arguments or within a common block. Any SAVE statement has not yet taken effect, so you should not assume that a variable's current value will be in storage when the recursive invocation begins. That is, input variables used in recursive calls should be passed as in any other subprogram call.

SAVE [a[,a] .•. ]

a Variable name; array name; or common block name preceded and followed by a slash. If a is omitted, all common blocks, variables, and arrays that can legally appear in a SAVE

statement are assumed specified. A name must not appear more than once in the SAVE statements of a program unit.

The names of dummy arguments, pointees, automatic arrays, or function result variables must not be specified in a SAVE statement. Variables and arrays within a common block can be specified only if the entire block is included.

The ANSI Fortran standard specifies that a common block that is named in a SAVE statement must also be specified in every subprogram where the common block appears. This is not enforced by CFT77.

A SAVE statement in the main program has no effect.

All referenced entities specified in a SAVE statement are assigned to static storage (see 4.5.2), with the following exception: when

optimization is enabled, local variables or arrays that are not referenced or used might not be assigned storage, and in such cases are unaffected by the SAVE statement.

The ANSI Fortran Standard does not specify storage allocation methods.

Dans le document CRAY® COMPUTER SYSTEMS (Page 146-150)