Giter Club home page Giter Club logo

f2x's Introduction

F2x

A versatile, template-based FORTRAN wrapper written in Python.

Quickstart

Installation of F2x follows the Python standard installation routine: Get the sources (e.g. using git) and run setup.py install. The dependencies should be installed automatically and you should be ready to go.

To generate wrapper code, you need a template that should be applied. There are some templates available that come bundled with F2x. To use them, prefix the respective template name with @ and F2x will find them in it's package directory. For example if you wish to wrap your module.f90 with to Python using the BIND('C') and ctypes, you should issue

$ F2x -t @bindc/_glue.f90.t -t @ctypes/_glue.py.t module.f90

This will generate module_gluec.f90 and module_glue.py alongside your module.f90. When compiling the FORTRAN code note that you need to link against libF2x.so.

For detailed information on provided templates and their inner workings, please consult the detailed documentation.

How does it work?

F2x differs from other FORTRAN wrappers quite a bit. The basic flow is as follows: It uses a full FORTRAN 2008 grammar (adapted from the OpenFortranProject). This is fed to PlyPlus for transforming the source code into an AST. The AST is then queried by the template to generate the code.

This design makes the whole process very flexible as you can easily replace the used grammar as well as the templates to generate your wrapper code. This is however at the cost of performance. But as it does not target runtime code generation, this should be fine.

Requirements and acknowledgements

F2x reuses a lot of stuff from other Open Source projects. Namely the following parts were really helpful:

  • It is developed in Python (and should run with both Python 2 and 3).
  • The PLY project is used as parser generator. PlyPlus does the heavy lifiting of converting ANTLR-like grammars to PLY.
  • The FORTRAN grammar that comes bundled with F2x originates from the OpenFortranProject.
  • Templates are based on Jinja2.

Legal stuff

Copyright © 2015-2016, German Aerospace Center (DLR e.V.)

This software is licensed under the Apache Public License 2.0. See LICENSE for details.

f2x's People

Contributors

led02 avatar melven avatar

Watchers

 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.