Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

int() function in Fortran 77

$
0
0

I have come across a problem when I use the int() function. I have an real array mEL and I want to convert some of its components to integers for comparison with real array COORDS. I have to use int() due to rounding errors in COORDS array, so ZERO is not quite zero is 3.D-77 or similar:

DO I = 1,nLines IF (int(mEL(I,1)).EQ.int(COORDS(1,1)) .AND. 1 int(mEL(I,2)).EQ.int(COORDS(2,1)) .AND. 2 int(mEL(I,3)).EQ.int(COORDS(3,1))) THEN .....do something

The problem is that during the run the outcome of int(COORDS(1,1)) changes but the value of COORDS(1,1) is the same. For example:

COORDS(1,1) = 1829.0000000

During 1000 runs I get int(COORDS(1,1))=1829. However, after some runs I get: int(COORDS(1,1))=1828! but COORDS(1,1)=1829!

Any ideas why this happens?

Even stranger is when I have

COORDS(1,1) = 1829.0000000 and COORDS(1,2) = 1829.0000000 and int(COORDS(1,1)) = 1828 and int(COORDS(1,2)) = 1829!!!

Viewing all articles
Browse latest Browse all 5691

Trending Articles