Compilation
When testing for memory problems it is recommended to compile the code with both the debugging options -O0 (no optimization) and -g (debugging information). Using Valgrind with code that has been compiled with optimisation options could give incorrect results.
-
C : $(CC) filecode.c -g -O0 -o fileprog.x
-
F90 : $(FC) filecode.f90 -g -O0 -o fileprog.x
-
C++ : $(CXX) filecode.cpp -g -O0 -fno-inline -o fileprog.x
The -fno-inline flag avoids the inlining of functions into the main program and makes it easier to see the function-call chain. These examples can also be applied using the MPI compiler wrappers.