Calling FORTAN dll functions from Python



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

.



Relevant Pages

  • Re: calling a function that returns a c_char from python
    ... compiler used, the output in python is right or wrong. ... The problem could lie either on the python side or the Fortran side. ... character arguments was defined in f77. ...
    (comp.lang.fortran)
  • Re: Attempting to allocate already allocated array?
    ... and I've written a good enough Python wrapper. ... If the python array is C contiguous (numpy arrays can be either Fortran or C contiguous under the hood, without you knowing it) you risk copying these arrays on entry to SUDA, just to get them on Fortran form. ... To do that I need to compare the SUDA (Special Uniques Detection Algorithm) approach, of which the unique itemset mining is a part, with an alternative. ...
    (comp.lang.fortran)
  • Re: Python for Fortran programmers
    ... proposition for Python in the Fortran community", ... compiled language such as Fortran or C++, but I would still prefer to ... greater number of programming errors that are typically detected by a ...
    (comp.lang.fortran)
  • Re: New to Python: Features
    ... > compile-time checking of procedure calls) were fixed in Fortran 90. ... alternative language possibilities for my employer of the time, ... By directly attacking pyrex as "not mature", ... > language like Python is good old C. ...
    (comp.lang.python)
  • Re: Fortran vs Python - Newbie Question
    ... I've been told that Both Fortran and Python are easy to read, ... creating number crunching apps over Fortran?? ... serious numerical computation these days is large-scale) without ...
    (comp.lang.python)