(Re)allocation of allocatable arrays on assignment - F2003

Dominique Dhumieres dominiq@lps.ens.fr
Sat Oct 23 20:44:00 GMT 2010


Paul,

While trying to get some idea of the speed of the new feature, I stumbled
on the following problem:

real :: a(10)=1, b(51:60)=2
real, allocatable :: c(:)
c=a
print *, c
print *, lbound(c), ubound(c)
c=b
print *, c
print *, lbound(c), ubound(c)
end

gives

   1.0000000       1.0000000       1.0000000       1.0000000       1.0000000       1.0000000       1.0000000       1.0000000       1.0000000       1.0000000    
           1          10
   2.0000000       2.0000000       2.0000000       2.0000000       2.0000000       2.0000000       2.0000000       2.0000000       2.0000000       2.0000000    
           1          10

while I would expect the last line to be 51:60 according
my understanding of 

7.2.1.3 Interpretation of intrinsic assignments

 if expr is an array, the shape of expr with each lower bound equal to the corresponding element of
LBOUND (expr).

Do you agree with my reading of this sentence?

TIA

Dominique



More information about the Fortran mailing list