(j3.2006) CFI_establish questions

Bill Long longb
Wed Oct 29 14:03:16 EDT 2014

On Oct 29, 2014, at 11:16 AM, Lionel, Steve <steve.lionel at intel.com> wrote:

> I have some questions about CFI_establish that seem unanswered by either the TS or 14-007r2. I hope some light can be shed on this for me.
> 14-007r2 says, for the elem_len argument:
> ?If the type is equal to CFI type struct, CFI type other, or a Fortran character type code, elem_-
> len shall be greater than zero and equal to the storage size in bytes of an element of the object.
>         Otherwise, type will be ignored.?
> First, is the intention that if the type is not struct, other or character, CFI_establish will fill in the elem_len field on its own, based on its knowledge of type? I could infer this from the general instruction to create an ?established C descriptor?, but it seems rather vague.

Yes, for types with known storage sizes the routine will (should) fill in the correct value.  

> Second, the ?Otherwise, type will be ignored.? seems like an incorrect edit (it wasn?t expressed that way in the TS.) I assume it means to say elem-len will be ignored, but I really think it should say what value is stored in the elem_len field of the descriptor (see previous question.)

This seems like a mistake. I agree that we should  say what happens in the case that the IF conditions of the initial sentence are not satisfied. The TS text says that elem_len is ignored unless?  The new last sentence should read  ?Otherwise, the value of elem_len is ignored.?   If you are setting up a descriptor for a CFI_type_int, for example, you do not want the user to think they can redefine the element length to 37 by supplying a bogus value for the elem_len argument. 

> Next question: if rank is non-zero but base_addr is zero, what, if anything, should CFI_establish do with the dim field of the descriptor? The text says that the extents argument is ignored in this case. I suppose it does no harm to leave these undefined, but it bothers me to do so.

If the base address is zero (by which I assume you really mean NULL),  then you are setting up a descriptor for an unallocated allocatable or a pointer that is not associated.   A subsequent call to CFI_allocate or CFI_setpointer will fill in the dim information.  If you are concerned about leaving the dim values undefined on exit from CFI_establish, you could either assign the dim elements to zero, or (more interesting) to very large values that would result in a likely segfault if the descriptor was mis-used later.


> Steve Lionel
> Intel Developer Support
> Merrimack, NH
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Suport  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101

More information about the J3 mailing list