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