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

Automatic initialization of numeric variables?

Leigh
Débutant
1 134 Visites
Does Intel Fortran have a compiler option that forces static numeric variables to be initialised to zero?

I have seen the /Qzero and /Qtrapuv options. However, they don't seem to fit the bill.

Alternatively, is there an option to cause warning to be produced if a variable is used without having been initialised? I can understand that C compilers can do this because goto is rare in C. I'm not sure whether such a warning is possible in Fortran where goto might be present.

Thanks for your attention.

Leigh.
0 Compliments
1 Solution
netphilou31
Nouveau contributeur III
1 134 Visites
Hi Leigh,

I think that you have to also use the /Qsave option (save local variables in static allocation ) with the /Qzero option. However you did not mention which version of the compiler you are using.

Concerning the use of local, uninitialized variables, the compiler shouldnormally give you some warning message.

Phil.

Voir la solution dans l'envoi d'origine

0 Compliments
3 Réponses
netphilou31
Nouveau contributeur III
1 135 Visites
Hi Leigh,

I think that you have to also use the /Qsave option (save local variables in static allocation ) with the /Qzero option. However you did not mention which version of the compiler you are using.

Concerning the use of local, uninitialized variables, the compiler shouldnormally give you some warning message.

Phil.
0 Compliments
Leigh
Débutant
1 134 Visites
Hi,

The version is 2011.0.14.

I should also say that the body of code I am working on is legacy code. These variables are also at the program level. Does /Qsave have an effect on those.

Thanks,
Leigh.
0 Compliments
Steven_L_Intel1
Employé
1 134 Visites
The compiler offers run-time errors for uses of uninitialized local variables through /check:uninit. It has some limitations.

/Qtrapuv, in its current implementation, does nothing useful.
0 Compliments
Répondre