"Maximum debug" flags with PGI compiler

Hello,

I’m trying to get some legacy code to not crash and burn with the PGI compiler, and I came across a stack overflow post (edit: this one) that recommended a so-called “maximum debug” collection of compiler options for gfortran:

-O2 -fimplicit-none -Wall -Wline-truncation -Wcharacter-truncation -Wsurprising -Waliasing -Wimplicit-interface -Wunused-parameter -fwhole-file -fcheck=all -fbacktrace

What are the PGI equivalents to most of these?

  • -O2: -O2
  • -fimplicit-none: -Mdclchk?
  • -Wall: -Minform=inform? The gfortran compiler seems to have a lot more specific things it can warn about than the PGI compiler, such as…
  • -Wline-truncation, -Waliasing, -Wimplicit-interface, -Wunused-parameter: ??
  • -fwhole-file: ??
  • -fcheck=all: -Mbounds? (Which is itself equivalent to -C, right?)
  • -fbacktrace: -traceback

I’m already using the PGI-specific flag -Ktrap=fp,unf in my quest to get this code working. Are there any other flags you would suggest for maximum debugging?

While I have you, I’m having trouble getting -traceback to actually give a line number. I have to be using the PGI debugger in order to get the proper trace, which is a bit surprising to me (I am compiling with -g if that makes a difference). Is there a way to have the program write the trace to the display unit? Thanks in advance for the help.

Hi dcwarren,

-O2: -O2

Roughly, but not exactly. Though, I would not compile with optimization at all and use “-O0” instead,

-fimplicit-none: -Mdclchk?

-Mdclchk checks that all your variables have been declared, so yes it’s equivalent to -fimplicit-none"

-Wall: -Minform=inform

Yes, but this can get very verbose.

-fwhole-file

This is the default for both gfortran and PGI.

-fcheck=all

-Mbounds -Mchkptr -Mchkstk

-fbacktrace: -traceback

-traceback is on by default. You just need to set the environment variable PGI_TERM to “trace” or “debug”. Though, you may also need to add the link flag “-Meh_frame” in order to get the linker to not throw away the exception handling frame information.

Another useful utility is Valgrind (www.valgrind.org) which is able to find memory issues such as UMRs.

  • Mat

Thanks for this. I’m not sure why the guy on Stack Overflow recommended compiling with -O2, but I don’t set any optimization when I do debugging. (I’ll be specifying -O0 in the future!)