11-175r1 To: J3 From: Nick Maclaren / Toon Moene Subject: Interop TR: CFI_section and strides Date: 2011 June 28 Reference: N1854, 11-168, 11-175 For clarity, this doesn't repeat the discussion in 11-175 and proposes only the second alternative. This separates out the bounds and strides and makes CFI_section essentially a C equivalent of Fortran section syntax. During the meeting, it was pointed out that the proposal in 11-168 means that the attribute argument is unnecessary, and serves only to introduce a source of error. It is therefore removed. Edits to N1854 -------------- [17:7-8] Delete "CFI attribute t attribute," and replace "const CFI_dim_t dim[]" by "const CFI_index_t lower_bounds[], const CFI_index_t upper_bounds[], const CFI_index_t strides[]". [17:18] Delete the specification of the attribute parameter. [17:19-24] Replace the paragraph specifying the dim argument by: "lower_bounds points to an array specifying the subscripts of the element in the given array that is the first element of the array section. If it is NULL, the subscripts of the first element of source are used; otherwise, the number of elements shall be source->rank. upper_bounds points to an array specifying the subscripts of the element in the given array that is the last element of the array section. If it is NULL, the subscripts of the last element of source are used; otherwise, the number of elements shall be source->rank. strides points to an array specifying the strides of the array section in units of elements of argument source; if an element is 0, the section subscript for the dimension is a subscript and the corresponding elements of lower_bounds and upper_bounds shall be equal. If it is NULL, the strides are treated as being all 1; otherwise, the number of elements shall be source->rank." [17:26-28] Replace "The attribute argument determines whether the C descriptor describes an assumed-shape array or pointer object. The value of result->rank is source->rank minus the number of dim entries for which the extent member is equal to -1." by "The value of result->rank is source->rank minus the number of stride elements which have value 0." [17:29] Replace "the C descriptor established" by "an established C descriptor". [17:34-39] and [18:1-2] Replace the example by: "the following code fragment updates a C descriptor to describe the array section A(3::5). CFI_index_t lower_bounds[] = {2}, strides[] = {5}; CFI_CDESC_T(1) section; int ind; /* Establish the C descriptor section. */ ind = CFI_section ( (CFI_cdesc_t *) §ion, source, lower_bounds, NULL, strides ); If source already points to a C descriptor for the rank-two assumed-shape array A declared in Fortran as real A(100,100) the following code fragment updates a C descriptor to describe the rank-one array section A(:,42). CFI_index_t lower_bounds[] = {source->dim[0].lower_bound,41}, upper_bounds[] = {source->dim[0].upper_bound,41}, strides[] = {1,0}; CFI_CDESC_T(1) section; int ind; /* Establish the C descriptor section. */ ind = CFI_section ( (CFI_cdesc_t *) §ion, source, lower_bounds, upper_bounds, strides ); "