Best Debugging Compiler Options?

Hello All
I have what I believe to be a simple question.

I’m compiling a fairly large code using pgf90 and was wondering if there are debugging compiler options that would tell me where in the
code it runs into errors (like FPEs or SegFaults). Right now I am use this
set of options (see below) and I thought -traceback should give me some information about where in the source code I experience issues. Unfortunately it just tells me I have an issue and the job terminates. Am I missing something?

F90FLAGS = -Mbounds -Minfo=all -traceback -Mchkfpstk -Mchkstk -Mdalign
-Mdclchk -Mdepchk -Miomutex -Mrecursive -Msave -Ktrap=fp -O0 -g -byteswapio

Also are there a standard set of debugging options that would be good practice to use for diagnosing runtime errors?
Thanks in advance!

-ABT

Hi ABT,

You have them all! The only thing your missing is that you need to set the environment variable PGI_TERM to tell the runtime what to do when it encounters an error. Setting it to “debug” will launch the PGI debugger, PGDBG, in text mode, while “trace” will dump a stack trace. For details please see Chapter 10 of the PGI User’s Guide.

In your case, I would recommend running your code directly within PGDBG. The debugger will break on error. You can then set a break point before the error occurs. When you re-run the code, it will stop at the break point allowing you to better diagnose the error. If you are unfamiliar with PGDBG or debuggers in general, please refer to the PGDBG User’s Guide.

Another useful utility is Valgrind (http://www.valgrind.org) which is very helpful in finding memory issues such as uninitialized memory reads (UMR).

Hope this helps,
Mat

Thank you for the quick answer, Mat! It is much appreciated. I am going to try setting the environment variable to debug and see if that gives me any relief from the woes of unclear code crashes.

One last question while I have your ear. Does setting the environment variable to “debug” or “trace” also apply if I am running parallel code or is there something a little extra I need?

Thanks again.

-ABT

Does setting the environment variable to “debug” or “trace” also apply if I am running parallel code or is there something a little extra I need?

Nope. PGI_TERM works with OpenMP and MPI. For MPI you just need to make sure the environment variable gets set for each process since your shell environment doesn’t get inherited.

  • Mat