Oct-26-2016, 05:46 PM
I've been trying to call Fortran.dll file with ctypes in Python 2.7.
however I've struggled with how to send and get Array and Matrix. Strictly speaking, I'd like to know how to set argtypes and restypes for array and matrix.
I probably know how to do it with numpy but at this time I can't use numpy_modules but I can only use Python standard modules like ctypes.
Actually I want to work with Rhino IronPython though, my Rhino IronPython is something wrong so I can't install numpy.
By the way, this is my Fortran and Python code to exchange array.
I know C doesn't have executable statement to control whole array ,it should be controlled one by one
if there is no way to to send and get Array and Matrix, please tell me!!!
Thanks a million in advance...
however I've struggled with how to send and get Array and Matrix. Strictly speaking, I'd like to know how to set argtypes and restypes for array and matrix.
I probably know how to do it with numpy but at this time I can't use numpy_modules but I can only use Python standard modules like ctypes.
Actually I want to work with Rhino IronPython though, my Rhino IronPython is something wrong so I can't install numpy.
By the way, this is my Fortran and Python code to exchange array.
subroutine add_array(ii) implicit none real(8),dimension(0:1),intent(inout) :: ii(0:1) dimension b(0:1) integer i do i =1,2 b(i)=1 ii(i) = ii(i) + b(i) end do end subroutine stop end------------------------------------------------------------------------
from ctypes import* addmodule = cdll.LoadLibrary("C:\\Users\\Owner\\add_arraytest.dll") addmodule.test_.argtypes = [ POINTER(c_int),POINTER(c_int)] addmodule.test_.restype = c_void_p twoIntegers = c_int * 2 ii = twoIntegers(1,2) ii(0) = c_int(ii[0]) ii(1) = c_int(ii[1]) addmodule.test_(byref(ii[0]),byref(ii[1])) for i in ii: print i,these program are collapsed... doesn't work at all...
I know C doesn't have executable statement to control whole array ,it should be controlled one by one
if there is no way to to send and get Array and Matrix, please tell me!!!
Thanks a million in advance...