To be Improved

The program reported here below can be improved. How ?

program to_be_improved
! a ugly program that can be easily  reassembled improving performance
  ! hint: compute once the if within the loop

  integer :: i=1000,j=1000
  real    :: a(1000,1000)
  real*8  :: t1,t2
  real :: foo,bar

  foo=100.d0
  bar=100.d0

  call cpu_time(t1)
  DO I=1, 1000
     DO J=1, 1000
        IF(FOO .EQ. BAR) THEN
           A(I,J) = I + J
        ELSE
           A(I,J) = 0
        ENDIF
     ENDDO
  ENDDO
  call cpu_time(t2)

  print*,'wrong way=',t2-t1

end program to_be_improved

Post on your wiki page your solution and the gain in time. If you are too lazy to elaborate your own solution just check the one we propose and report at least the gain in time of our implementation.