Top: f77 Up: 13 - Statements
Previous: 13,59 - STOP Next: 13,60,1 - Type_declarations


Section 13,60: STRUCTURE

 Indicates the beginning of the record structure declaration and
 defines the name of the structure.  Declaration format:

    STRUCTURE [/str/][fnlist]
               fdcl
              [fdcl]
              ...
              [fdcl]
    END STRUCTURE

    str     Identifies a structure name, which is used in 
            subsequent RECORD statements to refer to the 
            structure. A structure name is enclosed in slashes.

    fnlist  Identifies field names when used in a substructure 
            declaration.(Only allowed in nested structure
            declarations.)

    fdcl    (Also called the declaration body.)  Is any 
            declaration or combination of declarations of 
            substructures, unions, or typed data, or
            PARAMETER statements.

 Subsequent RECORD statements use the structure name to refer to the
 structure.  A structure name must be unique among structure names,
 but structures can share names with variables (scalar or array),
 record fields, PARAMETER constants, and common blocks.

 Structure declarations can be nested (contain one or more other
 structure declarations).  A structure name is required for the
 structured declaration at the outermost level of nesting, and
 optional for the other declarations nested in it.  However, if you
 wish to reference a nested structure in a RECORD statement in your
 program, it must have a name.

 Structure, field, and record names are all local to the defining
 program unit.  When records are passed as arguments, the fields
 must match in type, order, and dimension.

 Unlike type declaration statements, structure declarations do not
 create variables.  Structured variables (records) are created when
 you use a RECORD statement containing the name of a previously
 declared structure.  The RECORD statement can be considered as a
 kind of type declaration statement.  The difference is that
 aggregate items, not single items, are being defined.

 Within a structure declaration, the ordering of both the statements
 and the field names within the statements is important because this
 ordering determines the order of the fields in records.

 In a structure declaration, each field offset is the sum of the
 lengths of the previous fields.  The length of the structure,
 therefore, is the sum of the lengths of its fields.  The structure
 is packed; you must explicitly provide any alignment that is needed
 by including, for example, unnamed fields of the appropriate
 length.

 In the following example, the declaration defines a structure named
 DATE.  This structure contains three scalar fields:  DAY
 (LOGICAL*1), MONTH (LOGICAL*1), and YEAR (INTEGER*2).

    STRUCTURE /DATE/
        LOGICAL*1  DAY, MONTH
        INTEGER*2  YEAR
    END STRUCTURE

Sub-Topics

  1. Type_declarations
  2. Substructure_declarations
  3. Union_declarations
  4. PARAMETER_Statements

Top: f77 Up: 13 - Statements
Previous: 13,59 - STOP Next: 13,60,1 - Type_declarations