Totalview® for HPC User Guide : PART II Debugging Tools and Tasks : Chapter 10 Examining Arrays : Examining and Analyzing Arrays : Displaying Array Slices : Using Slices and Strides
Using Slices and Strides
A slice has the following form:
lower_bound:upper_bound[:stride]
The stride, which is optional, tells TotalView to skip over elements and not display them. Adding a stride to a slice tells the debugger to display every stride element of the array, starting at the lower_bound and continuing through the upper_bound, inclusive.
For example, a slice of [0:9:9] used on a ten-element C array tells TotalView to display the first element and last element, which is the ninth element beyond the lower bound.
If the stride is negative and the lower bound is greater than the upper bound, TotalView displays a dimension with its indices reversed. That is, TotalView treats the slice as if it was defined as follows:
[upperbound : lowerbound : stride]   
CLI: dprint an_array(n:m:p,q:r:s)
For example, the following definition tells TotalView to display an array beginning at its last value and moving to its first:
[::-1]
This syntax differs from Fortran 90 syntax in that Fortran 90 requires that you explicitly enter the upper and lower bounds when you’re reversing the order for displaying array elements.
Because the default value for the stride is 1, you can omit the stride (and the colon that precedes it) from your definition. For example, the following two definitions display array elements 0 through 9:
[0:9:1]
[0:9]
If the lower and upper bounds are the same, just use a single number. For example, the following two definitions tell TotalView to display array element 9:
[9:9:1]
[9]
NOTE >> The lower_bound, upper_bound, and stride must be constants. They cannot be expressions.
Example 1
A slice declaration of [::2] for a C or C++ array (with a default lower bound of 0) tells TotalView to display elements with even indices of the array; that is, 0, 2, 4, and so on. However, if this were defined for a Fortran array (where the default lower bound is 1), TotalView displays elements with odd indices of the array; that is, 1, 3, 5, and so on.
Example 2
Figure 158 displays a stride of (::9,::9). This definition displays the four corners of a ten-element by ten-element Fortran array.
Figure 158 – Stride Displaying the Four Corners of an Array
Example 3
You can use a stride to invert the order and skip elements. For example, the following slice begins with the upper bound of the array and displays every other element until it reaches the lower bound of the array:
(::-2)
Using (::-2) with a Fortran integer(10) array tells TotalView to display the elements 10, 8, 6, 4, and 2.
Example 4
You can simultaneously invert the array’s order and limit its extent to display a small section of a large array. The following figure shows how to specify a (2:3,7::-1) slice with an integer*4(-1:5,2:10) Fortran array.
Figure 159 – Fortran Array with Inverse Order and Limited Extent
After you enter this slice value, TotalView only shows elements in rows 2 and 3 of the array, beginning with column 10 and ending with column 7.