title: Compiler won't calculate variable unless I print it""
body: <p>So apparently, depending in wether i tell the program to print the variable i, or not, I get different results that should not have anything to do with wether i print it our or not.</p>
  
  <pre><code> PROGRAM hello
  IMPLICIT NONE
  integer :: n,i, mini
  logical :: leave = .false.
  read*, n
  print*, is_prime(n)   
  
  !!---------------------------------------------------------------------
  
  do i=n, n/2, -1
      print*, "I= ", i                !!if you comment out this line, the result will be different than if you were to keep it, try it out yourselves
      if(is_prime(i)) then
          mini = i
      end if
  end do
  
  print*, "the lowest prime number between your number and its half is: ", mini
  
  !!----------------------------------------------------------
  
  CONTAINS
  
  logical function is_prime(n)
      integer::n,i
  
      do i=2,n
          if(mod(n,i) == 0 .and. (i/=1 .and. i/=n) ) then
              is_prime = .false.
          elseif(mod(n,i) /=0 .and. i == n-1 .and. is_prime .neqv. .false.) then
              is_prime = .true.
          end if
      end do
      return
  end function
  END PROGRAM
  </code></pre>
  
  <p>So if you were to comment out the line I pointed out, the result of "mini" will be different than if you were to keep it, as I said.
  I'm fairly new at fortran so I don't know wether I'm doing something wrong, or if this has something to do with the compiler, but it seems really weird to me that putting a print*, line would in any way change the value of the variabe, and that's what seems to happen.</p>
  
  <p>For example if you try it yourselve, the output of mini when the print line is in, is for exaple,, typing in 48, is 29, which is right, it's the minimum prime number between 48 and ts half, but when you tipe in 48 and the famous print line is commented out, the output will be -2, instead of 29.
  Any of you know why this happenes? </p>