|
Assignment
Use TotalView to locate
an error in the following program. The program should print a sum of matrix components. The correct sum is 5.001E+7.
Details
cut and paste the code into the file wrong.f
ifort -g -o wrong wrong.f
./wrong
Tips
- Load the program in TotalView.
- Double click on the common block named "block" in the stack frame
- In the window for the common block that pops up, you will see a list of all the variables that make up the block. Double click on VECA2 to view the contents of the array.
- When does the array VECA2 become corrupt?
- What will fix the problem?
A solution
The index used to assign values to VECB goes out of the bounds for this array. The index only goes slightly outside the boundaries of the array, so it does not cause a segmentation fault. Instead, the loop starts assiging values to VECA2. Values in VECA2 were overwritten because VECA2 was in the next chunk of memory following VECB.
Change the index for VECB or comment out the line entirely to solve the problem.
|