Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
115 Views

Is an allocatable of polymorphic variables polymorphic?

Jump to solution

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

Accepted Solutions
Highlighted
Valued Contributor III
94 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
Highlighted
Valued Contributor III
95 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