Skip to main content

An extension for IPython that help to use Fortran in your interactive session.

Project description

Latest PyPI version Number of PyPI downloads

Compile and import symbols from a cell with Fortran code, using f2py.

The contents of the cell are written to a .f90 file in the directory IPYTHONDIR/fortran using a filename with the hash of the code. This file is then compiled. The resulting module is imported and all of its symbols are injected into the user’s namespace.

author:

Martín Gaitán <gaitan@gmail.com>

homepage:

https://github.com/mgaitan/fortran_magic

documentation:

see this notebook

Install

You can install or upgrade via pip

pip install -U fortran-magic

or directly from the repository using the %install_ext magic command:

In[1]: %install_ext https://raw.github.com/mgaitan/fortran_magic/master/fortranmagic.py

Basic usage

Once it’s installed, you can load it with %load_ext fortranmagic. Then put your Fortran code in a cell started with the cell magic %%fortran`. For example:

In[2]: %load_ext fortranmagic


In[3]: %%fortran

       subroutine f1(x, y, z)
            real, intent(in) :: x,y
            real, intent(out) :: z

            z = sin(x+y)

       end subroutine f1

Every symbol is automatically imported. So f1 is already available:

In[4]:  f1(1.0, 2.1415)
Out[4]: 9.26574066397734e-05

See the documentation for details.

Changelog

0.5 / 2015-01-21

  • Call f2py via subprocess. It fixes problems finding fortran compilers under Windows. (Thanks to David Powell )

0.4.3 / 2013-12-09

  • Fix two python3.2+ incompatibilities (Thanks Ramon Crehuet for the report)

0.4.2 / 2013-10-08

  • Implement the --extra option (Thanks to Denis Vasilyev for the help)

  • Include %%fortran’s args in the hashing, so the same cell are recompiled with the same code but different arguments

0.3 / 2013-10-03

  • Added %fortran_config to set and persist default arguments for %%fortran

  • Improve documentation

0.2.1 / 2013-09-24

  • Packaged and registered in pypi

  • Starting a version’s changelog

0.2 / 2013-09-19

  • Fortran highlighting in a %%fortran cell

  • Works (or it should) in any platform (linux/windows/osx) and with py3 (thanks to Bradley Froehle)

  • Many f2py’s arguments exposed as magic arguments

  • Verbosity handling

  • Improved documentation

0.1 / 2013-09-08

  • First public release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fortran-magic-0.5.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fortran-magic-0.5.1.linux-x86_64.tar.gz (10.3 kB view details)

Uploaded Source

File details

Details for the file fortran-magic-0.5.1.tar.gz.

File metadata

  • Download URL: fortran-magic-0.5.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for fortran-magic-0.5.1.tar.gz
Algorithm Hash digest
SHA256 d73310ae4e376ff80a0bc8f3c2c4bf92a8146731e4cc8bb85898471dae8c9547
MD5 dfcd7d23b0608537722059e3ff885513
BLAKE2b-256 6f5c1dd369ca6557b5e99d5c139ae710f89e492393afcc4a077ab4d6a4d07289

See more details on using hashes here.

File details

Details for the file fortran-magic-0.5.1.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for fortran-magic-0.5.1.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 7cb61f7979a5676f2eff2919a656c673b70d7a4695510fab8db32ed996479bc8
MD5 cf51f2508e31e1f9b8c6749731b6b703
BLAKE2b-256 2089a936e08d4a391274aa67ba7cfe4178d824906b904cb9783f1b2537035477

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page