This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: another calling-fortran-from-C-question


On Tue, 28 Jun 2005, Daniel Franke wrote:

> 
> Searching google-groups revealed that each compiler encapsulates these assumed 
> shape arrays somehow. I assume it is possible to use some kind of structue in 
> C to map the memory layout needed by fortran, maybe similar to:
> 
> typedef struct {
>   int length;
>   void *ptr;
>   /* ... */
> } f90_assumed_shape_array;
> 
> Then, instead of passing
>    double x[] = {};
>    fortran_function( ..., x, ...);
> 
> I could write
>    f90_assumed_shape_array x;
>    x.length = ...;
>    x.ptr    = ...;
>    fortran_function( ..., &x, ...);
> 
> 
> If so, I'd like to ask for some pointers to docs, sources, whatever where I 
> can find information on how gfortran implements this since I don't mind doing 
> it non-portably or platform dependent -- everythings better than 
> reimplementing that library! I just need the results ...


If you would like to remain compiler independent, you could use the Chasm 
tool set.  Chasm provides a means for C/C++ to create the F90 array 
descriptors for assumed-shape f90 arrays for a number of f90 compilers.  I 
have used Chasm myself, so if you have any questions on how to use it, 
feel free to ask.  You could also look at the various definitions of C 
structs that represent the array descriptors for supported f90 compilers.

Chasm is at:

http://sourceforge.net/projects/chasm-interop/

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]