diff options
author | Pauli Virtanen <pav@iki.fi> | 2019-12-14 14:31:38 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2019-12-14 14:32:59 +0200 |
commit | b6f91207549fc97765c114c0c01625eaa5e58956 (patch) | |
tree | 74f527dceb3ce7c85e6361ac438776e6efccb29f /doc | |
parent | 2fc10a279edfd132ec27eeac9e72f5a02a8bae5e (diff) | |
download | numpy-b6f91207549fc97765c114c0c01625eaa5e58956.tar.gz |
DOC: f2py: copy documentation for .f2cmap file from old f2py FAQ
Diffstat (limited to 'doc')
-rw-r--r-- | doc/source/f2py/advanced.rst | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/doc/source/f2py/advanced.rst b/doc/source/f2py/advanced.rst index c9f3862e6..684b83fd7 100644 --- a/doc/source/f2py/advanced.rst +++ b/doc/source/f2py/advanced.rst @@ -43,3 +43,52 @@ In Python: .. include:: var_session.dat :literal: + + +Dealing with KIND specifiers +============================ + +Currently, F2PY can handle only ``<type spec>(kind=<kindselector>)`` +declarations where ``<kindselector>`` is a numeric integer (e.g. 1, 2, +4,...), but not a function call ``KIND(..)`` or any other +expression. F2PY needs to know what would be the corresponding C type +and a general solution for that would be too complicated to implement. + +However, F2PY provides a hook to overcome this difficulty, namely, +users can define their own <Fortran type> to <C type> maps. For +example, if Fortran 90 code contains:: + + REAL(kind=KIND(0.0D0)) ... + +then create a file ``.f2py_f2cmap`` (into the working directory) +containing a Python dictionary:: + + {'real': {'KIND(0.0D0)': 'double'}} + +for instance. + +Or more generally, the file ``.f2py_f2cmap`` must contain a dictionary +with items:: + + <Fortran typespec> : {<selector_expr>:<C type>} + +that defines mapping between Fortran type:: + + <Fortran typespec>([kind=]<selector_expr>) + +and the corresponding <C type>. <C type> can be one of the following:: + + char + signed_char + short + int + long_long + float + double + long_double + complex_float + complex_double + complex_long_double + string + +For more information, see F2Py source code ``numpy/f2py/capi_maps.py``. |