Interactive Fortran

In [1]:
from numpy import arange
from matplotlib.pyplot import plot
from IPython.html.widgets import interact
%matplotlib inline
In [2]:
%load_ext fortranmagic
In [3]:
%%fortran
subroutine f1(x, z)
    real, intent(in) :: x
    real, intent(out) :: z

    z = sin(x)

end subroutine f1
In [4]:
@interact
def ifort(w=5):
    xx = arange(0,10,0.1)
    yy = [f1(w*x) for x in xx]
    plot(xx,yy)
In [5]:
from IPython.display import Image
Image('/Users/bussonniermatthias/Desktop/ifort.png')
Out[5]:
In [5]: