Re: SEQUENCE



gary.l.scott@xxxxxxxx wrote:
Hi,

I had thought that specifying SEQUENCE in a derived type only caused
the ordering of the components to be respected. I think I've
experienced that it also prevented insertion of padding at appropriate
positions between components. What is the expectation regarding
padding and SEQUENCE?

I searched for "sequence type" and "sequence structure" and, apart from the following in section 4.4,
<quote>
The order of the component definitions in a sequence type specifies a storage sequence for objects of that type.
</quote>

I couldn't really find anything concrete about any padding or what not.

In section 5.5, Note 5.28 mentions:
<quote>
Structures that appear in EQUIVALENCE statements shall be sequence structures. If a
sequence structure is not of numeric sequence type or of character sequence type, it shall be equivalenced only to objects of the same type.

A numeric sequence structure may be equivalenced to another numeric sequence structure, an
object of default integer type, default real type, double precision real type, default complex type, or default logical type such that components of the structure ultimately become associated only with objects of these types.

A character sequence structure may be equivalenced to an object of default character type or another character sequence structure.
</quote>

Similar language for structures in COMMON blocks.

Seems to me the only thing the standard guarantees is that the sequence of structure components in memory will be the same as they are defined.

Although it refers mostly to non-SEQUENCE types, note 4.18 in the f95 standard states:

<quote>
A structure resolves into a sequence of components. Unless the structure includes a SEQUENCE statement, the use of this terminology in no way implies that these components are stored in this, or any other, order. Nor is there any requirement that contiguous storage be used. The sequence merely refers to the fact that in writing the definitions there will necessarily be an order in which the components appear, and this will define a sequence of components. This order is of limited significance since a component of an object of derived type will always be accessed by a component name except in the following contexts: the sequence of expressions in a derived-type value constructor, the data values in namelist input data, and the inclusion of the structure in an input/output list of a formatted data transfer, where it is expanded to this sequence of components. *Provided the processor adheres to the defined order in these cases, it is otherwise free to organize the storage of the components for any non-SEQUENCE structure in memory as best suited to the particular architecture.* [Emphasis mine]
</quote>

The last sentence suggests to me that for cases where the sequence /is/ required, the storage method is up to the implementation/hardware.

Didn't really help, did it? Sorry.

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
.



Relevant Pages

  • Re: Fortran calls a C function that returns a struct
    ... | at the beginning to the derived type definition. ... However, there's a practical problem with SEQUENCE, which ... There are probably workarounds with compiler switches. ...
    (comp.lang.fortran)
  • Re: SEQUENCE
    ... Michael Metcalf wrote: ... I had thought that specifying SEQUENCE in a derived type only caused ... padding and SEQUENCE? ... A sequence derived type is defined to be the concatenation of its components ...
    (comp.lang.fortran)
  • Re: Interface Block and Matching Arguments Bug?
    ... actual argument differs from the type of the dummy argument. ... For a derived type, there are two ways for the actual and dummy ... Derived types are one of those features. ... The sequence bit basically means exactly what you are ...
    (comp.lang.fortran)
  • Re: error in sun, ok in ifort
    ... type:: threadcontext ... must be a sequence type. ... Derived type variable 'threadcontext' in COMMON at has ... "C589 If a common-block-object is of a derived type, ...
    (comp.lang.fortran)
  • Re: Data alignment and performance
    ... that all data is correctly aligned (they insert padding bytes, ... If you add sequence to your derived type, ... compiler decide that you want to optimise for space, ...
    (comp.lang.fortran)