(j3.2006) (SC22WG5.3591) Assumed-type and Assumed-rank extensions for C Interop TR.
Fri Jul 25 14:04:07 EDT 2008
Aleksandar Donev wrote:
> On Friday 25 July 2008 08:52, Jim Xia wrote:
>> And more, I don't understand this fragment
>> type(*),target :: block(*)
>> integer(8) :: nbytes
>> Integer(8),pointer :: usable(:)
>> call c_f_pointer (c_loc(block), usable, [nbytes*bit_size(usable)/8] )
>> In particular, I don't understand what c_loc is used for since block is
>> already an address.
> It is an assumed-shape ARRAY, not an address.
Assumed-size, actually. Either way, the real reason for the c_loc is
that the first argument of c_f_pointer is required to be of type C_PTR,
which is what C_LOC provides.
> We don't have that concept nor
> is anyone proposing we add it. It is passed by address, sure, but so are
> other assumed-shape arrays.
>> Also I don't see any type "casting" happens here as
>> the example to demonstrate that.
> You started with an array of unknown type, with which you can do nothing. Then
> you made a Fortran pointer of a known type (integer) point to it. Now you can
> do things with it. It is like doing:
> usable => block(1:nbytes/8)
> J3 mailing list
> J3 at j3-fortran.org
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3