Calling FORTAN dll functions from Python

Katie T katie at coderstack.co.uk
Wed Dec 8 12:28:34 EST 2010


On Tue, Dec 7, 2010 at 11:11 AM, Alex van der Spek <zdoor at xs4all.nl> wrote:

> Does anyone know how to call functions from FORTRAN dlls in Python? Is it
> even possible? I browsed the documentation for Python 2.6.1 and the Python/C
> API comes close to what I would like to do but it is strictly limited to C.
>
> Unfortunately the passing of arguments in C and FORTRAN is very different,
> not to mention the differences with strings where FORTRAN expects a hidden
> length argument. It could call the FORTRAN dll from C and call the C
> functions from Python but is that my only option?
>
> For reference: I am using Python 2.6.1 FORTRAN powerstation 4.0. It is not
> an option to translate the FORTRAN code to C (using f2c) as the source code
> is the official ASME version of calculating steam tables.
>
>
I've done it before by creating C wrapper function and it was relatively
painless, using C wrappers means that it's much easier to integrate into
other languages as well if you need to do more integration down the line.

Katie
-- 
CoderStack
http://www.coderstack.co.uk
The Software Developer Job Board
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101208/91459661/attachment-0001.html>


More information about the Python-list mailing list