次の Fortran コードは、2D 配列 x に値 v を入力します。
subroutine fill(x,v,m,n)
real*8 x(m,n),v
integer m,n,i
cf2py intent(in) :: x,v,m,n
forall(i=1:m,j=1:n) x(i,j) = v
end
この関数を Python から呼び出す場合:
x = numpy.array([[[0.0]]],order='F')
fill(x[:,:,0],2.0)
assert(x[0,0,0]==2.0) # Assertion failed
このアサーションが失敗するのはなぜですか?