I have the following very simple code. What I don't understand is after I deallocate my array x
, I would assume that my pointer ptr
no longer can be dereferenced. However, If you run the program you will see that the print
statement will correctly give the values of x
, and likewise give its size even though I have deallocated the array before I dereference the pointer.
Is this because my x values are still loaded on the higher memory levels (L1,L2 etc) and would need more time to refresh its state?
program ptr_deall
implicit none
real, allocatable,target :: x(:)
real, pointer :: ptr(: )
allocate(x(100))
x = 100
ptr => x
deallocate(x)
print*, ptr,size(ptr)
end program