[Numpy-discussion] f2py with int8
John Mitchell
workalof@gmail....
Tue Apr 17 08:38:38 CDT 2012
Thanks Sameer. I confirmed on my side as well. I will try to understand
the why part now. Much appreciated.
On Mon, Apr 16, 2012 at 11:58 PM, Sameer Grover
<sameer.grover.1@gmail.com>wrote:
> On Tuesday 17 April 2012 11:02 AM, John Mitchell wrote:
>
> Hi,
>
> I am using f2py to pass a numpy array of type numpy.int8 to fortran. It
> seems like I am misunderstanding something because I just can't make it
> work.
>
> Here is what I am doing.
>
> PYTHON
> b=numpy.array(numpy.zeros(shape=(10,),dtype=numpy.int8),order='F')
> b[0]=1
> b[2]=1
> b[3]=1
> b
> array([1, 0, 1, 1, 0, 0, 0, 0, 0, 0], dtype=int8)
>
>
>
> FORTRAN
> subroutine print_bit_array(bits,n)
> use iso_fortran_env
> integer,intent(in)::n
> integer(kind=int8),intent(in),dimension(n)::bits
> print*,'bits = ',bits
> end subroutine print_bit_array
>
>
> RESULT when calling fortran from python
> bits = 1 0 0 0 0 0 0 0 1 0
>
> Any Ideas?
> thanks,
> John
>
>
>
>
> _______________________________________________
> NumPy-Discussion mailing listNumPy-Discussion@scipy.orghttp://mail.scipy.org/mailman/listinfo/numpy-discussion
>
> It seems to work if "integer(kind=int8)" is replaced with "integer(8)" or
> "integer(1)". Don't know why, though.
>
> Sameer
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120417/277af079/attachment.html
More information about the NumPy-Discussion
mailing list