# (j3.2006) reverse section contiguous?

Bill Long longb
Fri Jan 6 14:27:35 EST 2012

```
On 1/5/12 4:43 PM, John Reid wrote:
>
>
> Dick Hendrickson wrote:
>> On Thu, Jan 5, 2012 at 12:56 PM, Bill Long<longb at cray.com>   wrote:
>>> The question arose as to, given
>>>
>>>      real x(10)
>>>
>>> whether
>>>
>>>      x(10:1:-1)
>>>
>>> is CONTIGUOUS.
>>>
>>> The relevant part of the "is contiguous"  rules is
>>>
>>> "An object is contiguous if it is ...
>>>
>>>     (6) a nonzero-sized array section (6.5.3) provided that ...
>>>
>>>        (c) the elements of the section, in array element order, are a subset
>>> of
>>>        the base object elements that are consecutive in array element order,"
>>>
>>> The elements of the section are  {A(10), A(9), A(8), ..., A(1)}  which, as a
>>> set of elements, is a subset of {A(1), A(2), ..., A(10)}. (Perhaps "subset"
>>> is a flawed word here.)
>>>

The replies from Dick and John below match what I thought was the
intent. It might be clearer above if we said "the sequence of the
elements of the section, in array element order, is {part | a
subsequence } of the sequence of base object elements that are
consecutive in array element order".

Cheers,
Bill

>>> The test for NOT contiguous includes:
>>>
>>> "the elements of the object in array element order are not consecutive in
>>> the
>>> elements of the base object"
>>>
>>> which does appear to be satisfied, since "consecutive" implies both an
>>>
>>> Did we intent for X(10:1:-1) to be CONTIGUOUS?   In other words, is "packed
>>> in memory with no gaps" good enough here, or do we also require "memory
>>> locations in the same order as the memory locations of an explicit-shape
>>> whole array"?
>>
>> Since I don't go to the meetings, I'll vote early.  I think the second
>> choice is the one we meant.  I think we added contiguous to
>>
>> A) allow optimizers to do fast addressing without having to worry
>> about the stride part of the dope vector and
>> B) to allow contiguous arrays to be easily passed to other languages
>> which don't naturally have strided arrays.
>
> I agree. The definitive quote is (6)(c) above, where "in array element
> order" appears for both the section and the base object. There is
> further evidence in 6.5.4. "A section-subscript-list speci
es a simply
> contiguous section if and only if .... the last subscript-triplet does
> not have a stride, ..." And in 7.2.2.3, p9 "If bounds-remapping-list
> is speci
fied, the pointer target shall be simply contiguous (6.5.4) or
> of rank one. ... The elements of the target of the pointer object, in
> array element order (6.5.3.2), are the
first SIZE (data-pointer-object)
> elements of the pointer target." Further, I see no examples of
> contiguous objects with strides of -1.
>
> John.
>
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3

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

```