! A fortran95 program for G95
! By WQY
program test
implicit none
integer, target::a=1
integer, pointer::p=>null()
print*, associated(p)
p=>a
print*, associated(p)
print*, associated(p, a)
pause
end program
example-2:数组指针
! A fortran95 program for G95
! By WQY
program test
implicit none
integer, target::a(2, 3)=999
integer, pointer::p(:, :)=>null()
print*, associated(p)
p=>a
print*, associated(p)
print*, associated(p, a)
pause
end program
example-3:过程指针
! A fortran95 program for G95
! By WQY
program test
use m
integer::a=1
procedure(pro), pointer::p
interface
subroutine pro(a)
integer a
end subroutine
end interface
p=>sub
call p(a)
pause
end program
module m
contains
subroutine sub(a)
integer a
print*, "sub:", a
end subroutine sub
end module