Calling FORTAN dll functions from Python

Discussion in 'Python' started by Alex van der Spek, Dec 7, 2010.

  1. 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
     
    Alex van der Spek, Dec 7, 2010
    #1
    1. Advertising

  2. Alex van der Spek, 07.12.2010 12:11:
    > Does anyone know how to call functions from FORTRAN dlls in Python? Is
    > it even possible?


    Sure, have a look at fwrap and Cython.

    Stefan
     
    Stefan Behnel, Dec 7, 2010
    #2
    1. Advertising

  3. On Tue, 07 Dec 2010 12:52:54 +0100, Stefan Behnel <>
    declaimed the following in gmane.comp.python.general:

    > Alex van der Spek, 07.12.2010 12:11:
    > > Does anyone know how to call functions from FORTRAN dlls in Python? Is
    > > it even possible?

    >
    > Sure, have a look at fwrap and Cython.
    >
    > Stefan


    Possibly ctypes too...
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Dec 8, 2010
    #3
  4. Alex van der Spek

    Carl Banks Guest

    On Dec 7, 3:11 am, "Alex van der Spek" <> 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?


    I'd recommend f2py, which is part of the numpy package.


    Carl Banks
     
    Carl Banks, Dec 8, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anushi
    Replies:
    5
    Views:
    9,014
  2. tomekj
    Replies:
    1
    Views:
    398
    stelios xanthakis
    Oct 29, 2003
  3. tomekj
    Replies:
    2
    Views:
    403
    tomekj
    Oct 29, 2003
  4. Replies:
    2
    Views:
    363
    osmium
    Apr 11, 2009
  5. H. Simpson
    Replies:
    4
    Views:
    350
    H. Simpson
    Aug 3, 2004
Loading...

Share This Page