2nd Year Computational Laboratory
Introduction to Debugging
Support material
Some useful additional guides and tutorials that you will find useful:
Exercise 1
Download ftoc_wrong.f90, and copy it to ftoc.f90. Then compile it using:
[user@comp mijp1]$ gfortran "FLAGS" ftoc.f90
where "FLAGS" is an appropriate set of compiler flags - see compiler_flags.pdf for suggestions. This program is supposed to generate a list of temperatures, from the melting point of water to its boiling point in Farhenheit, and print out the correspondi ng temperature in Celsius.
Find all the bugs and fix them, so that the program does what it is supposed to do!
Include both the original (wrong) code and your corrected code in your ELOG. Make a note of where you think all the bugs are, explaining what you think each problem is, and what you have done to fix it and why.
return to topExercise 2
Download io_wrong.f90 and xy_in.dat. Copy io_wrong.f90 to io.f90 and compile it using:
[user@comp mijp1]$ gfortran "FLAGS" io.f90
where "FLAGS" is an appropriate set of compiler flags - see compiler_flags.pdf for suggestions. This program is supposed to read the xy_in.dat file, rescale the data so that x and y are both in the range [0,1] and then calculate the area of the data, and then output the scaled data to xy_out.dat file.
Find all the bugs and fix them, so that the program does what it is supposed to do!
Include both the original (wrong) code and your corrected code in your ELOG. Make a note of where you think all the bugs are, explaining what you think each problem is, and what you have done to fix it and why.
return to topExercise 3
Download constants.f90 algor.f90 and algor_test_wrong.f90. Copy algor_test_wrong.f90 to algor_test.f90 and then compile it using:
[user@comp mijp1]$ gfortran "FLAGS" -c constants.f90
[user@comp mijp1]$ gfortran "FLAGS" -c algor.f90
[user@comp mijp1]$ gfortran "FLAGS" constants.o algor.o algor_test.f90
where "FLAGS" is an appropriate set of compiler flags - see compiler_flags.pdf for suggestions. This program is supposed to be a test harness for a general purpose 'algorithms ' module that is part of a larger code. I have cut it down in size to make it more manageable for you! This version contains two primary algorithms: a uniform random number generator that is called many times and statistically tested; and a 'special functions' algorithm for generating erf(x) and erfc(x) which are calculated over various ranges of x and compared to the system functions.
Find all the bugs and fix them, so that the test harness works correctly!
Include both the original (wrong) code and your corrected code in your ELOG. Make a note of where you think all the bugs are, explaining what you think each problem is, and what you have done to fix it and why.
return to top