We now have the time loop that iterates the solver for exactly num_time_steps time steps. The last remaining step in this chapter is to print the results to screen. The simplest approach is to print the results to the terminal, from where we can redirect the output to a file for later use, such as plotting. For this, you can use the print statement, which you already encountered in chapter 1:
print *, n, h ❶
❶ Prints values n and h to the terminal using default formatting
print is the simplest output statement in Fortran. The * symbol that’s placed immediately after print signifies default formatting, which tells the compiler to use any format for the data it finds convenient. In most cases, the default format will be reasonable. As noted, here we’re printing the values of n (integer scalar) and h (real array with 100 elements) to the screen. This statement will thus output exactly 101 values to the terminal in a single line.
We’ll explore Fortran input/output in more detail in chapter 6. For now, print * is all we need.