Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner

Detect uninitialized variables that have the SAVE attribute with -ftrapuv

Dear intel team,

 

I am part of a larger group of developers that work on a quantum chemistry code  written in Fortran that was founded a few decades ago. We made now an initiative to identify some "hidden bugs" in the code for several reasons. As the code grew over the years people started coding using some Fortran constructs that are considered today as bad practice because they result in side effects that are error prone and hard to debug. In particular, we tried to identify bugs related to uninitialized variables, which I tried to identify with -ftrapuv available in the ifort 15.0.2 compiler for a Linux cluster. Old parts of the code, however, frequently employ variables with the SAVE attribute. There are several subroutines where those variables are initialized if a certain flag is given and incremented by some value otherwise. In the latter, the compiler is not  able to identify that initialization was correctly performed in an previous (initial) subroutine call. Unfortunately, there are too many variables with the SAVE attribute to simply change the code. There is another social aspect that some members of the community refuse such a re-writing. Is there a solution to that problem or any plans to provide a mechanism to detect uninitialized save variables. When using the gfortran compiler with the -fnit-(real/integer/logical)=something_silly flag the program does not abort when variables with save attributes are accessed.

Kind regards,

Ben

 

 

 

0 Kudos
3 Replies
Highlighted

Please see -init=snan, which

Please see -init=snan, which does what you want. -ftrapuv doesn't do what you want (and doesn't really do anything useful.)

Retired 12/31/2016
0 Kudos
Highlighted

>>There is another social

>>There is another social aspect that some members of the community refuse such a re-writing.

When education fails, sometimes humiliation works. Do these members really want the persistence of a bug attributed to them?

Jim Dempsey

0 Kudos
Highlighted
Beginner

Thanks for your support. As

Thanks for your support. As -init=snan,arrays is available since ifort 16 (I guess so since it is not a valid flag for 15.0.2) I ran the test examples once more. It stopped basically at the same part of the code and it is indeed a bug in the code and not an incapability of the Intel Fortran Compiler. Thanks for providing such tools that help debugging.

Ben

 

0 Kudos