array pointer change after calling FORTRAN subroutine in C++

Paul Richard Thomas paul.richard.thomas@gmail.com
Mon Oct 24 06:45:00 GMT 2011


Dear Qianqian,


> Thanks for the link. It clarified a lot of things for me.
> After reading this, I did not see interfacing a dynamic
> array argument. Is it supported?

What do you mean by a dynamic array argument?  If you mean an
allocatable array, these like array pointers are passed as a
'descriptor' or 'dope vector'.  This is a structure that points to the
array and contains information about the bounds, data type and so on.
Unfortunately, these are vendor dependent, at present.  If you are
interested in gfortran's representation take a look at the source in
the library; eg. matmul and at libgfortran.h

The most portable way of passing arrays of any kind to other languages
is to pass the first element of the array, which will be passed by
reference, and its shape.

>
> Also, when I use "iso_c_binding", will the Fortran
> .so/.a library file still be linkable with Fortran
> programs?

Of course.  You might have to chose bewteen using C binding in the
declarations of the calling programmes or writing interfaces to use
the fortran types.
>

Paul



More information about the Fortran mailing list