Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
26744 Discussions

Is an allocatable of polymorphic variables polymorphic?

E___Sebastian
Beginner
229 Views

In our code we sometimes need to iterate over a list of polymorphic variables. To do that we create a derived type as a container such as:

type myContainerT
  class(myExtendedBaseType), allocatable :: var
end type myContainerT

Now, myContainerT will not be extended, but var is polymorphic.
The question is, whether myContainerT is polymorphic too because it has polymorphic member variables and thus should be declared with class instead of type e.g. in dummy argument lists.

Even though the ifort seems to not care about that, any explanation of what goes on in the background would be greatly appreciated.

Thanks!

0 Kudos
1 Solution
FortranFan
Honored Contributor II
208 Views

@E___Sebastian ,

No, the objects and dummy argument references to this 'container' type need not be declared as 'CLASS', they can be 'TYPE'.

In fact, programs should be very judicious in their use of the polymorphic option with 'CLASS' and only make use of it when it serves a valuable purpose with respect to program design and logic.

View solution in original post

1 Reply
FortranFan
Honored Contributor II
209 Views

@E___Sebastian ,

No, the objects and dummy argument references to this 'container' type need not be declared as 'CLASS', they can be 'TYPE'.

In fact, programs should be very judicious in their use of the polymorphic option with 'CLASS' and only make use of it when it serves a valuable purpose with respect to program design and logic.

View solution in original post

Reply