Calling FORTAN dll functions from Python

Alex van der Spek zdoor at xs4all.nl
Tue Dec 7 06:11:44 EST 2010


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 am interested in a solution that will work on Windows (XP and Vista) as 
well as Linux (Ubuntu 10.4) although the latter would not use dlls but code 
resources.

I am a beginner in Python. The fact that I still use and can use FORTRAN 
gives away my age. Mixed language programming is not an issue for me (C/VB, 
VB/FORTRAN, C/FORTRAN) but Python is new. Just pointing me to relevant 
documentation would be helpful in its own right.

Thank you in advance,
Alex van der Spek 




More information about the Python-list mailing list