30.01.2013 Views

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

TotalView Users Guide - CI Wiki

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Changing a Variable’s Data Type<br />

Viewing Pointers to Arrays<br />

Suppose you declared a variable vbl as a pointer to an array of 23 pointers<br />

to an array of 12 objects of type mytype_t. The C language declaration for<br />

this is:<br />

mytype_t (*(*vbl)[23]) [12];<br />

Here is how you would cast the vbl variable to this type:<br />

(mytype_t (*(*)[23])[12])vbl<br />

The <strong>TotalView</strong> cast for vbl is:<br />

mytype_t[12]*[23]*<br />

Viewing Arrays<br />

When you specify an array, you can include a lower and upper bound separated<br />

by a colon (:).<br />

See Chapter 15, “Examining Arrays,” on page 333 for more information on arrays.<br />

By default, the lower bound for a C or C++ array is 0, and the lower bound<br />

for a Fortran array is 1. In the following example, an array of ten integers is<br />

declared in C and then in Fortran:<br />

int a[10];<br />

integer a(10)<br />

The elements of the array range from a[0] to a[9] in C, while the elements of<br />

the equivalent Fortran array range from a(1) to a(10).<br />

<strong>TotalView</strong> also lets you cast a variable to an array. In the GUI, just add an<br />

array specifier to the Type declaration. For example, adding (3) to a variable<br />

declared as an integer changes it to an array of three integers.<br />

When the lower bound for an array dimension is the default for the language,<br />

<strong>TotalView</strong> displays only the extent (that is, the number of elements<br />

in the dimension). Consider the following Fortran array declaration:<br />

integer a(1:7,1:8)<br />

Since both dimensions of this Fortran array use the default lower bound,<br />

which is 1, <strong>TotalView</strong> displays the data type of the array by using only the<br />

extent of each dimension, as follows:<br />

integer(7,8)<br />

If an array declaration doesn’t use the default lower bound, <strong>TotalView</strong> displays<br />

both the lower bound and upper bound for each dimension of the<br />

array. For example, in Fortran, you declare an array of integers with the first<br />

dimension ranging from –1 to 5 and the second dimension ranging from 2<br />

to 10, as follows:<br />

integer a(-1:5,2:10)<br />

<strong>TotalView</strong> displays this the same way.<br />

314 Chapter 14: Examining and Changing Data

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!