为什么预先准备在
例如, 在以下代码中,最后一份说明(x = foo(7)
)产生了GFortran错误:Error: Rank mismatch in debate a at (1) (1 and 0)
.
module m
public :: foo
contains
function foo(a) result(b)
integer, dimension(:) :: a
integer, dimension(size(a)) :: b
b = a+1
end function foo
end module m
program p
use m
integer, dimension(4) :: x
integer, parameter, dimension(4) :: y = (/1,2,3,4/)
x = 7
x = foo(x)
x = foo(y)
x = foo(x + 7)
x = foo(7)
end program p
This question should have asked about why an array assignment will promote a scalar value source to an array target; unlike an array function. I expect that s simply a convenient special case though. Any comments gratefully received in the begging caps below.