(j3.2006) Clarification related to C interoperability

Menard, Lorri lorri.menard
Tue Feb 10 11:21:55 EST 2015


In TS 29113, on the section titled CFI_cdesc_t, there is the following description:

---
For a C descriptor of an array pointer or allocatable array, the value of the lower_bound member of each element
of the dim member of the descriptor is determined by argument association, allocation, or pointer association.
For a C descriptor of a nonallocatable nonpointer object, the value of the lower_bound member of each element
of the dim member of the descriptor is zero.
---

Here's my question; does the attribute of the array apply to the actual argument or to the dummy argument?

For example:

Program call_c

Interface
   Subroutine print_values (int_array) bind (c)
   Integer, dimension(..) :: int_array
   End subroutine print_values
End interface

Integer, allocatable :: alloc_array
Integer :: static_array(10)

Allocate(alloc_array(-1:8))
    ...
Call print_values(alloc_array)


Is the lower-bound for dim[0] of the C-Descriptor created for the call to "print_values" given the value 0, or the value -1?

Clearly, if the call were "call print_values(static_array)" then the lower-bound for dim[0] would be 0.

If the program were changed to this:

Program call_c2

Interface
   Subroutine print_values (int_array) bind(c)
   Integer, allocatable, dimension(..) :: int_array
   End subroutine print_values
End interface

Integer, allocatable :: alloc_array
Integer :: static_array(10)

Allocate(alloc_array(-1:8))
    ...
Call print_values(alloc_array)


Clearly, the lower-bound for dim[0] would be given the value -1.

If the call were "call print_values(static_array)" I would expect a compile-time error.

Other opinions?

                Thanks -

                                                --Lorri




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20150210/1d3482b4/attachment.html 



More information about the J3 mailing list