Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29236 Discussions

How many types can I nest inside each other?

OP1
New Contributor III
675 Views
Hi,

Is there a limit to the number of derived types that can be nested inside each other (such as A%B%C%D%E... etc.)?

Thanks,

Olivier
0 Kudos
5 Replies
Steven_L_Intel1
Employee
675 Views
Quoting - opmkl
Hi,

Is there a limit to the number of derived types that can be nested inside each other (such as A%B%C%D%E... etc.)?

Thanks,

Olivier
30. This is listed in the "Compiler Limits" table in the Reference Information section of the compiler Building Applications manual.
0 Kudos
jimdempseyatthecove
Honored Contributor III
675 Views

Steve,

I would interpret this as 30 as the number of nests for de-referencing in expression as to number of enclosed nesting levels in the declaration. In order to access those members you would be required to use de-referencing functions

value = getFoo(A%B%C%D%E%...%Z) + getFoo(A2%B%C%D%E%...%Z)

where the dummy in getFoo is a type

real function getFoo(Z)
type(someTypeForZ) ::Z
getFoo = Z%AA%BB%CC%DD%EE%...%ZZ%foo
end function getFoo

Jim Dempsey
0 Kudos
Steven_L_Intel1
Employee
675 Views
The entry in the table is labeled "Structure Nesting". I interpret that as the nesting depth of a declaration for derived type.
0 Kudos
OP1
New Contributor III
675 Views
Thanks for the answer. 30 is five timesmore than what I need!

I can't wait to use the ASSOCIATE feature of IVF 11. Nested structures are great to organize data, but accessing them means long, unwieldy statements... The shortcuts one can define with ASSOCIATE are perfect to overcome this it seems.

Olivier
0 Kudos
jimdempseyatthecove
Honored Contributor III
675 Views

Until you get the feature consider using a pointer where you would use associate. Use conditional compilation such that when you get the update you can flip over to associate for a quick test.

Jim
0 Kudos
Reply