00001 subroutine error_matter(pot,pot_bak,error,flag)
00002   use phys_constant,  only : long
00003   use grid_parameter, only : nrf, ntf, npf, eps
00004   implicit none
00005   real(long), pointer :: pot(:,:,:), pot_bak(:,:,:)
00006   real(long), intent(out) :: error
00007   integer,    intent(out) :: flag
00008   real(long) :: error_pot = 0.0d0, small = 1.0d-14
00009   integer    :: irf, itf, ipf
00010 
00011   error = 0.0d0
00012   flag = 0
00013   do irf = 0, nrf-1
00014     do itf = 0, ntf
00015       do ipf = 0, npf
00016         error_pot = 2.0d0*dabs(pot(irf,itf,ipf) -     pot_bak(irf,itf,ipf)) &
00017       &                 /(dabs(pot(irf,itf,ipf))+dabs(pot_bak(irf,itf,ipf)) &
00018       &                 + small)
00019         if (error_pot > eps) flag = 1
00020         error = dmax1(error,error_pot)
00021       end do
00022     end do
00023   end do
00024 end subroutine error_matter