Using Fortran code through f2py

Fortran (from Formula Translation System) is a mature programming language mostly used for scientific computing. It was developed in the 1950s with newer versions emerging such as Fortran 77, Fortran 90, Fortran 95, Fortran 2003, and Fortran 2008 (refer to http://en.wikipedia.org/wiki/Fortran). Each version added features and new programming paradigms. We will need a Fortran compiler for this example. The gfortran compiler is a GNU Fortran compiler, which can be downloaded from http://gcc.gnu.org/wiki/GFortranBinaries.

The NumPy f2py module serves as an interface between Fortran and Python. If a Fortran compiler is present, we can create a shared library from Fortran code using this module. We will write a Fortran ...

Get Python Data Analysis now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.