How can I wrap in the f2py module?
I mean, I am reading a few tutorials that say I should execute
f2py FIB1.f -m FIB2 -h FIB1.pyf
However, I don't know where I have to execute that, for sure not in spyder
or I am doing something wrong.
Why?
Because I execute this code that should create the extension module of Fortran with Python from my subroutine in Fortran, however an error is generated.
my Fortran subroutine:
SUBROUTINE FIB(A,N) INTEGER N REAL*8 A(N) DO I=1,N IF (I.EQ.1) THEN A(I) = 0.0D0 ELSEIF (I.EQ.2) THEN A(I) = 1.0D0 ELSE A(I) = A(I-1) + A(I-2) ENDIF ENDDO END
What I'm executing in Python:
import numpy.f2py as f2py
f2py FIB1.f -m FIB2 -h FIB1.pyf
The error is this one:
runfile('F:/SLB/Larryf2py/teste.py', wdir='F:/SLB/Larryf2py')
File "F:/SLB/Larryf2py/teste.py", line 9
f2py FIB1.f -m FIB2 -h FIB1.pyf
^
SyntaxError: invalid syntax
As far as I know, not sure, It should generate something like:
# File setup.py
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('',parent_package,top_path)
config.add_extension('m',
sources = ['m.pyf','foo.c'])
return config
if __name__ == "__main__":
from numpy.distutils.core import setup
setup(**configuration(top_path='').todict())
This example of what is generated is to C but I think its something like that to Fortran too.
What I think? That I should run the first code in another place of the Python...
I tried to reproduce this.