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

Problem with /qzero un update 6

hkausl
Beginner
773 Views
I had same strange problems in my programs after updating to version 6. It seems, that /qzero doesn't work as it did before. So I made a small console program and comiled it in VS2010 with /qzero option

program test

write ( *,* ) ' ih = ', ih

call exit

end

I get the following result

ih = -1757079179

Drcken Sie eine beliebige Taste . . .

I'mshure, that this worked in the versions before, the result was 0. This is a problem for me, because I migratet all my programs from digital fortran to intel. In df all scalar values were 0 when starting. This made me some problemswith the Intel compiler till I found the /qzero option. Now the problem seems to be back.

0 Kudos
11 Replies
hkausl
Beginner
773 Views
You are correct, the titel of my post is wrong. But I choose the option in visual studio and therefore the compile is done with the correct options. It doesn't work
0 Kudos
TimP
Honored Contributor III
773 Views
How about adding a SAVE in the source code, or adding the option /Qsave as part of your interim fix? /Qzero tends to work only on SAVE variables. ifort has changed the default status of local variables in Fortran main program so they are no longer SAVE by default.
I'd hesitate to say that "correct" options exist for source code with undefined variables.
0 Kudos
Steven_L_Intel1
Employee
773 Views
Which Intel version did you use where /Qzero gave you the result you wanted? Tim is correct that it should work only if you also specify /Qsave. I assume you know that your program is not legal Fortran if it requires such measures.

The main problem is that if the initialization is not done, the variable's value is unpredictable. It may be zero, it may be something else that could change from run to run.
0 Kudos
hkausl
Beginner
773 Views
I'm quite sure that it worked withupdate 3. of the current compiler.This is the version where I migrated my Digital Fortran programs to. In digital fortran all variables were zero when starting. I don't want so save variables, I only want to be shure, that when program starts, the variables are zero. This worked for my since more than 30 years with fortran compilers from DEC,IBM-MVS, IBM-aix, Microsoft, Intergraph and so on.
So I have a look on my sources to find such unsetted variables and set them. Is there a compiler option to help my find such.
0 Kudos
DavidWhite
Valued Contributor II
773 Views
Steve will correct me if I'm wrong, but you were relying on a feature of the earlier compilers which are not supported by the Fortran Standard. No compiler is required to initilize "uninitialized" variables. If you do not initialize a veriable, but go ahead and use it, there is no guarantee that the value will be zero, or even any other particular value.

If your program uses uninitialized variables, then your program is not compliant with the Fortran standard, even if they have previously worked with other compilers. Rather than expecting the compiler to behave as you would like them (either with or without particular compiler switches), you should aim to make your program compliant with the standard. This means initializing all variables before you use them.

Regards,

David
0 Kudos
hkausl
Beginner
773 Views
Ok, I'll fix my code. But is there a compiler option to find such unset variablesto make it easier for me?
0 Kudos
Les_Neilson
Valued Contributor II
773 Views

Under project properties Fortran -> Run-time -> Runtime Error Checking
you can check for uninitialized variables
I would advise you to also check array and string bounds

All of my Debug configurations have check "all" andsome of my Release configurationshave check for uninitialized variables and bounds checking (plus traceback) so that in the event of a user encountering a problem a screen shot will hopefully show us where and what.

Les
0 Kudos
mecej4
Honored Contributor III
773 Views
Use /CU /traceback. There is another options which seems to be intended to do similar checks (/Qtrapuv ) but does nothing in the current 12.1 compiler.

The options /RTCu /traceback seems to function similarly.

The trapping of undefined variables is probably unavailable or incomplete for user-defined variable types and arrays.


0 Kudos
hkausl
Beginner
773 Views
Thanks to all, I'll change my sources. But a last question. What does the option /Qzero. In my opinion it sets undefined variables to zero.
0 Kudos
DavidWhite
Valued Contributor II
773 Views
The helpfile gives this information:

zero, Qzero

Initializes to zero all local scalar variables of intrinsic type INTEGER, REAL, COMPLEX, or LOGICAL that are saved but not yet initialized.

Use -save (Linux and Mac OS X) or /Qsave (Windows) on the command line to make all local variables specifically marked as SAVE.

So these options only work for scalars (i.e not arrays), and the variable need to be saved, which I think you said you did not want to do.

No other choices it would appear.

Regards,

David

0 Kudos
Steven_L_Intel1
Employee
773 Views
My advice would be to correct your program rather than relying on "Band-Aid" fixes such as /Qzero.
0 Kudos
Reply