Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

SIZE function on an ALLOCATABLE array

Jon_D
New Contributor II
965 Views

Hello,

The following code prints out 10 as the size of the ALLOCATABLE array after the array is deallocated. Is this the correct behavior or a compiler bug? I am using the latest version of the Intel Fortran compiler.

Thanks for any clarification.

PROGRAM Main
    IMPLICIT NONE
    
    INTEGER,ALLOCATABLE :: iTestArray(:)
    
    WRITE (*,*) SIZE(iTestArray)
    
    ALLOCATE (iTestArray(10))
    WRITE (*,*) SIZE(iTestArray)
    
    DEALLOCATE (iTestArray)
    WRITE (*,*) SIZE(iTestArray)
    
END

 

0 Kudos
2 Replies
Steven_L_Intel1
Employee
965 Views

It's your error for calling SIZE on an unallocated array. The result of that is undefined.

0 Kudos
andrew_4619
Honored Contributor III
965 Views

You should use the function allocated(itestarray)

0 Kudos
Reply