Re: Fortran to C array convertor

Peter wrote:
Hi guys,
I'm writing a wrapper in C for one of our libraries that we want users
to be able to call from Fortran. The one problem we have is converting
Fortran arrays into row-major C arrays. We don't want our users to
have to worry about array formats, instead we want to convert the
Fortran array into the C array before it is passed onto the library.

Does anyone know of a simple way of doing this? I'm finding it very
hard to write an algorithm that does this for more than 2 dimensions.

I'm not clear on your aims, but you might use f2c as a starter for C code which accesses f77 arrays, so you could copy them to the format you like. You could write a macro for each number of Fortran subscripts you want to support, if you are into that style of C. Or, you could use a Fortran program with TRANSPOSE, if that's what you have in mind. If the problem with complexity is in your C formats, this may not be the place to ask.