(j3.2006) TKR for C Interop

Bill Long longb
Wed Feb 28 18:58:44 EST 2007

Aleksandar Donev wrote:

>On Wednesday 28 February 2007 13:01, Bill Long wrote:
>>Struct components either have documented names or not.  This is direction
>OK, I was not aware of "small-group" decisions to change the API to a mixed 
>struct/function approach (which is fine by me, modulo some details I complain 
>about below).
>For such an approach, the Fortran->C descriptor function should set the rank 
>and type information to invalid values if they are not available (say 0 for 
>rank and -1 for size of the element in bytes), or set them to valid values if 
>they are available in the Fortran descriptor.

Yes. The current thinking is give these standardized invalid values 
names to provide some implementation flexibility and make the user code 
a little more self documenting.  The values would be otherwise 
impossible values, such as negative values for sizes of things.

>>The other functions create/destroy a shell C descriptor 
>Why is this necessary? If we expect that the C descriptor will not match most 
>vendors descriptors (and Craig can easily tell you this for several 
>compilers), what is the point of making the C struct soo opaque? Let's allow 
>the programmer to directly declare C descriptors without "creating" and 
>"destroying" them. Some components of the C struct can still be opaque.
>In C, structs are either of fixed size (this means rank-independent in our 
>particular case), or they have flexible array members. I don't know of an 
>in-between alternative. Which one of these two is this C struct you are 
>BTW, C also has "incomplete types" which have unspecified size:

The incomplete type option has come up as a candidate.  The simplest is 
fixed size.  In the worst case I can think of, this could be ~140 64-bit 
words, though for vendors that support higher than rank 15 it could be 
even more.  Do you think this would be acceptable?  If so, I'm happy to 
get rid of two more functions.  And it would allow the descriptors to go 
onto the stack which gives better performance and reduces the chance for 
memory leaks.


>"The use of a type specifier of the syntactic classes 
><structure-type-reference> ... without a preceding definition...is alowed 
>when the size of the structure is not required, including when declaring:
>1. pointers to the structure
>2. a typedef name as a synonym for the structure"
>This is like a "handle" to a descriptor.
>I see more open (and more fundamental) questions than just the triplets.
>J3 mailing list
>J3 at j3.scs.gmu.edu

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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3.scs.gmu.edu/pipermail/j3/attachments/20070228/6c6dc61a/attachment-0001.html 

More information about the J3 mailing list