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

Size of pointer alias

pterminator
Beginner
625 Views
Hello,

I'm a bit confused by the results of the little program below. I create a (pointer) alias for some array and nullify it later. However, the size of the alias remains the same after nullifying it and is not equal to 0. Is this normal? I also tried gfortran and that gives similar results, although the initial size of the pointer is then equal to 1 (even more strange).

Regards, Peter

Code:
program size_p

implicit none
double precision,target::r(10)
double precision,pointer::pr(:)=>null()

integer::i

write(*,*)'Size pr before assigning:',size(pr)
!do something stupid with the array
do i=1,size
r(i)=i
end do
pr=>r
write(*,*)'Size pr after assigning :',size(pr)
nullify(pr)
write(*,*)'Size pr after nullifying:',size(pr)

end program

0 Kudos
1 Reply
Steven_L_Intel1
Employee
625 Views
The program is not legal Fortran. You are not allowed to ask the size of an unallocated array.
0 Kudos
Reply