Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning SciPy for Numerical and Scientific Computing Second Edition
  • Table Of Contents Toc
Learning SciPy for Numerical and Scientific Computing Second Edition

Learning SciPy for Numerical and Scientific Computing Second Edition - Second Edition

4.3 (10)
close
close
Learning SciPy for Numerical and Scientific Computing Second Edition

Learning SciPy for Numerical and Scientific Computing Second Edition

4.3 (10)

Overview of this book

This book targets programmers and scientists who have basic Python knowledge and who are keen to perform scientific and numerical computations with SciPy.
Table of Contents (10 chapters)
close
close
9
Index

Interaction with Fortran


SciPy provides a simple way of including Fortran code—f2py. This is a utility shipped with the NumPy libraries, which is operative when distutils from SciPy are available. This is always the case when we install SciPy.

The f2py utility is supposed to run outside Python, and it is used to create from any Fortran file a Python module that can be easily called in our sessions. Under any *nix system, we call it from the terminal. Under Windows, we recommend you run it in the native terminal, or even better, through a cygwin session.

Before being compiled with f2py, any Fortran code needs to undergo three basic changes, which are as follows:

  • Removal of all allocations

  • Transformation of the whole program into a subroutine

  • If anything special needs to be passed to f2py, we must add it with the comment string "!f2py" or "cf2py"

Let's illustrate the process with a simple example. The following naive subroutine, which we store in the primefactors.f90 file, performs a factorization...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning SciPy for Numerical and Scientific Computing Second Edition
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon