= G3 F2PY - the Third Generation of F2PY = The G3 F2PY is a complete rewrite of f2py2e and its main aim is to support wrapping Fortran 90 derived types to Python. ''See http://www.f2py.com for recent development.'' == Status == * Fortran 77/90/2003 parser - completed * Support for scalar arguments - completed * Support for array arguments - work in progress == Fortran 77/90/2003 parser example == {{{ >>> from numpy.f2py.lib.parser.api import parse >>> code = '''c comment ... subroutine foo(a) ... integer a ... print*, "a=", a ... end ... ''' >>> tree = parse(code, isfree=False) >>> print tree !BEGINSOURCE mode=fix77 SUBROUTINE foo(a) INTEGER a PRINT *, "a=", a END SUBROUTINE foo >>> tree BeginSource blocktype='beginsource' name=' mode=fix77' a=AttributeHolder: external_subprogram= content: Subroutine args=['a'] item=Line('subroutine foo(a)',(2, 2),'') a=AttributeHolder: variables= content: Integer selector=('', '') entity_decls=['a'] item=Line('integer a',(3, 3),'') Print item=Line('print*, "a=", a',(4, 4),'') EndSubroutine blocktype='subroutine' name='foo' item=Line('end',(5, 5),'') >>> }}} == Scalar support and compilation example == {{{ >>> from numpy.f2py.lib.main import compile >>> code = '''c comment ... subroutine foo(a) ... integer a ... print*, "a=", a ... end ... ''' >>> m, = compile('c -*- f77 -*-\n' + code, 'mymodule') # tell f2py that code is Fortran 77 >>> m.foo(3) a= 3 >>> m, =compile(code,'mymodule2',extra_args=['--fcompiler=gnu95']) # use gnu95 compiler, f2py will automatically detect that code is in Fortran 90 fixed format >>> m.foo(3) a= 3 >>> }}} == Related documentation == * [wiki:G3F2PY/FortranParserDoc] * [wiki:G3F2PY/FortranWrapperDoc] * [wiki:G3F2PY/ExtGenDoc]