Further reading
Fortran Wiki article on submodules: http://fortranwiki.org/fortran/show/Submodules Summary
Guide To Learn
Fortran Wiki article on submodules: http://fortranwiki.org/fortran/show/Submodules Summary
The task is to define the set_gaussian subroutine, which sets the values of an input array to a specific shape, in its own module. The solution is analogous to defining the diff function in the mod_diff module. This time, we’re defining the set_gaussian procedure in the mod_initial module, as shown in the following listing. Listing 4.12 Defining the set_gaussian subroutine in a custom module ❶ Imports standard type kinds […]
The task is to import the portable type kind parameters from the iso_fortran_env module and use them in the tsunami simulator. To do this, we’ll rewrite only the declaration section, as shown in the following listing. Listing 4.11 Using portable type kinds in the tsunami simulator ❶ Assigns a name to the program ❷ Accesses only these two constants from […]
This section contains solutions to exercises in this chapter. Skip ahead if you haven’t worked through the exercises yet.
Finally, we get to the end! The complete code for the main application is shown in the following listing. Listing 4.10 Complete code of the main program of the tsunami simulator ❶ Imports type kind parameters for numeric data ❷ Imports the diff_centered function from the mod_diff module and renames it as diff ❸ Imports the set_gaussian procedure […]
Based on what we’ve covered so far about importing entities from Fortran modules, you can imagine a situation where variables or procedures with the same name could be imported from different modules. What happens in that case? Fortran will let you import two entities with the same name; however, it won’t let you reference them. […]
As you probably noticed in the previous subsection, in the new version of the tsunami simulator we’ll get to apply the diff function not once, but three times. It looks like our work with procedures and modules will finally pay off. There’s just one more thing we need to do, and that is make our finite difference […]
To go from uniform motion to a more realistic fluid flow, we need to add a few terms to the equations in our simulation code. Let’s briefly look at the shallow water equations that I first introduced in chapter 1 (figure 4.5). If you don’t care for the math, don’t worry about it; you can […]
I promised in the previous chapter that we’d finally get to some more realistic wave simulations in this chapter. With the additions to the simulator in the final section of this chapter, our water will finally start to move and slosh like real water would (figure 4.4). Figure 4.4 Simulated wave propagation as a result […]