invalid syntax error in using f2py

344 views
Skip to first unread message

asds

unread,
Apr 29, 2015, 5:12:35 AM4/29/15
to f2py-...@googlegroups.com
I am trying to compile this fairly simple  fortran code into python module.

But getting invalid syntax error from python shell

>>import numpy.f2py as f2py
>>f2py -c -m foo foo.f90
 
        File "<stdin>", line 1 
        f2py -c -m foo foo.f90
                          ^
       SyntaxError: invalid syntax



file --------foo.f90

subroutine foo (a)
    implicit none
 
    integer, intent(in) :: a
    print*, "Hello from Fortran!"
    print*, "a=",a
end subroutine foo
 
I'm on linux with python 3.4 installed from anaconda distribution.
what i'm doing wrong here?

John E

unread,
Apr 29, 2015, 10:48:30 AM4/29/15
to f2py-...@googlegroups.com
f2py command goes on the command line, not in python shell.  You'll then be importing foo from the python shell.

asds

unread,
Apr 30, 2015, 10:03:15 AM4/30/15
to f2py-...@googlegroups.com
Finally, I'm able to compile my fortran program to python module.Thanks for help. 
Reply all
Reply to author
Forward
0 new messages