Skip to content

Instantly share code, notes, and snippets.

@davidtrem
Created December 11, 2012 09:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidtrem/4257286 to your computer and use it in GitHub Desktop.
Save davidtrem/4257286 to your computer and use it in GitHub Desktop.
Ipython notebook - f2py cell Magic
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mlgill
Copy link

mlgill commented Jun 5, 2013

I am currently working on an IPython notebook that I'd love to incorporate f2py in. I downloaded the extension from your pull request because I didn't see f2pymagic listed in the IPython extension index and tried to run this sample notebook. The f2pymagic extension loads fine, but when I try to run the first cell in this notebook that contains an f2py compilation, I get the following:


Something went wrong...
running build
running config_cc
unifing config_cc, config, build_clib, build_ext, build commands --compiler options
running config_fc
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
running build_src
build_src
building extension "_fortran_magic_f741b3e7c1da249dd999e27b90e279ca" sources
f2py options: []
f2py:> /var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7/_fortran_magic_f741b3e7c1da249dd999e27b90e279camodule.c
creating /var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq
creating /var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7
Reading fortran codes...
    Reading file '/Users/mlgill/.ipython/f2py/_fortran_magic_f741b3e7c1da249dd999e27b90e279ca.f90' (format:fix)
Post-processing...
    Block: _fortran_magic_f741b3e7c1da249dd999e27b90e279ca
            Block: foo
Post-processing (stage 2)...
Building modules...
    Building module "_fortran_magic_f741b3e7c1da249dd999e27b90e279ca"...
        Constructing wrapper function "foo"...
          foo(a,b)
    Wrote C/API module "_fortran_magic_f741b3e7c1da249dd999e27b90e279ca" to file "/var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7/_fortran_magic_f741b3e7c1da249dd999e27b90e279camodule.c"
  adding '/var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7/fortranobject.c' to sources.
  adding '/var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7' to include_dirs.
copying /Volumes/Files/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.c -> /var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7
copying /Volumes/Files/macports/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/f2py/src/fortranobject.h -> /var/folders/mx/qvhh44jj00581tvvy6qzxxch0000gn/T/tmpP3G1Fq/src.macosx-10.8-intel-2.7
build_src: building npy-pkg config files
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
warning: build_ext: f77_compiler=None is not available.

building '_fortran_magic_f741b3e7c1da249dd999e27b90e279ca' extension

Any suggestions? I've used f2py from the command line to create and import functions, so I know that my installation works fine and it is found in my path. Also, per one of the comments on your PR, there are no spaces in my path.

Some other details:

  • python version 2.7.5
  • IPython version 0.14dev
  • Mac OS X 10.8.4

Thanks!

@mlgill
Copy link

mlgill commented Jun 5, 2013

Please disregard the above comment--I just realized the appropriate gcc version (the one with a fortran compiler) wasn't set appropriately within MacPorts. Long day. Your sample notebook now runs fine. I'm very sorry.

This is a fantastic extension. I hope you decide to add it to the extension index if it isn't there already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment