Quantcast
Channel: Intel® Fortran Compiler
Viewing all articles
Browse latest Browse all 3270

ifort real*4 count bug

$
0
0
Recently, I wrote a piece of codes, like that below. The value of num is larger than the range of integer 32.
The result of the tmp should be 2. But in that code, the program gave 0. No matter if use ifort 13.0.0 or 15.0.0. If I change the tmp from real*4 to real*8, the result is correct. Ang idea?


integer*8,parameter :: num = 2500000000
integer*8 :: i
real*4,dimension(:),allocatable :: a
real*4 :: tmp

allocate(a(num))
a = 0.0e0

do i = 1, num
   if(i.eq.1) then
      a(1) = 1.0e0
   else if(mod(i, 2).eq.0) then
      a(i) = 1.0e0
   else
      a(i) = -1.0e0
   end if
end do


tmp = 0.0e0
do i = 1, num
   tmp = tmp + a(i)
end do

print*, tmp

end

 


Viewing all articles
Browse latest Browse all 3270

Trending Articles