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

f03 array allocation

mataras__dimitrios
837 Views

IVF 16 compiles the following code with 0 errors, 0 warnings,

program main
    implicit none
      integer:: i
      real, allocatable:: a(:)
      real:: c(5) = [(i, i = 1,5)]
     a = c     !   allocation F03   
     print *, '  array a has ', size(a), ' elements:'
     print *, a

end program main

The output is that the array has 0 elements and of course no values. Apparently the F03 style allocation in the assignment statement a=c does not work as it should.

The program runs correctly with 2 other compilers.

Is the F03 allocation feature not implemented in IVF 16?

BR

Dimitris

 

 

 

0 Kudos
1 Solution
mecej4
Honored Contributor III
837 Views

The default in Intel Fortran is not to reallocate an allocatable variable that is assigned an expression of a different size than the current allocated size, for performance reasons and to fulfill customer preference. Use the /assume:realloc_lhs option, as in ifort /assume:realloc_lhs assign.f90.

View solution in original post

0 Kudos
3 Replies
TimP
Honored Contributor III
837 Views

Did you read about compile options /assume:realloc_lhs and /standard-semantics?

0 Kudos
mecej4
Honored Contributor III
838 Views

The default in Intel Fortran is not to reallocate an allocatable variable that is assigned an expression of a different size than the current allocated size, for performance reasons and to fulfill customer preference. Use the /assume:realloc_lhs option, as in ifort /assume:realloc_lhs assign.f90.

0 Kudos
mataras__dimitrios
837 Views

Thanks everyone, I missed the option. it works ok.

BR

 

Dimitris

0 Kudos
Reply