title: Store value, check it up against new value for every iteration count
body: <p>I have a program that computes a new value (L2norm) for every new iteration count i. I want to check this value at iteration i against the value at iteration (i+1). And see if the difference is less then some  spesific value. How can I store the this value at iteration i (L2old) and check it up against L2norm at i+1 (L2norm)</p>
  
  <p>If I set L2old=L2norm I just get zero every time. I want a nonzero value. </p>
  
  <p>Part of my program:</p>
  
  <pre><code>module hei
  
  use sub_solver
  
  implicit none
  contains
  
  subroutine heis(f,T,n)
  
  integer, intent(in) :: n
  double precision, intent(in) :: f
  double precision, dimension(:,:), allocatable :: T
  double precision pi,re,L2norm
  integer i
  pi=3.14159265359
  
  do i=1,50
  
  
  
  call BC(n,T)
  
  call gauss_seidel(n,T)
  
  call L2normsolver(n,T,L2norm)
  
  if (abs(L2old-L2norm) .LE. 0.0000001) then
  
      exit
  
  end if
  
  L2old=L2norm
  
  end do
  
  write(*,*)'iteration count',i
  
  end subroutine heis
  end module hei
  
  
  subroutine L2normsolver(n,T,L2norm)
  
  integer, intent(in) :: n
  double precision, dimension(:,:), allocatable :: T
  integer i,j
  double precision errorsum,L2norm,pi,h,x,y
  
  pi=3.14159265359
  h=1/n
  errorsum=0
  
  !Sums up all the errors
  
  do i=2,n+1
    do j=2,n+1
  
     x=(j-1.5)*1/n
     y=(i-1.5)*1/n
  
     errorsum=errorsum+(T(i,j)-(cos(pi*x)*sinh(pi*y))/sinh(pi))**2
  
     end do
  end do
  
  !L2 norm
  L2norm=sqrt(errorsum/(n**2))
  
  
  end subroutine L2normsolver
  </code></pre>