00001 subroutine compute_shift(potx, poty, potz, gvec, bfnc)
00002 use phys_constant, only : long
00003 use grid_parameter, only : nrg, ntg, npg
00004 use trigonometry_grav_theta, only : sinthg, costhg
00005 use trigonometry_grav_phi, only : sinphig, cosphig
00006 use coordinate_grav_r, only : rg
00007 use def_vector_x, only : vec_xg
00008 use make_array_3d
00009 use interface_grgrad_4th_gridpoint
00010 implicit none
00011 real(long), pointer :: potx(:,:,:), poty(:,:,:), potz(:,:,:)
00012 real(long), pointer :: bfnc(:,:,:), gvec(:,:,:,:)
00013 real(long), pointer :: xdotg(:,:,:), bminusxdotg(:,:,:)
00014 real(long) :: gradx, grady, gradz
00015 real(long) :: xxx, yyy, zzz
00016 integer :: irg, itg, ipg
00017
00018 call alloc_array3d(xdotg,0,nrg,0,ntg,0,npg)
00019 call alloc_array3d(bminusxdotg,0,nrg,0,ntg,0,npg)
00020
00021 do ipg = 0, npg
00022 do itg = 0, ntg
00023 do irg = 0, nrg
00024 xxx = vec_xg(irg,itg,ipg,1)
00025 yyy = vec_xg(irg,itg,ipg,2)
00026 zzz = vec_xg(irg,itg,ipg,3)
00027 xdotg(irg,itg,ipg) = xxx*gvec(irg,itg,ipg,1) &
00028 & + yyy*gvec(irg,itg,ipg,2) &
00029 & + zzz*gvec(irg,itg,ipg,3)
00030 bminusxdotg(irg,itg,ipg) = bfnc(irg,itg,ipg) - xdotg(irg,itg,ipg)
00031 end do
00032 end do
00033 end do
00034
00035 do ipg = 0, npg
00036 do itg = 0, ntg
00037 do irg = 0, nrg
00038 call grgrad_4th_gridpoint(bminusxdotg,gradx,grady,gradz,irg,itg,ipg)
00039 potx(irg,itg,ipg) = gvec(irg,itg,ipg,1) + 0.125d0*gradx
00040 poty(irg,itg,ipg) = gvec(irg,itg,ipg,2) + 0.125d0*grady
00041 potz(irg,itg,ipg) = gvec(irg,itg,ipg,3) + 0.125d0*gradz
00042 end do
00043 end do
00044 end do
00045
00046 deallocate(xdotg)
00047 deallocate(bminusxdotg)
00048
00049 end subroutine compute_shift