On 03/27/2011 08:54 PM, Sturla Molden wrote: > Den 26.03.2011 19:31, skrev Christopher Barker: > >> To understand all this, you'll need to study up a bit on how numpy >> arrays lay out and access the memory that they use: they use a concept >> of "strided" memory. It's very powerful and flexible, but most other >> numeric libs can't use those same data structures. > With the ISO C bindings in Fortran 2003, we can get a Fortran pointer > from a C pointer. This means it is actually possible to pass "strided > memory" from NumPy to Fortran libraries in a portable way. A Fortran > pointer is more similar to a NumPy view array than a C pointer. If I am > not mistaken, fwrap can generate the boiler-plate Cython and Fortran code.
fwrap currently ensures that array are Fortran-contiguous. Supporting strided arrays has been in the back of our minds but not much thought has been given it really... What would we do exactly -- pass the entire underlying buffer to Fortran and then re-slice it Fortran side? That's more complicated than doing a copy Python-side, so unless the Fortran compiler actually supports keeping the array strided throughout the code it's not worth it. I'm not aware of the rules here -- basically, if you keep an array assumed-shape, it can be passed around in non-contiguous form in Fortran? And it will be copied whenever it is passed as an explicit-shape array? Dag Sverre _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
