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

What is the minimum version that supports allocatable arrays of polymorphic types?

Casey
Beginner
377 Views

I have some code I use for analysis that makes use of allocatable arrays of polymorphic types in the following way:

One derived type contains an allocatable array of a polymorphic type cm1_base, where cm1_base is an abstract type that defines a set of interfaces for derived types to adhere to.  I allocate the specific derived type based on a parameter sent to an initialization function.  

This code works with gcc >= 4.8 and recent versions of ifort 14.x that I have tested it against.  I will soon have to run this code on machines with varying versions of ifort (12.x, 13.x) and am wondering in which version ifort first properly supported this feature. 

What is the minimum version of ifort that properly supports allocatable arrays of polymorphic types?

0 Kudos
4 Replies
IanH
Honored Contributor II
377 Views

Depends on what you mean by "properly".  The compiler still has some issues in this area.
 

0 Kudos
Casey
Beginner
377 Views

By properly I mean that I can allocate the array and that each element (a type derived from an abstract type) is accessible and works as expected.  For example, issues I see in gfortran 4.7 are that variables in the derived type (an element of the array) are not properly treated -- setting one variable in one element causes changes in other elements in a non-deterministic way.  I would consider this improper.  I haven't been able to do similar tests with ifort and don't have the multitude of versions between 12.1 and current to test the spectrum of behavior.  All I'm looking for is that any element of the allocatable array work the same as a single allocatable variable which behaves the same as a non-allocatable polymorphic variable.  I found in gcc the issue was putting it in an allocatable array.

0 Kudos
IanH
Honored Contributor II
377 Views

I have made extensive use of polymorphic allocatable variables since 12.0, I think.  (Going back a bit too far (i.e. more than about four hours...) for me to be very confident about that.)  But with each version you have needed to avoid certain constructs - for example I think array assignment (perviously (and still?) scalar too) of a derived type with a polymorphic component is still broken in the current update.

Issues that spring to mind or that I can see test code for include appropriate deallocation of components when associated with INTENT(OUT) arguments, bringing a polymorphic components value across with ALLOCATE(..SOURCE=xxx) (I think that's fixed as of 14), use of MOVE_ALLOC on the component (fixed in 14?), issues with default initialization (fixed in 13.0?), finalization stuff and the odd ICE.

I think I got by in the 12.0 days if the size of the array of derived type was fixed (i.e. if allocated, it gets allocated once), and similarly only allocate any polymorphic components in an element of that array once.  Anything more than that and the program ultimately went feral.

0 Kudos
Kevin_D_Intel
Employee
377 Views

From some archived notes it appears that and other Object-Oriented features were added in the 11.1 release; however, Steve’s advice in an earlier thread here was to upgrade beyond that version due to may defects having been fixed.

If you have a specific test case in mind that you can share with us then we have many older versions available that we can quickly/easily test to help with your confidence in what older version might support your needs/interests, and I'm happy to test older versions for you.

0 Kudos
Reply