Coder Social home page Coder Social logo

jesperkrogh / fortran_magic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mgaitan/fortran_magic

0.0 0.0 0.0 46 KB

An extension for IPython/Jupyter that helps to use Fortran in your interactive session.

License: BSD 3-Clause "New" or "Revised" License

Python 32.04% Jupyter Notebook 67.96%

fortran_magic's Introduction

Fortran magic

Latest PyPI version Number of PyPI downloads

Compile and import symbols from a cell with Fortran code, 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 <[email protected]>
homepage:https://github.com/mgaitan/fortran_magic
documentation:see this notebook

Install

You can install or upgrade via pip

pip install -U fortran-magic

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 the subroutine f1 is already available in your python session as a function:

In[4]:  f1(1.0, 2.1415)
Out[4]: 9.26574066397734e-05

See the documentation for further details.

fortran_magic's People

Contributors

mgaitan avatar astrojuanlu avatar bfroehle avatar qulogic avatar guihigashi avatar carreau avatar jr3cermak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.