[Discuss] SciPy and F2PY

Deryk Barker dbarker at camosun.bc.ca
Mon Jul 23 14:49:19 PDT 2007


Alan W. Irwin wrote:
> Many years ago the scientific community developed the Numeric 
> extension to
> Python to provide Fortran/C - like speed for operations on arrays.  Note,
> that Numeric is no longer supported and its successor (under the umbrella
> project SciPy at http://www.scipy.org/SciPy) is called NumPy
> (http://numpy.scipy.org/).
>
> When boning up on converting some of my Python/Numeric scripts to
> Python/NumPy, I discovered another neat component of SciPy called F2py
> (http://www.scipy.org/F2py).  That project allows python programmers 
> to call
> routines written in fortran (and also C).  This is great for scientific
> python programmers because there are literally millions of lines of 
> fortran
> (and C) code out there that are the best in their class for solving
> particular numerical problems.  F2py should allow doing lots of useful
> things with the numerical results from Fortran (and C) routines including
> combining results from various routines together in novel ways.
>
> F2py is going to be immediately useful for my own research. For example,
> right now I output results to disk from my FreeEOS fortran library using
> special utility programmes written in fortran, then read that data into
> python to plot it using the python interface to PLplot.  With F2py I 
> will be
> able to short-circuit the whole process and call FreeEOS routines 
> directly
> to get the data I need to plot.  (Note, PLplot has both fortran 77 and 95
> interfaces, but I feel Python is just more flexible and powerful than 
> either
> kind of fortran which is why I always do my plotting using the python
> interface to PLplot.)
>
> My discovery of F2py has made my day.
Then you really need to check out SWIG, the Simplified Wrapper Interface 
Generator, which will enable you to use C/C++ etc in your 
python/perl/whatever scripting language.




More information about the Discuss mailing list