{ "info": { "author": "James Kermode", "author_email": "james.kermode@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "f90wrap: Fortran to Python interface generator with derived type support\n========================================================================\n\n|Build Status|\n\nf90wrap is a tool to automatically generate Python extension modules\nwhich interface to Fortran code that makes use of derived types. It\nbuilds on the capabilities of the popular\n`f2py `__ utility by generating\na simpler Fortran 90 interface to the original Fortran code which is\nthen suitable for wrapping with f2py, together with a higher-level\nPythonic wrapper that makes the existance of an additional layer\ntransparent to the final user.\n\nCopyright (C) James Kermode 2011-2018. Released under the GNU Lesser\nGeneral Public License, version 3. Parts originally based on f90doc -\nautomatic documentation generator for Fortran 90. Copyright (C) 2004 Ian\nRutt.\n\nIf you would like to license the source code under different terms,\nplease contact James Kermode james.kermode@gmail.com\n\nDependencies\n------------\n\n1. `Python `__ >= 2.7 or 3.x (both now\n supported!)\n2. Recent version of `numpy `__ which includes\n ``f2py``\n3. Fortran compiler - tested with ``gfortran`` 4.6+ and recent ``ifort``\n 12+\n\nInstallation\n------------\n\nFor the latest stable release, install with either ``pip`` or ``conda``:\n\n::\n\n pip install f90wrap\n\nf90wrap can also be installed using ``conda`` via the conda-forge\nchannel:\n\n::\n\n conda config --add channels conda-forge\n\nOnce the conda-forge channel has been enabled, f90wrap can be installed\nwith:\n\n::\n\n conda install f90wrap\n\nFor the development version, installation is as follows:\n\n::\n\n git clone https://github.com/jameskermode/f90wrap\n cd f90wrap\n python setup.py install [--prefix PREFIX]\n\nExamples and Testing\n--------------------\n\nTo test the installation, run ``make test`` from the ``examples/``\ndirectory. You may find the code in the various examples useful.\n\nCase studies\n------------\n\nf90wrap has been used to wrap the following large-scale scientific\napplications:\n\n- `QUIP `__ - molecular dynamics code\n- `CASTEP `__ - electronic structure code\n\nSee this `IPython\nnotebook `__\nfrom a recent seminar for more details.\n\nUsage\n-----\n\nTo use ``f90wrap`` to wrap a set of Fortran 90 source files and produce\nwrappers suitable for input to f2py use:\n\n::\n\n f90wrap -m MODULE F90_FILES\n\nwhere ``MODULE`` is the name of the Python module you want to produce\n(e.g. the name of the Fortran code you are wrapping) and ``F90_FILES``\nis a list of Fortran 90 source files containing the modules, types and\nsubroutines you would like to expose via Python.\n\nThis will produce two types of output: Fortran 90 wrapper files suitable\nfor input to ``f2py`` to produce a low-level Python extension module,\nand a high-level Python module desinged to be used together with the\nf2py-generated module to give a more Pythonic interface.\n\nOne Fortran 90 wrapper file is written for each source file, named\n``f90wrap_F90_FILE.f90``, plus possibly an extra file named\n``f90wrap_toplevel.f90`` if there are any subroutines or functions\ndefined outside of modules in ``F90_FILES``.\n\nTo use f2py to compile these wrappers into an extension module, use:\n\n::\n\n f2py -c -m _MODULE OBJ_FILES f90wrap_*.f90 *.o\n\nwhere ``_MODULE`` is the name of the low-level extension module.\n\nOptionally, you can replace ``f2py`` with ``f2py-f90wrap``, which is a\nslightly modified version of ``f2py`` included in this distribution that\nintroduces the following features:\n\n1. Allow the Fortran ``present()`` intrinsic function to work correctly\n with optional arguments. If an argument to an f2py wrapped function\n is optional and is not given, replace it with ``NULL``.\n2. Allow Fortran routines to raise a RuntimeError exception with a\n message by calling an external function ``f90wrap_abort``\\ (). This\n is implemented using a ``setjmp()/longjmp()`` trap.\n3. Allow Fortran routines to be interrupted with ``Ctrl+C`` by\n installing a custom interrupt handler before the call into Fortran is\n made. After the Fortran routine returns, the previous interrupt\n handler is restored.\n\nNotes\n-----\n\n- Unlike standard ``f2py``, ``f90wrap`` converts all ``intent(out)``\n arrays to ``intent(in, out)``. This was a deliberate design decision\n to allow allocatable and automatic arrays of unknown output size to\n be used. It is hard in general to work out what size array needs to\n be allocated, so relying on the the user to pre-allocate from Python\n is the safest solution.\n- Scalar arguments without ``intent`` are treated as ``intent(in)`` by\n ``f2py``. To have ``inout`` scalars, you need to call ``f90wrap``\n with the ``--default-to-inout`` flag and declare the python variables\n as 1-length numpy arrays (``numpy.zeros(1)`` for example).\n- Pointer arguments are not supported.\n- Arrays of derived types are currently not fully supported: a\n workaround is provided for 1D-fixed-length arrays,\n i.e.\u00a0\\ ``type(a), dimension(b) :: c``. In this case, the super-type\n ``Type_a_Xb_Array`` will be created, and the array of types can be\n accessed through ``c.items``. Note that dimension b can not be ``:``,\n but can be a parameter.\n\nHow f90wrap works\n-----------------\n\nThere are five steps in the process of wrapping a Fortran 90 routine to\nallow it to be called from Python.\n\n1. The Fortran source files are scanned, building up an abstract symbol\n tree (AST) which describes all the modules, types, subroutines and\n functions found.\n2. The AST is transformed to remove nodes which should not be wrapped\n (e.g.\u00a0private symbols in modules, routines with arguments of a\n derived type not defined in the project, etc.)\n3. The ``f90wrap.f90wrapgen.F90WrapperGenerator`` class is used to write\n a simplified Fortran 90 prototype for each routine, with derived type\n arguments replaced by integer arrays containing a representation of a\n pointer to the derived type, in the manner described in\n (Pletzer2008)[https://doi.org/10.1109/MCSE.2008.94]. This allows\n opaque references to the true Fortran derived type data structures to\n be passed back and forth between Python and Fortran.\n4. f2py is used to combine the F90 wrappers and the original compiled\n functions into a Python extension module (optionally, f2py can be\n replaced by f2py-f90wrap, a slightly modified version which adds\n support for exception handling and interruption during exceution of\n Fortran code).\n5. The ``f90wrap.pywrapgen.PythonWrapperGenerator`` class is used to\n write a thin object-oriented layer on top of the f2py generated\n wrapper functions which handles conversion between Python object\n instances and Fortran derived-type variables, converting arguments\n back and forth automatically.\n\nAdvanced Features\n-----------------\n\nAdditional command line arguments can be passed to f90wrap to customize\nhow the wrappers are generated. See the ``examples/`` directory to see\nhow some of the options are used:\n\n::\n\n -h, --help show this help message and exit\n -v, --verbose set verbosity level [default: None]\n -V, --version show program's version number and exit\n -p PREFIX, --prefix PREFIX\n Prefix to prepend to arguments and subroutines.\n -c [CALLBACK [CALLBACK ...]], --callback [CALLBACK [CALLBACK ...]]\n Names of permitted callback routines.\n -C [CONSTRUCTORS [CONSTRUCTORS ...]], --constructors [CONSTRUCTORS [CONSTRUCTORS ...]]\n Names of constructor routines.\n -D [DESTRUCTORS [DESTRUCTORS ...]], --destructors [DESTRUCTORS [DESTRUCTORS ...]]\n Names of destructor routines.\n -k KIND_MAP, --kind-map KIND_MAP\n File containing Python dictionary in f2py_f2cmap\n format\n -s STRING_LENGTHS, --string-lengths STRING_LENGTHS\n \"File containing Python dictionary mapping string\n length names to values\n -S DEFAULT_STRING_LENGTH, --default-string-length DEFAULT_STRING_LENGTH\n Default length of character strings\n -i INIT_LINES, --init-lines INIT_LINES\n File containing Python dictionary mapping type names\n to necessary initialisation code\n -I INIT_FILE, --init-file INIT_FILE\n Python source file containing code to be added to\n autogenerated __init__.py\n -A ARGUMENT_NAME_MAP, --argument-name-map ARGUMENT_NAME_MAP\n File containing Python dictionary to rename Fortran\n arguments\n --short-names SHORT_NAMES\n File containing Python dictionary mapping full type\n names to abbreviations\n -m MOD_NAME, --mod-name MOD_NAME\n Name of output extension module (without .so\n extension).\n -M, --move-methods Convert routines with derived type instance as first\n agument into class methods\n -P, --package Generate a Python package instead of a single module\n -a ABORT_FUNC, --abort-func ABORT_FUNC\n Name of Fortran subroutine to invoke if a fatal error\n occurs\n --only [ONLY [ONLY ...]]\n Subroutines to include in wrapper\n --skip [SKIP [SKIP ...]]\n Subroutines to exclude from wrapper \n\nAuthor\n------\n\nJames Kermode: james.kermode@gmail.com\n\nContributors\n------------\n\n- Tamas Stenczel `stenczelt `__\n- Steven Murray `steven-murray `__\n- Greg Corbett `gregcorbett `__\n- Bob Fischer `citibob `__\n- David Verelst `davidovitch `__\n- James Orr `jamesorr `__\n- `yvesch `__\n\n.. |Build Status| image:: https://travis-ci.org/jameskermode/f90wrap.svg?branch=master\n :target: https://travis-ci.org/jameskermode/f90wrap\n", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/jameskermode/f90wrap/archive/v0.2.1.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jameskermode/f90wrap", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "f90wrap", "package_url": "https://pypi.org/project/f90wrap/", "platform": "", "project_url": "https://pypi.org/project/f90wrap/", "project_urls": { "Download": "https://github.com/jameskermode/f90wrap/archive/v0.2.1.tar.gz", "Homepage": "https://github.com/jameskermode/f90wrap" }, "release_url": "https://pypi.org/project/f90wrap/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Fortran to Python interface generator with derived type support", "version": "0.2.1" }, "last_serial": 5622688, "releases": { "0.1.4": [ { "comment_text": "", "digests": { "md5": "34384c83d57d3ee13d3ed19d85b15935", "sha256": "afa19c27e952f167cdd20497f97864ffaa0ac1033733b2f46d86951a618364b1" }, "downloads": -1, "filename": "f90wrap-0.1.4.tar.gz", "has_sig": false, "md5_digest": "34384c83d57d3ee13d3ed19d85b15935", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 66217, "upload_time": "2016-08-09T08:47:31", "url": "https://files.pythonhosted.org/packages/05/80/80e4f6d3829a583d1bf9fad4735c9c4f7d9e96d0c51737413aeb6b7c07b7/f90wrap-0.1.4.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "4c508a29cc4867d9cb9cd9c60df8ef06", "sha256": "13975ab3b4f4718dea5fc5385d8375fcc9969436905e8f1d0049eace7b9f6113" }, "downloads": -1, "filename": "f90wrap-0.2.1.tar.gz", "has_sig": false, "md5_digest": "4c508a29cc4867d9cb9cd9c60df8ef06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71204, "upload_time": "2019-08-02T08:53:20", "url": "https://files.pythonhosted.org/packages/dc/7c/8ba6fd3277470d134007bf174eca95500a534933a499e46327fe41bdf5b3/f90wrap-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4c508a29cc4867d9cb9cd9c60df8ef06", "sha256": "13975ab3b4f4718dea5fc5385d8375fcc9969436905e8f1d0049eace7b9f6113" }, "downloads": -1, "filename": "f90wrap-0.2.1.tar.gz", "has_sig": false, "md5_digest": "4c508a29cc4867d9cb9cd9c60df8ef06", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71204, "upload_time": "2019-08-02T08:53:20", "url": "https://files.pythonhosted.org/packages/dc/7c/8ba6fd3277470d134007bf174eca95500a534933a499e46327fe41bdf5b3/f90wrap-0.2.1.tar.gz" } ] }