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

Strange M6201 Math -sqrt Domain Error in Release Version

onkelhotte
Nouveau contributeur II
556 Visites

Hi there,
I have a strange problem with my project, Im using CVF6.6c, VS6, WinXP.

I get an M6201 Math -sqrt Domain Error, but this only appears in Release Mode. In Debug everything runs fine. So I tried certain things, and what I found out is very strange:

I use the subroutine (calcTorsion) where the M6201 Error comes fora few weeks, havent touched it since. The error appeared this morning when I changed a line in another subroutine that hasnt anything to do with calcTorsion.

Strangeness Nr.1: Changing that line and program runs fine.

So I looked in calcTorsion for x**0.5 and tested it

if (x.gt.0.)then
y=x**0.5
else
y=0.
end if

but M6201 was still there.

Next thing I tried was to find out where the program crashes. So I insertedthe line write(16,'(a,i2)') 'ix= ',ix after starting a do loop, where ix is the counter of that do loop where the torsions are calculated.

Strangeness Nr.2: Writing that damn ix in a file and program runs fine!

All variables are declared and initialised properly. Im using implicit none and no variable is used before its value is defined.

While writing these lines I changed the optimization settings. The error does not appear when using none or local optimizations. When I compile with global optimizatins, optimize for speed, full or maximum optimizations.


Thanks in advance,
Markus

0 Compliments
2 Réponses
onkelhotte
Nouveau contributeur II
556 Visites

I found a "solution"...

I changed in the optimization setting Math Library to Fast, before it was set to Check*.
Now it works fine. But the "solution" with writing something in a file is very strange.

Markus

0 Compliments
TimP
Contributeur émérite III
556 Visites
Not so strange, and similar to several situations discussed in past posts. Since all intermediate arithmetic in x87 code is promoted to double precision, optimization produces slightly different results. Inserting a write could prevent one of those optimizations. Such effects could occur even when you set /fltconsistency to prevent dangerous optimizations, and you didn't even mention whether you tried that.
0 Compliments
Répondre