Build extension module from a Fortran 77 source string with f2py. Parameters ---------- source : str or bytes Fortran source of module / subroutine to compile .. versionchanged:: 1.16.0 Accept str as well as bytes modulename : str, optional
(source,
modulename='untitled',
extra_args='',
verbose=True,
source_fn=None,
extension='.f',
full_output=False
)
| 24 | |
| 25 | |
| 26 | def compile(source, |
| 27 | modulename='untitled', |
| 28 | extra_args='', |
| 29 | verbose=True, |
| 30 | source_fn=None, |
| 31 | extension='.f', |
| 32 | full_output=False |
| 33 | ): |
| 34 | """ |
| 35 | Build extension module from a Fortran 77 source string with f2py. |
| 36 | |
| 37 | Parameters |
| 38 | ---------- |
| 39 | source : str or bytes |
| 40 | Fortran source of module / subroutine to compile |
| 41 | |
| 42 | .. versionchanged:: 1.16.0 |
| 43 | Accept str as well as bytes |
| 44 | |
| 45 | modulename : str, optional |
| 46 | The name of the compiled python module |
| 47 | extra_args : str or list, optional |
| 48 | Additional parameters passed to f2py |
| 49 | |
| 50 | .. versionchanged:: 1.16.0 |
| 51 | A list of args may also be provided. |
| 52 | |
| 53 | verbose : bool, optional |
| 54 | Print f2py output to screen |
| 55 | source_fn : str, optional |
| 56 | Name of the file where the fortran source is written. |
| 57 | The default is to use a temporary file with the extension |
| 58 | provided by the ``extension`` parameter |
| 59 | extension : ``{'.f', '.f90'}``, optional |
| 60 | Filename extension if `source_fn` is not provided. |
| 61 | The extension tells which fortran standard is used. |
| 62 | The default is ``.f``, which implies F77 standard. |
| 63 | |
| 64 | .. versionadded:: 1.11.0 |
| 65 | |
| 66 | full_output : bool, optional |
| 67 | If True, return a `subprocess.CompletedProcess` containing |
| 68 | the stdout and stderr of the compile process, instead of just |
| 69 | the status code. |
| 70 | |
| 71 | .. versionadded:: 1.20.0 |
| 72 | |
| 73 | |
| 74 | Returns |
| 75 | ------- |
| 76 | result : int or `subprocess.CompletedProcess` |
| 77 | 0 on success, or a `subprocess.CompletedProcess` if |
| 78 | ``full_output=True`` |
| 79 | |
| 80 | Examples |
| 81 | -------- |
| 82 | .. literalinclude:: ../../source/f2py/code/results/compile_session.dat |
| 83 | :language: python |