Fortran-compiled DLLs in Python
Thomas Heller
theller at python.net
Thu May 27 06:26:48 EDT 2004
"byte biscuit" <stephen.mcphail at casaccia.enea.it> writes:
> Hi there everybody!
> The problem is the following:
> we have a DLL (H2O.dll) - compiled in Visual Fortran - depending in turn on
> another DLL.
> H2O.dll contains only one (1) function, with a known name (WATER).
> The WATER function is called with the following parameters:
> - TT (datatype: double precision) [input]
> - PP (datatype: double precision) [input]
> - State (datatype: integer)
> [input]
> - DiERR (datatype: integer)
> [output]
> - SIG (datatype: double precision)
> [output]
> - Prop (datatype: double precision array[16 elements]) [output]
>
> Obviously, we would like to make use of Python to handle the function and
> pick out the results...
> We thought of using the **ctypes** module to tackle the problem, but we have
> stranded just about at the first attempt:
>
>>>> from ctypes import *
>>>> h2o = windll.H2O
>>>>
> h2o.WATER(c_long(40.0),c_long(1.0),c_int(2),c_int(dierr),c_int(Sig),c_long*1
> 6(prop))
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> TypeError: int expected instead of float instance
Looking at your function description above, I would guess you have call
it in the following way (although the error you get is that c_long(40.0)
complains about the float argument):
dierr = c_int()
prop = (c_double * 16)() # create a 16 element double array
h2o.WATER(c_double(40.0), c_double(1.0), c_int(2),
byref(dierr), prop)
Although I do know nothing about fortran (anymore).
Thomas
More information about the Python-list
mailing list