Re: [f2py] F2PY: Unable to prevent Fortran ordered array copy
Robin <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Nov 19, 2009 at 3:07 PM, Robin <[email protected]> wrote: > On Thu, Nov 19, 2009 at 2:50 PM, Ravi Kanda <[email protected]> wrote: >> I have been using Numpy+f2py for a couple of years, and the combination >> has worked well for me for many types of problems. However, I have >> never been able to prevent F2PY from copying arrays even though I >> initialize them as Fortran ordered in the calling python script. I have >> spent a considerable time looking in the archives (both F2PY & NUMPY) >> and found several leads to diagnosing array-copy problems (see results >> below), but none of them seem to work for me. > > I didn't have time yet to read through the details of what you've > tried - but thought I'd point out Fortran vs C order is only one of > the things that will trigger and f2py copy. A copy is also created if > a cast is required between the dtype of the numpy array and the > fortran type. (I found this out the hard way moving integer code > between 32 bit and 64 bit platforms - I couldn't understand why it was > slower on 64 bit, but it was because the cast was causing a copy). > > In your code it looks like you are using real(kind=4) whereas numpy > default is 64 bit double I think (real(kind=8)) so I suspect this is > where the copies are coming from. Try passing numpy arrays with > float32 dtype, or change fortran types... I just saw in your Python script you are using float32 - so sorry for the noise... I don't have any other ideas! Cheers Robin