00001 subroutine error_velocity_potential(pot,pot_bak,error,flag)
00002 use phys_constant, only : long
00003 use grid_parameter, only : nrf, ntf, npf, eps, &
00004 & ntfpolp, ntfpolm, ntfeq, npfxzp, npfxzm
00005 use def_matter, only : rs
00006 use coordinate_grav_r, only : rg
00007 implicit none
00008 real(long), pointer :: pot(:,:,:), pot_bak(:,:,:)
00009 real(long), intent(out) :: error
00010 integer, intent(out) :: flag
00011 real(long) :: error_pot = 0.0d0, small = 1.0d-14
00012 integer :: irf, itf, ipf, ire, ite, ipe
00013
00014 error = 0.0d0
00015 flag = 0
00016 do irf = 0, nrf-1
00017 do itf = 0, ntf
00018 do ipf = 0, npf
00019 if ( dabs(pot(irf,itf,ipf)) < 1.0e-12 ) cycle
00020 if (itf.eq.ntfpolp .or. itf.eq.ntfpolm .or. itf.eq.ntfeq .or. &
00021 & ipf.eq.npfxzp .or. ipf.eq.npfxzm .or. ipf.eq.npf) cycle
00022
00023 error_pot = 2.0d0*dabs(pot(irf,itf,ipf) - pot_bak(irf,itf,ipf)) &
00024 & /(dabs(pot(irf,itf,ipf))+dabs(pot_bak(irf,itf,ipf)) &
00025 & + small)
00026 if (error_pot > eps) flag = 1
00027
00028 if(error_pot > error) then
00029 error = error_pot
00030 ire = irf
00031 ite = itf
00032 ipe = ipf
00033 end if
00034 end do
00035 end do
00036 end do
00037
00038 write(6,'(1a19,3i5,a10,1p,e14.6,a12,1p,e20.12,a8,1p,e14.6)') '-- max error grid =',ire,ite,ipe, &
00039 & " rf coor=", rg(ire)*rs(ite,ipe), " Potential=", pot(ire,ite,ipe), " Error=", error
00040
00041 end subroutine error_velocity_potential