Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Detect uninitialized variables that have the SAVE attribute with -ftrapuv

Benjamin_H_1
Beginner
323 Views

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
Steven_L_Intel1
Employee
323 Views

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

0 Kudos
jimdempseyatthecove
Honored Contributor III
323 Views

>>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
Benjamin_H_1
Beginner
323 Views

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
Reply