another calling-fortran-from-C-question
Paul Brook
paul@codesourcery.com
Tue Jun 28 21:58:00 GMT 2005
On Tuesday 28 June 2005 22:22, Tobias Schlüter wrote:
> Daniel Franke wrote:
> > Google is not that much of help, all it reveals: "Don't do it", "Dragons
> > there" and similar =(
>
> seems about right :-)
>
> > Now I'd like to have a C-wrapper function to call the library entry point
> > (I did this before with code written in f77).
> >
> > The function requires arguments as this:
> > INTEGER, DIMENSION(:), INTENT(IN) :: RgType
> > REAL(kind=stnd), INTENT(IN), DIMENSION(:,:,:) :: Vertices
> >
> > I learned these arrays are "assumed-shape" arrays, i.e. they can
> > represent almost anything.
>
> They're not.
Yes they are.
The different types of array are described in
section 5.1.2.4 "DIMENSION attribute"
In summary:
- Explicit shape arrays. "real :: a(1:n)". These are allowed in f77. IF N is
not a constant this is also an automatic object.
- Assumed shape array (this case). "real :: a(1:)". Only allowed for dummy
arguments. Not allowed in f77. Must have an explicit interface.
- Deferred shape arrays. "real, pointer :: a(:)". Only allowed for pointer or
allocatable arrays. Not allowed in f77. It happens that gfortran used the
same calling conventions for these as it does for assumed shape arrays.
- Assumed size arrays. "real :: a(1:*)". Only allowed for dummy arguments.
Allowed in g77. Calling convention is same as for explicit shape arrays.
Paul
More information about the Fortran
mailing list