[Numpy-discussion] [f2py] f2py ignores 'fortranname' inside F90 modules?

Irwin Zaid irwin.zaid@physics.ox.ac...
Mon Apr 16 05:22:20 CDT 2012


Hi all,

I've been having an issue with f2py simply ignoring the fortranname 
option if the Fortran subroutine is inside an F90 module. That option is 
useful for renaming Fortran subroutines.

I don't know if this behaviour is to be expected, or if I am doing 
something wrong. I would definitely appreciate any help!

As an example, here is code that correctly produces a Python module 
'test' with a single Fortran subroutine 'my_wrapped_subroutine'.

TEST_SUBROUTINE.F90
-------------------
subroutine my_subroutine()
     write (*,*) 'Hello, world!'
end subroutine my_subroutine

TEST_SUBROUTINE.PYF
-------------------
python module test
     interface
         subroutine my_wrapped_subroutine()
             fortranname my_subroutine
         end subroutine my_wrapped_subroutine
     end interface
end python module test

But, when the Fortran subroutine 'my_subroutine' is placed inside a 
module, the fortranname option seems to be entirely ignored. The 
following example fails to compile. The error is "Error: Symbol 
'my_wrapped_subroutine' referenced at (1) not found in module 'my_module'".

TEST_MODULE.F90
---------------
module my_module
     contains
     subroutine my_subroutine()
         write (*,*) 'Hello, world!'
     end subroutine my_subroutine
end module my_module

TEST_MODULE.PYF
---------------
python module test
     interface
         module my_module
             contains
             subroutine my_wrapped_subroutine()
                 fortranname my_subroutine
             end subroutine my_wrapped_subroutine
         end module my_module
     end interface
end python module test

F2py is a great tool aside from this and a few other minor quibbles. So 
thanks a lot!

Cheers,

Irwin


More information about the NumPy-Discussion mailing list