Compiler setting to catch defined but unset variables


I compile a section of code with the following options:

mpif90 -g -C -v -byteswapio -c -Mbounds -Mchkptr -Mchkstk -Mextend -Mfree -Ktrap=fp -i4 -r8 -mcmodel=medium mycode.f

The code runs fine, but I’ve just noticed that within the code there is a variable that is defined but not set. When it is later used it is taking a value of zero.


REAL Variable_A
REAL Variable_B
REAL Variable_C


Variable_C = Variable_A + Variable_B

So Variable_A is set to 10 and then used but Variable_B is used (read from) but not set (written to).

I would like to know if there is a compiler option available that would catch such a mistake.

The real code is rather longer so it’s not always so easy to spot these mistakes!

Thanks in advance for your help,

Hi K,

There isn’t a compiler setting for this but I have found Valgrind ( a usefull utility when finding UMRs (unitialized memory reads).

Hope this helps,

Thanks, I’ll give that a try…