[IPython-dev] Fortran Magic for IPython

Ondřej Čertík ondrej.certik@gmail....
Thu Sep 12 13:25:21 CDT 2013


Hi,

I developed Fortran magic for IPython:

https://github.com/certik/ipython_fortran

Follow the link in the README for an example notebook. Travis
suggested this idea to me yesterday in a pub. ;)

You should be able to run everything from:

http://fortran90.org/src/rosetta.html
http://fortran90.org/src/best-practices.html


Some notes:

* the syntax highlighting is wrong for Fortran, both in code cells an
markdown cells

* it'd be nice to automatically wrap via Cython some subroutines to
Python with %%fwrap magic, currently I just execute the code with the
%%fortran magic

* it'd be nice to allow to link my Fortran library in, so that I can
interactively test subroutines in it. So I use my current build system
for my library, and just tell the %%fortran magic to link it + paths
to *.mod files, so that I can import modules. That should be quite
robust/simple to do. The only requirement is to use the same compiler.

* what is the best way to setup different compilers and compiler
options in the %%fortran magic? The code is here:
https://github.com/certik/ipython_fortran/blob/master/fortranmagic.py,
it's really simple so far.

* all cells are currently independent. I don't think it makes sense to
try to somehow append and execute code together from multiple cells.
But it might make sense to reuse modules defined in different cells
somehow.

* Eventually I'd love to contribute a PR against IPython notebook with
this extension, but for now I am just polishing it in the above
repository.

I would appreciate any feedback.

Ondrej


More information about the IPython-dev mailing list