Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor II
6 Views

Issue with ALLOCATE(..., SOURCE=...) and polymorphic array slices

I experience unexpected behavior when allocating a polymorphic array from a part of another polymorphic array. I have added a fully working program demonstrating the problem.

In both cases, I would have expected to get a TargetItems array with 5 elements. But in the first case, I get an array with 10 elements, i.e. the full size of the SourceItems array.

I have seen this behavior with the latest IVF 17.0.0.109 as well as several previous versions.

Another issue: In the debugger (using IVF 17 and VS 2015 Update 3), all arrays are shown as undefined even after the allocate...

Best regards,

Thomas

  program AllocateSourceIssueWithArraySlice

   implicit none

    type :: baseType
      integer aValue
    end type
  
    
      class (baseType), ALLOCATABLE :: SourceItems(:)
      class (baseType), ALLOCATABLE :: TargetItems(:)
    
      ALLOCATE( baseType::SourceItems(10))
  
      print *, 'Allocating with arrayslice in SOURCE= statement'
    
      ALLOCATE( TargetItems, SOURCE=SourceItems(1:5) )
         
      print *, 'Size SourceItems (expected 10): ', SIZE(SourceItems)
      print *, 'Size TargetItems (expected 5):  ', SIZE(TargetItems)
    
    
      DEALLOCATE(TargetItems)
      print *, 'Allocating with arrayslice via assosciate construct'
    
    
      ASSOCIATE (Source => SourceItems(1:5))
      ALLOCATE( TargetItems, SOURCE=Source )
      END ASSOCIATE
    
      print *, 'Size SourceItems (expected 10): ', SIZE(SourceItems)
      print *, 'Size TargetItems (expected 5):  ', SIZE(TargetItems)
    
      end program

0 Kudos
4 Replies
Highlighted
6 Views

Thanks - escalated as issue

Thanks - escalated as issue DPD200414141. Interesting that if the source array is not polymorphic, it works correctly.

Retired 12/31/2016
0 Kudos
Highlighted
6 Views

The fix for this might not

The fix for this might not make Update 1, but if not, definitely Update 2.

Retired 12/31/2016
0 Kudos
Highlighted
New Contributor II
6 Views

Quote:Steve Lionel (Intel)

Steve Lionel (Intel) wrote:

The fix for this might not make Update 1, but if not, definitely Update 2.

Thanks for the update on this issue.

Steve, in my original post I also mentioned that I am unable to see the variables in the above program in the debugger (VS2015 Update 3/IVF 17). Is that something specific to my installation or do have this issue as well? 

0 Kudos
Highlighted
6 Views

The debugger issue is

The debugger issue is unrelated - the debugger still has problems with polymorphic variables. I will check with our debugger folk to make sure they're aware of this (DPD200414790).

Retired 12/31/2016
0 Kudos