subroutine error(problem,f,mmax,nmax,m,N,a,b,c,d,c0,emax,el2,erel) implicit none external u integer N,problem,mmax,nmax,m double precision a,b,c,d,emax,el2,erel,c0,f(mmax+2,nmax+2) double precision sum1,e1,sum2,e2,x,y,v,w,u integer i,j sum1 = 0 sum2 = 0 emax = 0 C We do not use the boundary do i = 2,m do j = 2,n x = a + (i-1)*(b-a)/(m+1) y = c + (j-1)*(d-c)/(n+1) v = a + (i-1+1)*(b-a)/(m+1) w = c + (j-1+1)*(d-c)/(n+1) if(i .lt. m .and. j .lt. n) then e1 = ((u(problem,x,y,c0)-f(i,j)+u(problem,x,w,c0)-f(i+1,j $ )+u(problem,v,y,c0)-f(i+1,j+1)+u(problem,v,w,c0)-f(i $ ,j+1))/4)**2*(b-a)*(d-c)/((m-1)*(n-1)) e2 = ((u(problem,x,y,c0)+u(problem,x,w,c0)+u(problem,v,y, $ c0)+u(problem,v,w,c0))/4)**2*(b-a)*(d-c)/((m-1)*(n-1)) sum1 = sum1 + e1 sum2 = sum2 + e2 end if if(abs(u(problem,x,y,c0)-f(i,j)) .gt. emax) then emax = abs(u(problem,x,y,c0)-f(i,j)) end if end do end do el2 = sqrt(sum1) erel = sqrt(sum1/sum2) return end