Entry
Can python be embedded in a fortran program?
Aug 21st, 2001 05:53
Pearu Peterson, unknown unknown, Robert Kern, G. David Kuhlman
Problem:
There is some documentation (and also a lot of threads on this
newsgroup) on embedding python in a c program. I would like to embed it
in a fortran program so that the gui, input, error checking is done by
python and core computations are done in fortran. does anybody have any
idea on doing this? where can i find pointers for the same? I have
access to Compaq visual fortran 6.1.
Solutions:
In this case, you might want to extend the interpreter with extension
modules written in C that call the FORTRAN routines, rather than embed
the interpreter into your program. It depends on how well you can
separate the computation routines from the rest of the program that
has already been written.
To assist you, there are the following tools:
Numerical Python:
http://numpy.sourceforge.net
Pyfort:
http://pyfortran.sourceforge.net
f2py:
http://cens.ioc.ee/projects/f2py2e/
The last two depend on Numerical Python.
----------------
On any platform in which C code can be linked in with and called
from FORTRAN, this problem is equivalent to embedding Python in a C
application. Embed Python into a C module, produce a shared
library, and call into that (C) module from FORTRAN.