Debugging flags
On all systems, and for both Fortran and C/C++, if one wishes to produce code that will be useful for debugging one has to use the -g flag for both compiling and linking:
% cc -g -c c_program.c
% cc -g -o run_prog c_program.o -lm
Code that has been compiled with the -g flag will be slow - so don't use it for production runs. On the Suns, acc/cc (for SunOS/Solaris) will allow -g to be used along with optimization flags, on the SGIs you should look at the man pages for debugging flags that do optimization. No such feature exists for the IBMs and the othe Sun compilers where -g overrides any optimization flags. It is recommended that you compile with -g and no optimization and then test your code on small test problems where run time is not a concern. This will enable you to find the bugs that are due to your code alone - optimization can cause additional problems that will obscure the source of your bugs. Of course if you are having problems with your code working on large datasets after a long time, then you may very well need to compile with both debugging and optimization flags.