这两种声明假定大小数组的方法之间有什么区别吗?
例如
real, dimension(:) :: arr
Run Code Online (Sandbox Code Playgroud)
和
real :: arr(*)
Run Code Online (Sandbox Code Playgroud) 以下代码,结合模块程序和外部程序:
module module_dummy
implicit none
contains
subroutine foo(a)
real, intent(inout) :: a(:)
call bar(a)
end subroutine foo
end module module_dummy
program main
use module_dummy
implicit none
integer, parameter :: nelems = 100000000
real, allocatable :: a(:)
allocate( a(nelems) )
a = 0.0
call foo(a)
print *, a(1:10)
deallocate(a)
end program main
subroutine bar(a)
implicit none
real, intent(inout) :: a(:)
a = 1.0
end subroutine bar
Run Code Online (Sandbox Code Playgroud)
似乎失败了:
segmentation fault0.000而不是块1.000在我迄今为止尝试过的任何平台上。该问题与 的隐式接口声明 …