Can someone explain to me why the following program is not working, and how to make it work? In the main program, I highlight the pointer, in the sub routine, I look for the shape of the array and get the wrong values.
program test real, pointer, dimension(:,:,:) :: arr allocate(arr(3,5,7)) print *, "In test: ",shape(arr) call sub(arr) print *, "Back in test: ",shape(arr) end program test subroutine sub(arr) real, pointer, dimension(:,:,:) :: arr print *, "In sub: ",shape(arr) end subroutine
Output:
In test: 3 5 7 In sub: 12694064 1 3 Back in test: 3 5 7
thanks
PS: I am using gfortran (gcc 4.4.3)
EDIT: with gfortran 4.6, this code just doesn't compile. I get an error message:
The dummy argument 'arr' of the procedure 'sub' at (1) has an attribute that requires an explicit interface for this procedure
source share