Further reading
Summary
Guide To Learn
Summary
This section contains the solution to the exercise in this chapter. Skip ahead if you haven’t worked through the exercise yet.
Looking back at this chapter and what we’ve made so far, it’s helpful to summarize what we don’t have yet and how we’ll get there in the second part of the book: Beyond that, in part 3 of this book we’ll explore parallel computing with coarrays, as well as advanced data structures and procedures. A […]
Finally, we’ve gotten to the exciting part: taking the pieces that we’ve learned and putting them together into a complete and working program. We’ll first look at the solution of our program, visualized with a Python script, and then go through the complete code. The result The numerical solution of our simple app is shown […]
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 […]
We initialized the values of water height and are ready to get to the core of our simulation–iterating forward in time and calculating the solution at each time step. This consists of two steps: The following listing provides the core of the solver. Listing 2.12 Iterating the solution forward in time ❶ Iterates over num_time_steps time […]
Before iterating the solution forward in time, we need to specify the initial state of the water height. In other words, we need to set the initial values of the array h. A common choice in toy models like ours is a Gaussian (bell) shape (figure 2.6). Figure 2.6 Initial values of water height This is […]
We need to implement looping in our app to do two things: The main construct for looping or iterating in Fortran is the do loop: ❶ Increment n from start to end. ❷ Code inside the loop will execute end – start + 1 times. Here, n is the integer index that changes value with each iteration. In the first iteration, n equals start. […]