Skip to content Skip to sidebar Skip to footer

Call Fortran Function From Python With Ctypes

I am looking to use ctypes to call some old fortran libraries which were written by my boss a few years ago. I followed the example given in this previous question, and I get the r

Solution 1:

Add the line

ykr_.restype = c_float

in your python code, before ykr_(byref(c_int(4))). This sets the return type for the function to float (or real in Fortan language).

In the original post, this was not necessary since int was assumed as default.


Post a Comment for "Call Fortran Function From Python With Ctypes"