我有以下Fortran程序。但我不明白为什么输出是4而不是1.我使用的是GNU 6.4 Fortran编译器:
program aa
implicit none
real, pointer, dimension(:,:) :: t => null()
integer :: i,j
allocate(t(0:100,20))
do i = 0, 100
do j = 1, 20
t(i,j) = i*j
end do
end do
call te(t(1:,:))
stop
contains
subroutine te(a)
implicit none
real,dimension(:,:),pointer,intent(in) :: a
print *, a(1,1)
end subroutine te
end program aa
答案 0 :(得分:2)
英特尔编译器18.0.2返回错误消息
/pt.f90(17): error #7121: A ptr dummy may only be argument associated with a ptr, and this array element or section does not inherit the POINTER attr from its parent array. [T]
call te(t(1:,:))
将子程序中的行更改为
real,dimension(:,:),intent(in) :: a
一切都很好。