Re: [f2py] "natural" Fortran calling conventions?
Kevin Mitchell <[email protected]>
| Newsgroups | gmane.comp.python.f2py.user |
|---|---|
| Message-ID | <[email protected]> |
Amen, All this invisible transposing makes things 1000 times more confusing than if it just passed the arrays as they are. As far as I can tell there's no way to do this in all cases, however there are a two mutually exclusive ways you can get close: 1. Use default python arrays (c-order) and make your subroutine arguments intent(c). You need to make sure however that everything you're giving is indeed c-order. For instance you might want to make sure that the output arguments are also intent(c) if you plan on passing them back into fortran at some point. 2. Use the default intent(f) for your subroutine arguments and use fortran-order arrays in python (as created by asfortranarray()). Again, you need to make sure you're passing the right ordered arrays in otherwise it will transpose them Kevin On Sun, Apr 26, 2009 at 10:44 AM, Thomas Breuel <[email protected]> wrote: > Hi, > > It seems like f2py only offers copying (in, out, inout), or in-place > reordering (inplace), but it doesn't offer the simplest case, namely just > leaving the array alone and reversing the order of the indexes that the > programmer sees. > > Is there some way in which I can get f2py to use "natural" calling > conventions between Python and Fortran, something that always leaves the > array data alone? By that I mean that I pass an array in such a way that > "a[i,j]" is accessed as "a(j+1,i+1)" in Fortran. > > The current calling conventions seem to be going through a lot of trouble to > reorder the data in a way that then makes accesses particularly inefficient > from Fortran, just so that the order of the indexes stays the same. Most > performance critical code will naturally use the reverse order of indexes in > Fortran and Python/C code anyway, since the decision of where to put the > indexes will be driven by which index varies fastest, not by which position > the index should be in. > > Tom > _______________________________________________ > f2py-users mailing list > f2py-users-Y4l6ocDipWCuvFJfX82//[email protected] > http://cens.ioc.ee/mailman/listinfo/f2py-users > >