.. _optimizing: ============================================================= Optimizing code ============================================================= See :ref:`rotating` and :ref:`rotating_fortran` for some comments on writing programs that run quickly. See :ref:`optimizing_fortran` for some simple examples of Fortran optimization. Compiler such as gfortran can automatically perform some optimizations. The level of optimization is typically denoted by the `-O` flag, and `-O3` is commonly used. See :ref:`rotating_fortran` for examples of this in action, including a case where using `-O3` makes the code run slower, which can happen. Note that optimization normally has to be turned off in order to use a debugger on the code, in which case it should be compiled with the `-g` flag instead to produce more information that can be used by debuggers like `gdb`. Further reading --------------- * [Goedecker-Hoisie-optimization]_ contains many techniques for optimizing Fortran codes. * ``_ has a good list of the sort of compiler optimizations that might be performed.