Build, debug, test and performance

The compiler is the first tool of this part: its flags, its warnings, the .mod file a module writes and the order a build has to follow. make drives that build, and gdb, -fcheck, -fbacktrace, -ffpe-trap and valgrind find what a run hides. Coverage with gcov and a hand-written assert module cover the tests, and the last lessons measure: array layout, vectorisation and the -O levels, timed five times each.

110 gfortran flags and warnings -Wall, -Wextra, -Wconversion, -std, -J, -c, -o and a flags table with what each one catches Open 111 Modules, .mod files and separate compilation gfortran -c, the .mod file a module writes, the order of the objects, and a build script Open 112 make and a project layout a Makefile with the module order, src and build folders, and a real make run Open 113 Debugging with gdb -g, gdb -batch, break, run, print, backtrace and a real crash found Open 114 -fcheck, -g and -fbacktrace -fcheck=all, an out-of-bounds array access caught, -fbacktrace and the line it names Open 115 -ffpe-trap and floating-point exceptions -ffpe-trap=invalid,zero, a division by zero that stops, and the status it leaves Open 116 valgrind on a Fortran program valgrind --leak-check=full on a real program, the summary it prints, and a leak it finds Open 117 gcov and coverage -fprofile-arcs -ftest-coverage, the .gcda files, gcov output and a line that never ran Open 118 Testing: a hand-written assert module an assert subroutine, a counter, PASS and FAIL lines and a driver that exits non-zero Open 119 Testing: drivers, tolerances and exit codes a table of cases, a tolerance check, an ERROR STOP on failure and the tools not in this image Open 120 Performance: layout and vectorisation the loop order over a 2D array, -O2 with and without -ftree-vectorize, and measured timings Open 121 -O levels measured -O0, -O2 and -O3 on the same program, five runs each, min and median, and what changed Open

Lessons