Re: [Numpy-discussion] f2py with int8

2012-04-19 Thread Sturla Molden
On 17.04.2012 07:32, 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.

Re: [Numpy-discussion] f2py with int8

2012-04-18 Thread Paul Anton Letnes
Hi, 1, 2, 3 are integer literals. 1.0, 3.0e2, -42.0 are real (float) literals 'hello world' is a string literal. As far as I remember, f2py requires a literal variable for the kind. The solution I have landed on is to write a pure fortran module (using int8, or whatever), and then wrap this modu

Re: [Numpy-discussion] f2py with int8

2012-04-17 Thread John Mitchell
Thanks Paul. I suppose this is now going slightly out of bounds for f2py. What I am looking for is the fortran kind type for a byte. I thought that this was int8. I guess the question is how to identify the kind type. Although I have verified that integer(1) seems to work for me, I would real

Re: [Numpy-discussion] f2py with int8

2012-04-17 Thread Paul Anton Letnes
Ah, come to think of it, I think that f2py only supports literal kind values. Maybe that's your problem. Paul On 17. apr. 2012, at 07:58, Sameer Grover 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 fort

Re: [Numpy-discussion] f2py with int8

2012-04-17 Thread John Mitchell
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 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

Re: [Numpy-discussion] f2py with int8

2012-04-16 Thread Sameer Grover
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=nump

Re: [Numpy-discussion] f2py with int8

2012-04-16 Thread Paul Anton Letnes
Hi, this probably does not help with your problem. However, I would recommend changing your fortran code to: subroutine print_bit_array(bits) use iso_fortran_env integer(kind=int8),intent(in),dimension(:)::bits print*,'bits = ',bits end subroutine print_bit_array In that way you could p

[Numpy-discussion] f2py with int8

2012-04-16 Thread John Mitchell
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,