Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 7/13/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

SEQUENCE

Statement: Preserves the storage order of a derived-type definition.

SEQUENCE

Description

The SEQUENCE statement allows derived types to be used in common blocks and to be equivalenced.

The SEQUENCE statement appears only as part of derived-type definitions. It causes the components of the derived type to be stored in the same sequence they are listed in the type definition. If you do not specify SEQUENCE, the physical storage order is not necessarily the same as the order of components in the type definition.

If a derived type is a sequence derived type, then any other derived type that includes it must also be a sequence type.

Example

 !DIR$ PACK:1
 TYPE NUM1_SEQ
   SEQUENCE
   INTEGER(2)::int_val
   REAL(4)::real_val
   LOGICAL(2)::log_val
 END TYPE NUM1_SEQ
 TYPE num2_seq
    SEQUENCE
    logical(2)::log_val
    integer(2)::int_val
    real(4)::real_val
 end type num2_seq
 type (num1_seq) num1
 type (num2_seq) num2
 character*8 t, t1
 equivalence (num1,t)
 equivalence (num2,t1)
 num1%int_val=2
 num1%real_val=3.5
 num1%log_val=.TRUE.
 t1(1:2)=t(7:8)
 t1(3:4)=t(1:2)
 t1(5:8)=t(3:6)
 print *, num2%int_val, num2%real_val, num2%log_val
 end