00001 subroutine interpo_gr2gr_4th(fnc,cfn,rc,thc,phic)
00002 use phys_constant, only : long, pi
00003 use grid_parameter, only : nrg, ntg, npg
00004 use coordinate_grav_extended
00005 implicit none
00006 real(long), pointer :: fnc(:,:,:)
00007 real(long), intent(out) :: cfn
00008 real(long) :: rc, thc, phic
00009 real(long) :: r4(4), th4(4), phi4(4), fr4(4), ft4(4), fp4(4)
00010 integer :: irg, itg, ipg, irgex, itgex, ipgex
00011 integer :: ir0, it0, ip0, irg0 , itg0 , ipg0, ii, jj, kk
00012 real(long), external :: lagint_4th
00013
00014
00015
00016
00017 cfn = 0.0d0
00018
00019 do irg = 0, nrg+1
00020 if (rc.lt.rgex(irg).and.rc.ge.rgex(irg-1)) ir0 = min0(irg-2,nrg-3)
00021 end do
00022 do itg = 0, ntg+1
00023 if (thc.lt.thgex(itg).and.thc.ge.thgex(itg-1)) it0 = itg-2
00024 end do
00025 do ipg = 0, npg+1
00026 if (phic.lt.phigex(ipg).and.phic.ge.phigex(ipg-1)) ip0 = ipg-2
00027 end do
00028
00029 do ii = 1, 4
00030 irg0 = ir0 + ii - 1
00031 itg0 = it0 + ii - 1
00032 ipg0 = ip0 + ii - 1
00033 r4(ii) = rgex(irg0)
00034 th4(ii) = thgex(itg0)
00035 phi4(ii) = phigex(ipg0)
00036 end do
00037
00038 do kk = 1, 4
00039 ipg0 = ip0 + kk - 1
00040 do jj = 1, 4
00041 itg0 = it0 + jj - 1
00042 do ii = 1, 4
00043 irg0 = ir0 + ii - 1
00044 irgex = irgex_r(irg0)
00045 itgex = itgex_r(itgex_th(itg0),irg0)
00046 ipgex = ipgex_r(ipgex_th(ipgex_phi(ipg0),itg0),irg0)
00047 fr4(ii) = fnc(irgex,itgex,ipgex)
00048 end do
00049 ft4(jj) = lagint_4th(r4,fr4,rc)
00050 end do
00051 fp4(kk) = lagint_4th(th4,ft4,thc)
00052 end do
00053 cfn = lagint_4th(phi4,fp4,phic)
00054
00055 end subroutine interpo_gr2gr_4th