Clicky

Fortran Wiki
Assumed-size data structures

  TYPE MY_TYPE
    INTEGER :: SIZE
    REAL :: DATA(*)
  END TYPE MY_TYPE

Rationale: This should be supported at least for C interoperability. In most cases, this approach is somewhat of a hack compared to a contained allocatable array. However, a contiguous data structure can be more efficient. Using TRANSFER, this is also a way to implement a data union for data objects of variable size.

A work-around is just to use an array of size zero or one, like the old Fortran66 method for assumed-size arrays. But, this is not compatible with bounds-checking, which is why the assumed-size array specification was created.


I’m a bit confused. Can you illustrate how you would like to use this? Don’t parameterized derived types achieve what you’re proposing? -IzaakBeekman