Skip to main content

Fortran magic

Latest PyPI version Number of PyPI downloads

Compile and import Fortran symbols from a code cell, 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.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

Metadata

Release files for fortran-magic 0.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fortran-magic 0.4.3
File Size Uploaded
fortran-magic-0.4.3.tar.gz 6.3 kB Details

Release files / fortran-magic-0.4.3.tar.gz

Download URL fortran-magic-0.4.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9681c29a8cfc8a0e45fa2705e2406ba02a9a9e3430b685ff6de4a93d92487cd3
BLAKE2b-256 checksum
How to use checksums
df8cf4207041a5616b27e00685e15319013018be7986de9e4e09a43b3131b97e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.0

2 release files

0.9

2 release files

0.8

2 release files

0.7.1

2 release files

0.7

2 release files

0.6.1

2 release files

0.6

2 release files

0.5.1

2 release files

0.5

1 release file

This release

0.4.3 This release

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4

1 release file

0.3

1 release file

0.2.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page