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

INT gives me incorrect value

$
0
0

Hello

I have this code:

program th
  implicit none

  integer N1
  integer maxi,ei,Nc,ns,na
  real CH1,CH2



  OPEN(unit=1,file='input_file',status="old")
  read(1,*) ns                      !!!
  read(1,*) ei                         !!!!!!!!!!!!!!!
  read(1,*) maxi!!!!!!!!!!!!!!!!!!!
  read(1,*) N1!!!!!!!!!!!!!!!!
  close(unit=1)


  CH1 = 0.07
  CH2 = -0.35


  Na = INT(abs(2.*((N1/2)*CH1 + (N1/2)*CH2)))
  write(*,*) Na,abs(2.*((real(N1)/2.)*CH1 + (real(N1)/2.)*CH2));stop
end program  th

and the input file is

1                      !!!!!!!!!!!
1                          !!!!!!!!!!
1                   !!!
1600

Then I compile it with

ifort -O3 -autodouble t1.f90 -o out

but when I execute it I get 447 for na which is not correct. The correct answer is 448

Could you please tell me what is happening? and how I can fix it?

Thanks alot


Viewing all articles
Browse latest Browse all 3270