我有以下由 python 调用的子程序的开始:
从 python 调用:libomp.cic(pos,mpart,boxsize,dim,npart)
subroutine cic(pos,mpart,boxsize,dim,npart,mesh)
use omp_lib
implicit none
real*8 mpart
!f2py intent(in) :: mpart
real*8 boxsize
!f2py intent(in) :: boxsize
integer dim
!f2py intent(in) :: dim
integer*8 npart
!f2py intent(in) :: npart
real*8, dimension(0:dim-1,0:dim-1,0:dim-1) :: mesh
!f2py intent(out) :: mesh
real*8, dimension(npart,3) :: pos
!f2py intent(in) :: pos
运行python脚本时出错:
error: (shape(pos,0)==npart) failed for 1st keyword npart: cic:npart=47099622
WARNING: Failure executing file: <test.py>
出于某种原因,当我设置npart
为整数时它可以工作,但它无法npart
从 python 接收并动态创建数组pos
。它适用于mesh
使用dim
但不适用pos
,为什么?它与调用它们的顺序有关吗?