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.
.



Relevant Pages

  • Re: F90 to C interface
    ... I had a while ago a similar problem (interfacing Fortran code with C ... libraries); theoretically you would be able to use the Fortran2003 ... A Fortran module was also written containing interface ... Regarding arrays, you have to be careful: ...
    (comp.lang.fortran)
  • Re: best practices for structuring ASCII input
    ... I'm maintaining a number of smallengineering/scientific Fortran ... data consists of a mixture of variables, arrays, ... the input files are not human readable. ...
    (comp.lang.fortran)
  • Re: How old is the average Fortran programmer?
    ... No. C++ has many advantages over Fortran: ... metaprogramming, libraries etc. ... If your problem can be solved elegantly by looping over arrays of floats ... specialized numerics skills such as array syntax are thus left to ...
    (comp.lang.fortran)
  • Re: bivariate interpolation
    ... > interpolated using Akima's Bivariate Interpolation for Smooth Surface ... > rewrite the code form its original Fortran V to much cleaner C. ... > The routine has numerous 2-dimensional arrays that are being accessed ...
    (comp.lang.c)
  • Re: I dont have Matlab but I need the data contained with a .mat file.
    ... If I can find the right libraries, I might be able to "roll-my-owe" with a little less pain using some code I ran across at The Code Project webpage. ... The arrays contained within the .mat file are stock exchange data used in an article on a local search algorithm. ... I'll read the ASCII text files containing the arrays into Fortran and code my algorithm in Fortran. ...
    (comp.soft-sys.matlab)