This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: another calling-fortran-from-C-question
- From: "Christopher D. Rickett" <crickett at lanl dot gov>
- To: Daniel Franke <daniel dot franke at imbs dot uni-luebeck dot de>
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 28 Jun 2005 16:27:53 -0600 (MDT)
- Subject: Re: another calling-fortran-from-C-question
- References: <200506282047.37657.daniel.franke@imbs.uni-luebeck.de>
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