Python and Fortran code
Scott Wolford
wolford at enews.nrl.navy.mil
Thu Jul 8 12:49:12 EDT 1999
Look at a combination of the SWIG tool (I can't remember where it's at but it
stands for Simplified Wrapper Interface Generator so you can search for it) and
a C wrapper for you fortran function. Basically, make it so you can call the
fortran from C. Then swig the C function and link the cstuff.o and fstuff.o with
cstuff_wrap.o (from SWIG) into a shared library then you can follow choice 2
from the other response to this post.
Scott
Jose L Gomez Dans wrote:
> Hi!
> I have a quetion on using python to do some simple processing on
> some data I pre-process with some Fortran code. I wanted to be able to call
> this subroutine from within python, as it is already "tried and tested" and
> optimized. Basically, my subroutine looks like this:
>
> subroutine ex1(exdata)
> dimension exdata(256,200)
> print*,'Doing some processing in FORTRAN'
> C We said we were doing some processing, so we might as well do it :)
> C Processing of exdata
> return
> end
>
> This subroutine would need to get input from the user and would also
> need to print stuff out for the user to see several parameters as the
> software runs. I'd like to pass exdata as a Python object (NumPy array
> object), and then recover it with the results. I wonder if I could somehow
> do that compiling this subroutine as an object file and then calling it from
> python (not that i know how to do it, but with scilab, it works :D).
>
> If it's of any use, I am using Debian GNU/Linux and g77. And using
> loads of complex numbers :))))
>
> Thanks in advance!
> Jose
>
> --
> Jose L Gomez Dans PhD student
> Radar & Communications Group
> Department of Electronic Engineering
> University of Sheffield UK
More information about the Python-list
mailing list