next up previous contents
Next: 8.2 Gravitylab Up: 8. A More Modular Previous: 8. A More Modular

8.1 Starting a Tool Box

In this chapter we will discuss in detail a more modular version of the Hermite code hermite6.C, developed in the previous chapter. The new version is called nbody_sh1.C. Here `sh' stands for the shared but variable time step choice, and the number 1 indicates again that this is the first version. This code will be the first tool of a tool box that we will continue to develop in the rest of this book, as well as in following books in this series. From now on, each tool will adhere to our $N$-body I/O format, specified in the previous chapter (and possibly more fancy formats as well, but we will keep those more advanced versions compatible with our current bare bones format). In addition, each tool will have extensive comments, explaining both the usage and the internal structure of the code.

The new code, nbody_sh1.C, has roughly four times more lines than the previous version, hermite6.C. Almost half of these lines are either comments of blank lines, both of which help to make the code more readable and more understandable. The fact that the code itself still has more than twice the length of the previous version stems from several factors. First, the new code has nine functions, besides main(), while the old code had only two. Second, there are seven command line options, rather than two. Third, we now declare all functions at the top of the file. Finally, there is more diagnostics output than we had before.

Below, the full code is presented, one function at a time.


next up previous contents
Next: 8.2 Gravitylab Up: 8. A More Modular Previous: 8. A More Modular
The Art of Computational Science
2004/01/25