A Fortran derived type (defined using a TYPE statement) is like a
.NET object in some respects, but with important differences. In particular, a
Fortran derived type can contain Fortran arrays or pointers to arrays. You can
also have Fortran arrays whose elements are of a derived type.
As an extension to standard Fortran, FTN95 allows you to include an
OBJECT (i.e. a Fortran pointer to a .NET object) as a component of a
derived type with the following restrictions.
1. Variables that are based on derived types cannot be
guaranteed to be scanned during garbage collection
. For this reason, any derived type that includes an OBJECT is
subject to the same restrictions as OBJECTs themselves. Thus, when automatic
garbage collection is required to avoid memory leakage, variables of these
derived types must be local to a routine or be stored in a module (for a
global array you can use a .NET array instead).
2. Furthermore, a derived type that includes an OBJECT cannot include a
Fortran array (or a pointer to a Fortran array) at the same time.
This is because a derived type containing one or more OBJECT
declarations is effectively a .NET object.