Next: Avoid Extensions Up: Some Notes on Previous: Input

Output

Your program should produce a neat, easily understood output file. Give it a name derived from your program name such as heat.out for program heat.f.

Write each variable that you read in from the input file or from the keyboard immediately to the output file, with a clear description what variable it is. Later, this allows you or anybody else to figure out for sure what input variables were being used to produce the obtained results. Do not merely attach the used input file. Input files may have been changed, or a different input file may have been used than you were thinking. And input from the keyboard is always suspect because of possible typos.

The output file is for reading. Output only numbers intended to be read to it. Students have been known to write 32 computed and exact mesh point values in 7 digit precision to the output file for 5 times. That is about 3000 digits. If we assume that each of these digits is studied for only one second, it takes almost an hour. Most likely a wasted hour. And if the exact and numerical solution are already different in the second digit, what can we learn from the seventh digit?

Instead present the obtained results in processed form. If you compute heat conduction in a bar and you have an exact solution, do not output a table of the computed mesh point values next to the exact values. It should not be necessary to compare numbers digit by digit to see what the differences are. Instead compute and print out the maximum and the root-mean-square errors.

To check the individual mesh point values, write them to a separate data file, and write a remark to the output file such as `The data at time 1 have been written to data file mesh1.dat'. Then use a plotting package to make a plot of the data in this data file. You will not see that there is a wiggle in your temperature profile from looking at thousands of digits.

Create plots whenever you can. For example, a plot can show much more clearly that a solution blows up than a table of numbers. Properly label all axes of your plots and give them appropriate titles.

Keep the output file for information that is truly relevant, such as the maximum temperature, the temperatures at the ends, or the total heat content of the bar, depending on the problem. Properly label what each number in the output file is.

For any number in the output file only present digits that are meaningful, and do not use scientific notation unless it is unavoidable. A number such as 12.3 is much easier to read than 0.1234567 E+002, and if no more than two digits are meaningful, you should not present them. Never let the compiler make the decision how many digits to present; do it yourself.


Next: Avoid Extensions Up: Some Notes on Previous: Input