(j3.2006) (SC22WG5.3591) Assumed-type and Assumed-rank extensions for C Interop TR.
Aleksandar Donev
donev1
Fri Jul 25 13:39:28 EDT 2008
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. 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)
Aleks
More information about the J3
mailing list