I would like to know the reason for the difference in output between just_checking_1
and just_checking_2
in the below toy code. I guess this boils down to what is the difference between a(*)
and a(:)
. Also, is there any way that subroutine just_checking_p
could access the memory location to which b
is pointing?
$ cat whereis.F90
program whereisit
integer, target :: a(100)
integer, pointer :: b(:)
print '("a is at 0x",Z8)', loc(a)
call just_checking_1(a)
call just_checking_2(a)
b => a
print '("b is at 0x",Z8)', loc(b)
call just_checking_p(b)
end program
subroutine just_checking_1(a)
integer :: a(*) !<-- Noice: a(*)
print '("In just_checking_1 a is at 0x",Z8)', loc(a)
end subroutine
subroutine just_checking_2(a)
integer :: a(:) !<-- Notice: a(:)
print '("In just_checking_2 a is at 0x",Z8)', loc(a)
end subroutine
subroutine just_checking_p(b)
integer, pointer, intent(in) :: b(:)
print '("In just checking b is at 0x",Z8)', loc(b)
end subroutine
$ ./a.out
a is at 0x 6B4140
In just_checking_1 a is at 0x 6B4140
In just_checking_2 a is at 0x 0
b is at 0x 6B4140
In just checking b is at 0x 0