I have a Python driver calling a Fortran subroutine. The subroutine has 1 character, then 3 integers. Before I added the character variable at the start and didn't have the argtypes call, it ran fine. But adding the character (and its length) plus the artgtypes call at the start gives a TypeError:
import ctypes as ctlib = ct.CDLL('FTN_lib.dll')fs = getattr(lib,'PY_OBJFUN_MOD_mp_GETSIZE')fs.restype = Nonefs.argtypes = [ct.c_char_p,ct.c_int,ct.c_int,ct.c_int,ct.c_int]x = b'x '+ sys.argv[1].encode('UTF-8') + b' debug=900'n = ct.c_int(0)nl = ct.c_int(0)nnl = ct.c_int(0)fs(x, len(x), ct.byref(n), ct.byref(nl), ct.byref(nnl))
fs(x, ln, ct.byref(n), ct.byref(nl), ct.byref(nnl))
ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type
The Fortran code header is:
subroutine getsize(file,n,nl,nnl) implicit none character(*), intent(in ) :: file integer , intent(out) :: n integer , intent(out) :: nl integer , intent(out) :: nnl