|
Assignment
To your left you can select to see more details on this assignment if you
need them. You can also select tips if you need some suggestions to get
started on the assignment. Finally, you can select Solution to view a
solution to the problem.
Your first assignment is to use TotalView to locate
an error in the following program. The program is printing a value of "NAN" or "-Infinity"
for one of the values.
Compile the code with ifort and locate the source of the error.
Details
cut and paste the code into the file 'nan.c'
Compile the code with the default Intel compiler with:
icc -g -o nan nan.c
Execute the code to see the error
./nan
Tips
Load TotalView: module load totalview
Run TotalView: totalview
- File -> New Program
- Browse for your executable
- select your executable, 'nan'
When you click the "Go" button, the program will run, and print the STDOUT to the window you launched totalview from.
- click on the line number for the 3rd for statement.
- click the "Go" button.
- double-click the variable "vec" in the Stack frame window (in the upper right).
- Do all the elements in the array look right?
- Try stopping the program at a different line, and look at the array contents.
A solution
The first for loop should run from 0 to 9 instead of 1 to 9. When the first number of vec is not set in this loop, it remains zero. When we take the Log of zero, it gives NaN or -Infinity.
|