Sample Programs for
Computational Physics, 2nd Edition

Although a liberal number of samples are given here, the reader is reminded that s/he gains the most benefit by programming everything her/himself. The programs here are really just to guide you, suggesting particular ways of implementing the pseudo-codes already given in the book. You are also warned that there are some dependences on particular compiler/OS setups and such for these programs to run as is. Please expect that you will have to make appropriate modifications to get them to run on your particular setup. Standard caveats about the possibilities of bugs still in these samples apply as well. Beware: no guarantees!

Most of the following sample programs are in a variant of the Basic language called True Basic. This is mainly because the first edition of the book used this particular language as the one to use in all sample programs given in the book; however, True Basic is a very simple computer language to learn and includes excellent graphics capabilities and thus is a good choice for the demonstration purposes. It is also available inexpensively for many hardware/software platforms. (Some information on True Basic is available from its source at www.truebasic.com.) In the True Basic sample programs, you will find some "library" calls that refer to graphics libraries.

Some of the programs are also available in Fortran. The variant of Fortran used in these samples is the venerable Fortran 77 (some even compatible with Fortran 66). If you are more familiar with Fortran 90 (or later!), you should still be able to understand/use these programs with almost no changes. Some of these samples conatin graphic subroutine calls and those are specific to a particular graphic library available at Purdue (called PEPL) and not likely to be of use to the reader elsewhere. However, there are similar graphics libraries at most installations and it should not be too difficult to modify those graphic calls appropriately. Otherwise, just use the samples to save data to files and use separate programs to plot the results. There are free versions of Fortran compilers available on most platforms, e.g., GNU Fortran (g77 or g90) and their variants. So Fortran is also a widely accessible language.

Note also: All the True Basic programs are formatted as Windows text files, meaning that each line ends with a CR/LF combination. Most of the Fortran programs are Unix text files, meaning that each line is terminated by only a LF. Your web browser should have no problems with them, but if you download them onto your machine that uses a different platform, you may wish to use a text editor/viewer which knows how to handle these formats suitably or convert them first into your machine's native text formats.