[IPython-User] Fortran cell magic

Chao YUE chaoyuejoy@gmail....
Tue Sep 17 11:01:54 CDT 2013


Dear Martin,

I am following your github instruction and successfully installed the
fortran magic.

I am having this error when I tried to execute some line of code:

ImportError: /homel/ychao/.cache/ipython/fortran/_fortran_magic_aed467970fab506a0a5170ace559f7a0.so:
cannot open shared object file: No such file or directory


the code is rather simple:

%%fortran
INTEGER,PARAMETER  :: r_std = 4
REAL(r_std),PARAMETER :: so_cond = 1.5396
  REAL(r_std),PARAMETER :: so_capa = 2.0514e+6

could you give some some hints? GREAT thanks for this contribution.

cheers,

Chao


On Wed, Sep 11, 2013 at 1:55 PM, Matthias BUSSONNIER <
bussonniermatthias@gmail.com> wrote:

>
> Le 11 sept. 2013 à 00:54, Martín Gaitán a écrit :
>
>
> On Tue, Sep 10, 2013 at 4:19 AM, Matthias BUSSONNIER <
> bussonniermatthias@gmail.com> wrote:
>
>>
>>
>> For mosts things that would be a single line to add/ monkey patch:
>>
>>
>> https://github.com/ipython/ipython/blob/master/IPython/html/static/notebook/js/config.js#L57
>>
>> ,'magic_fortran'      :{'reg':[/^%%fortran/]}
>>
>> Unfortunately, it seem code mirror does not support fortran (yet)
>>
>
>
> I've sent a pull request  with a basic Fortran mode
>
> https://github.com/marijnh/CodeMirror/pull/1815
>
> I hope it will be accepted soon, but then... I should wait for a repack of
> ipython's components, right?
>
>
> Has already been accepted apparently.
> It is possible to "backport" on earlier IPython by tweaking the profile.
> I'll see If I can come up with a PR agains your repo that does it.
>
> Or if you are interested, you can just inject the file you have in above
> PR in IPython using custom.js
> and it should almost work out of the box.
>
> Well living in the same repo might not always make sense, but in case like
>> %%R/rpy2 %%cython/cython, the magic is just a higher level wrapper to API.
>> So it might make sense to have it together.  I don't really use fortran
>> (anymore) so I'm not in a good place to judge, this was jus t a
>> proposition.
>> I might have.
>>
>> From a end user point of view, you have either the :
>>  - to use fortran with python, the best is IPython with fortran magic.
>>  - you have to  install fortran magic.
>>  - but fortran magic use f2py
>>  - once done if you have the correct f2py version installed it works
>>
>> or
>>  - to use fortran with python : install f2py
>>  - oh, and by the way if you are using ipython you can "Just" do load ext
>> numpy.f2py and you have a fortran magic.
>>
>> it feels for me exactly the same as %sympyprinting and panda html
>> dataframe option.
>> they are part of the package, and if you are using IPython you "just"
>> have to enable them.
>>
>> (I guess a package can even try to detect if it is in IPython at import
>> time and register magic automagically
>> even if explicit is better than implicit.)
>>
>
> I got the point, but doesn't be a better idea to do this "registration"
> automatically in the external package install process? I mean, if I have
> ipython installed and I install numpy/f2py, then numpy automatically should
> register its "magic for ipython". Once it's already installed, I could
> directly use "%%fortran" in a cell without importing anything.
>
>
> I do not agree with that, you can imagine have different implementation of
> the same magic. So if 2 external packages define the rmagic
> How would you decide which one to use ?
>
> Also having code of some magics to work might require loading library you
> don't want. As it might take a lot of time to load.
>
> But I would expect if possible that doing
>
> import numpy.f2py as f2py
>
> make the magic available in current namespace would be nice, but again it
> does something that might be "unexpected"
> for some user.
>
>
> I guess this could be done more or less easily declaring setuptool's
> "entry points" in the ipython's setup.py.
>
>
> http://pythonhosted.org/distribute/setuptools.html#dynamic-discovery-of-services-and-plugins
>
> For example, this is the architecture used in the nose's plugin machinery:
> http://nose.readthedocs.org/en/latest/plugins/writing.html#registering
>
> let me know if it sounds like a good idea
>
>
> having a way to know which magic might be available would be a good thing
> though.
> --
> M
>
>
>
> cheers.
> martin
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
>


-- 
***********************************************************************************
Chao YUE
Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL)
UMR 1572 CEA-CNRS-UVSQ
Batiment 712 - Pe 119
91191 GIF Sur YVETTE Cedex
Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16
************************************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20130917/b0b4bd9f/attachment-0001.html 


More information about the IPython-User mailing list