Re: [f2py] integers = 2226756?

Paul Anton Letnes <[email protected]> Thu, 24 Mar 2011 08:50:59 +0100
Newsgroups gmane.comp.python.f2py.user
Message-ID <[email protected]>
On 24. mars 2011, at 04.16, Michael Colonno wrote:

>             Hi ~
>  
>             I have what I hope is a very simple issue with integers. My extremely simple F90 code:
>  
> subroutine test(N)
>  
>     implicit none
>  
> !f2py integer, intent(in) :: N
>     integer                 :: N
Off topic: I think it's better to skip the !f2py line and write this as:

integer, intent(in) :: N

That way, the fortran compiler can perform more checks when compiling. On topic: The code works for me using either form when compiling with
f2py -c test.f90 -m testmodule
<stuff>
~/Desktop/test % python -c 'import testmodule; testmodule.test(102)'
 N =          102
The gfortran compiler was version 4.4 and my OS is mac os x.

Paul.

>  
>     print *, "N = ", N
>  
> end subroutine
>            
>             I compile this with F2PY and get in Python:
>  
> >>> import test
> >>> test.test(13)
> N =      2226756
> >>> N = 7
> >>> test.test(N)
> N =      2226756
>  
> I get the same value for any value I input. If I change the argument N to a real, I get the correct value. Is there some kind of incompatibility re: integers from Python? Please let me know if I’m going crazy.
>  
>             Thanks,
>             ~Mike C.
> _______________________________________________
> f2py-users mailing list
> f2py-users-Y4l6ocDipWCuvFJfX82//[email protected]
> http://cens.ioc.ee/mailman/listinfo/f2py-users