Re: gfortran and the family of fortran array types
- From: relaxmike <michael.baudin@xxxxxxxxx>
- Date: Tue, 26 Aug 2008 00:37:14 -0700 (PDT)
Thank you very much for your both messages.
Now I clearly understand what happens.
Back to the initial problem, I can implement
what is probably the solution used by Intel,
that is, the creation of a module which
contains the definition of the interface for the
subroutine (but Intel does that for me automatically).
module mymodule
interface
subroutine mysub (x)
integer :: x(:)
end subroutine mysub
end interface
end module mymodule
program test
use mymodule
integer y(2)
y(1) = 123
y(2) = 12
call mysub (y)
end program test
subroutine mysub (x)
integer :: x(:)
print *, x(1)
print *, x(2)
end subroutine mysub
When I look to the intermediate code generated
by gfortran, it appears that the data, which
is initially created in a basic data storage with
type integer(kind=4), is transferred to a struct, and
only the struct is passed to the subroutine so that it matches
the interface :
test ()
{
integer(kind=4) y[2];
static integer(kind=4) options.0[7] = {68, 255, 0, 0, 0, 1, 0};
_gfortran_set_options (7, (void *) &options.0);
y[0] = 123;
y[1] = 12;
{
struct array01_integer(kind=4) parm.1;
parm.1.dtype = 265;
parm.1.dim[0].lbound = 1;
parm.1.dim[0].ubound = 2;
parm.1.dim[0].stride = 1;
parm.1.data = (void *) &y[0];
parm.1.offset = -1;
mysub (&parm.1);
}
}
I have two more possibilities to solve my
problem :
- use a contains in the program, so that the
subroutine mysub is a internal subroutine of the
program,
- put the body of the subroutine directly into the
module.
It also clearly shows why there is a problem with
the interoperability with C, see the chasm project :
http://chasm-interop.sourceforge.net/
Regards,
Michaël
.
- Prev by Date: Re: F2003 complier, how far from us?
- Next by Date: Re: Implementing JAVA interfaces in FORTRAN 20xx
- Previous by thread: Re: gfortran and the family of fortran array types
- Next by thread: Re: gfortran and the family of fortran array types
- Index(es):