.. _optimizing_fortran: ============================================================= Optimizing Fortran ============================================================= Several simple examples are given in `$CLASSHG/codes/fortran/optimizing`. See :ref:`rotating_fortran` and `$CLASSHG/codes/fortran/particles` for some other examples. 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. But there are many sorts of optimizations that the compiler cannot do for you, where some care in coding can make the program run much faster. Further reading --------------- * [Goedecker-Hoisie-optimization]_ contains many techniques for optimizing Fortran codes.