optimize_test, C++ codes which demonstrate the use and benefits of the compiler's automatic optimization ability.
Most compilers have an option to "optimize" your code; that is, to spend some extra compilation time looking for ways to adjust your program so that it runs faster, while getting the same results.
By default, compiler optimization is not accessed. In GFORTRAN, you can request optimization by including the "-O#' option where '#' is a value between 0 (no optimization) and 3 (high optimization). Asking for a higher level of optimization may increase the compilation time somewhat, and occasionally, an optimization performed by the compiler might not be suitable for your program (in other words, it might make your program return different or incorrect results.) Thus, it's important to time your code before and after optimization, to see if it helps, and to check your results, to see if it hurts!
The molecular dynamics example program given here runs in about 72 seconds. After optimization at level 1, it runs in 50 seconds. Optimization level 2 brings the run time down to 48 seconds and level 3 to 54 seconds. These improvements come with not a single change to the source code.
The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.
optimize_test is available in a C version and a C++ version and a FORTRAN90 version.
gprof_test, C++ programs which illustrate the use of the GPROF program performance monitor;
MD, a C++ program which carries out a molecular dynamics simulation, intended as a starting point for implementing a parallel version.
TIMER, C++ programs which demonstrate how to compute CPU time or elapsed time.
MD is a molecular dynamics program.