The STRUCTURE @ statement organizes data into structures.
STRUCTURE [/structure-name/] [field-list]
field-declaration
field-declaration
. . .
END STRUCTURE
Each field declaration can be one of the following:
A substructure--either another structure declaration, or a record that has been previously defined
A union declaration
A type declaration, which can include initial values
A STRUCTURE statement defines a form for a record by specifying the name, type, size, and order of the fields that constitute the record. Optionally, it can specify the initial values.
A structure is a template for a record. The name of the structure is included in the STRUCTURE statement, and once a structure is thus defined and named, it can be used in a RECORD statement.
The record is a generalization of the variable or array--where a variable or array has a type, the record has a structure. Where all the elements of an array must be of the same type, the fields of a record can be of different types.
Structures, fields, and records are described in "Structures".
The name is enclosed in slashes and is optional in nested structures only.
If slashes are present, a name must be present.
You can specify the field-list within nested structures only.
There must be at least one field-declaration.
Each structure-name must be unique among structures, although you can use structure names for fields in other structures or as variable names.
The only statements allowed between the STRUCTURE statement and the END STRUCTURE statement are field-declaration statements and PARAMETER statements. A PARAMETER statement inside a structure declaration block is equivalent to one outside.
Fields that are type declarations use the identical syntax of normal FORTRAN type statements, and all f77 types are allowed, subject to the following rules and restrictions:
Any dimensioning needed must be in the type statement. The DIMENSION statement has no effect on field names.
You can specify the pseudo-name %FILL for a field name. The %FILL is provided for compatibility with other versions of FORTRAN. It is not needed in f77 because the alignment problems are taken care of for you. It is a useful feature if you want to make one or more fields not referenceable in some particular subroutine. The only thing that %FILL does is provide a field of the specified size and type, and preclude referencing it.
You must explicitly type all field names. The IMPLICIT statement does not apply to statements in a STRUCTURE declaration, nor do the implicit I,J,K,L,M,N rules apply.
You cannot use arrays with adjustable or assumed size in field declarations, nor can you include passed-length CHARACTER declarations.
In a structure declaration, the offset of field n is the offset of the preceding field, plus the length of the preceding field, possibly corrected for any adjustments made to maintain alignment.
You can initialize a field that is a variable, array, substring, substructure, or union.
Example 1: A structure of five fields:
STRUCTURE /PRODUCT/ INTEGER*4 ID / 99 / CHARACTER*16 NAME CHARACTER*8 MODEL / 'Z' / REAL*4 COST REAL*4 PRICE END STRUCTURE RECORD /PRODUCT/ CURRENT, PRIOR, NEXT, LINE(10)
In the above example, a structure named PRODUCT is defined to consist of the fields ID, NAME, MODEL, COST, and PRICE. Each of the three variables, CURRENT, PRIOR, and NEXT, is a record which has the PRODUCT structure, and LINE is an array of 10 such records. Every such record has its ID initially set to 99, and its MODEL initially set to Z.
Example 2: A structure of two fields:
STRUCTURE /VARLENSTR/ INTEGER*4 NBYTES CHARACTER A*25 END STRUCTURE RECORD /VARLENSTR/ VLS VLS.NBYTES = 0