accessing fortran modules from python

Beliavsky beliavsky at aol.com
Thu Nov 16 13:05:24 EST 2006


sam wrote:
> hello all,
>
> i am currently in the process of planning a piece of software to model
> polymerisation kinetics, and intend to use python for all the
> high-level stuff. the number-crunching is something i would prefer to
> do in fortran (which i have never used, but will learn), but i have no
> experience of accessing non-python code from python.

I strongly recommend learning Fortran 95, rather than Fortran 77

> i am also fairly new to programming period, and am therefore tackling a fairly serious
> issue reletive to my experience.
>
> how easy is it to get fortran modules running from python?

G95 is a good, free Fortran 95 compiler -- I use it heavily, on
Windows. A discussion of "How to interface with Python programs" using
numpy is at http://www.g95.org/howto.html#python .

There is a numpy group http://groups.google.com/group/Numpy-discussion
with a recent thread "accessing FORTRAN from Python". There is also a
g95 group http://groups.google.com/group/gg95 .

> if c is easier to use in this respect, i could go in that direction instead.

easier to interface with Python, but not easier for writing numerical
code IMO, especially if you need multidimensional arrays.

<snip>

> PS if numpy is adequate for this, i would be quite happy to use it. i
> got the impression it was more for matrix algebra. i will be
> programming a monte carlo simulation, which will need to perform a lot
> (a lot!) of simple operations over and over...

Fortran 95 has some of the advantages of numpy -- you perform
operations on whole arrays and array sections. It would probably be
considerably faster for code with loops.




More information about the Python-list mailing list