02.07.2014 Views

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

Intel(R) Fortran Compiler for Linux* Systems User's Guide Volume I ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Intel</strong>® <strong>Fortran</strong> <strong>Compiler</strong> <strong>for</strong> <strong>Linux*</strong> <strong>Systems</strong> <strong>User's</strong> <strong>Guide</strong>, <strong>Volume</strong> I: Building<br />

Applications<br />

7. The command print n, k displays the current values of variables N<br />

and K. Their values are correct at this point in the execution of the<br />

program.<br />

8. The two step commands continue executing the program into the loop<br />

(lines 9 to 11) that copies and squares all nonzero elements of INARR into<br />

OUTARR. Certain commands can be abbreviated. In this example, the s<br />

command is an abbreviation of the step command.<br />

9. The command print i, k displays the current values of variables I and<br />

K. Variable I has the expected value, 1. But variable K has the value 0<br />

instead of the expected value, 1. To fix this error, K should be incremented<br />

in the loop just be<strong>for</strong>e it is used in line 11.<br />

10. The assign command assigns K the value 1.<br />

11. The watch variable k command sets a watchpoint that is triggered<br />

every time the value of variable K changes. In the original version of the<br />

program, this watchpoint is never triggered, indicating that the value of<br />

variable K never changes (a programming error).<br />

12. To test the patch, the cont command (an abbreviation of continue)<br />

resumes execution from the current location. The program output shows<br />

that the patched program works properly, but only <strong>for</strong> the first array<br />

element. Because the watchpoint (watch variable k command) does<br />

not occur, the value of K did not change and there is a problem. The idb<br />

message "Process has exited with status 0" shows that the program<br />

executed to completion.<br />

13. The quit command returns control to the shell so that you can correct the<br />

source file and recompile and relink the program.<br />

14. The shell command vi runs a text editor and the source file is edited to<br />

add K = K + 1 after line 10, as shown. (<strong>Compiler</strong>-assigned line numbers<br />

have been added to clarify the example.)<br />

15. The revised program is compiled and linked. The shell command idb<br />

squares starts the debugger, using the revised program so that its<br />

correct execution can be verified.<br />

16. The when at 12 {print k} command reports the value of K at each<br />

iteration through the loop.<br />

17. The run command starts execution.<br />

18. The displayed values of K confirm that the program is running correctly.<br />

19. The quit command ends the debugging session, returning control to the<br />

shell.<br />

Displaying Variables in the Debugger<br />

To refer to a variable, use either the uppercase or lowercase letters. For<br />

example:<br />

(idb) print J<br />

97

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

Saved successfully!

Ooh no, something went wrong!