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

How to set unititialised variables to zero ?

bnsmod123
Beginner
1,355 Views

In my program i am passing a variable to some function without initialising, in my previous compiler it was automatically set to Zero. I am using Intel Fortran Compiler 9.0 now and the variable contains garabge value. I have set "Initilise Local Saved Scalars to Zero" option( in visual studio 2003) to "YES", but still it's not initialised to Zero.

- Pramod

0 Kudos
5 Replies
Steven_L_Intel1
Employee
1,355 Views
Only static, local variables get initialized this way. It's not a universal solution. Good programming practice is to have your code initialize all variables before use.
0 Kudos
bnsmod123
Beginner
1,355 Views

can you please let me know the compiler setting to initilise Static and Local variables. I am porting compac visual fortran to Intel Visual fortran, some variable in my code contain uninitilised variables which were working well in compaq but in Intel it's setting that to garabage value. I have to port very huge piece of code and i don't how many variables are uninitilised.

-Pramod

0 Kudos
Steven_L_Intel1
Employee
1,355 Views
The command line option is /Qzero. You should combine this with /Qsave (and that's probably the original poster's problem too). In Visual Studio, these are under the Data property page: Local Variable Storage>All variables SAVE and Initialize Local Saved Scalars to Zero>Yes.
0 Kudos
TimP
Honored Contributor III
1,355 Views
You still should consider correcting the source so as not to require /Qsave. For example, the -Qparallel option requires that, and this option will get improvements in the near future. The option -check:uninit (without -Qzero or -Qsave) ought to assist in finding candidates, although we have found annoying false positives.
0 Kudos
bnsmod123
Beginner
1,355 Views
Thank you that solved my problem
0 Kudos
Reply