Viewing Individual Elements in an Array of Structures
On this page:
If you have an array of structures data object, you may wish to analyze a particular field of the structure in all the elements of the array; this would require expanding all the elements and then scrolling through the expanded array and visually searching through for that single field.
To avoid this painstaking process, use the Dive-In-All command.
The Dive In All Command
The Dive-In-All command can display a single field of a structure in an array of structures as a new array across all the structures. This makes it much easier to look at the values of only that field.
In Figure 53, the array of structures strucArray in the left pane contains 20 structures, far more than the Data View can actually display. After you select the Dive in All command with element a selected, TotalView creates a new array in the Data View that contains all these a elements across all structures, shown in the right pane.
|
|
Accessing Dive In All
To Dive-In-All on a variable, right-click a field in a single element of the array in the Data View, and choose Dive In All (short for “dive in all elements”) from the context menu.
Figure 54. Dive In All context menu
Displaying a Fortran Structure
Consider the following Fortran definition of an array of structures:
type i_c
integer r
complex c
end type i_C
type(i_c), target :: rc2(3,4)
With the array in the Data View, select an r element, right click, then select Dive In All. TotalView displays all of the r elements of the rc2 array as if they were a single array.
|
|
Displaying a C++ Structure
The Dive in All command can also display the elements of a C array of structures as arrays. Figure 56 shows a unified array of structures and a multidimensional nested array in a structure.
|
|
Here, the array of structures foo contains a nested array of structures b, visually represented like so:
The array strucArray[:].foo visually represents an array composed of every foo element in each of the 20 strucArray objects.
Drilling further, the array strucArray[:].foo[:].b visually represents an array composed of every b element in the array of structures strucArray[:].foo.
Using Dive In All to Deference a Pointer in an Array of Pointers
If you have an array of pointers that you first want to dereference to see the values, use Dive In All on a pointer to create a new array of the dereferenced value. In Figure 57, ptrArray is an array of pointers of integers. Using Dive In All on a single pointer creates a new array of just integers in which each element of the original array is dereferenced.
Figure 57. Dive In All used to dereference a pointer in an array of pointers