00001 subroutine interpo_fl2gr_midpoint(flv,grv)
00002 use phys_constant, only : long
00003 use grid_parameter, only : nrg, ntg, npg, nrf, ntf, npf
00004 use coordinate_grav_r, only : rg, hrg
00005 use coordinate_grav_theta, only : hthg
00006 use coordinate_grav_phi, only : hphig
00007 use coordinate_grav_extended
00008 use def_matter, only : rs
00009 use interface_interpo_linear_type0_2Dsurf
00010 implicit none
00011 real(long), external :: lagint_4th, lagint_2nd
00012 real(long), pointer :: grv(:,:,:), flv(:,:,:)
00013 real(long) :: r4(4), th4(4), phi4(4), fr4(4), ft4(4), fp4(4)
00014 real(long) :: r2(2), fr2(2)
00015 real(long) :: rrff, rrgg, small = 1.0d-14
00016 real(long) :: rc, thc, phic
00017 integer :: irg, itg, ipg, irgex, itgex, ipgex
00018 integer :: ir0, it0, ip0, irg0 , itg0 , ipg0, ii, jj, kk
00019 integer :: irf, irf0
00020
00021 grv(0:nrg,0:ntg,0:npg) = 0.0d0
00022
00023 do ipg = 1, npg
00024 ip0 = ipg-2
00025 do itg = 1, ntg
00026 it0 = itg-2
00027 call interpo_linear_type0_2Dsurf(rrff,rs,itg,ipg)
00028 do irg = 1, nrg
00029 rc = hrg(irg)/rrff
00030 thc = hthg(itg)
00031 phic = hphig(ipg)
00032
00033 if (hrg(irg).gt.rrff*rg(nrf)) exit
00034
00035 do irf = 0, nrf
00036 if (hrg(irg).le.rrff*rg(irf)) then
00037 irf0= irf-1
00038 ir0 = min0(irf-2,nrf-3)
00039 exit
00040 end if
00041 end do
00042
00043 if (irf0.eq.nrf-1) then
00044
00045 r2(1:2) = rgex(irf0:irf0+1)
00046 th4(1:4) = thgex(it0:it0+3)
00047 phi4(1:4) = phigex(ip0:ip0+3)
00048
00049 do kk = 1, 4
00050 ipg0 = ip0 + kk - 1
00051 do jj = 1, 4
00052 itg0 = it0 + jj - 1
00053 do ii = 1, 2
00054 irg0 = irf0 + ii - 1
00055 irgex = irgex_r(irg0)
00056 itgex = itgex_r(itgex_th(itg0),irg0)
00057 ipgex = ipgex_r(ipgex_th(ipgex_phi(ipg0),itg0),irg0)
00058 fr2(ii) = flv(irgex,itgex,ipgex)
00059 end do
00060 ft4(jj) = lagint_2nd(r2,fr2,rc)
00061 end do
00062 fp4(kk) = lagint_4th(th4,ft4,thc)
00063 end do
00064 grv(irg,itg,ipg) = lagint_4th(phi4,fp4,phic)
00065
00066 else
00067
00068 r4(1:4) = rgex(ir0:ir0+3)
00069 th4(1:4) = thgex(it0:it0+3)
00070 phi4(1:4) = phigex(ip0:ip0+3)
00071
00072 do kk = 1, 4
00073 ipg0 = ip0 + kk - 1
00074 do jj = 1, 4
00075 itg0 = it0 + jj - 1
00076 do ii = 1, 4
00077 irg0 = ir0 + ii - 1
00078 irgex = irgex_r(irg0)
00079 itgex = itgex_r(itgex_th(itg0),irg0)
00080 ipgex = ipgex_r(ipgex_th(ipgex_phi(ipg0),itg0),irg0)
00081 fr4(ii) = flv(irgex,itgex,ipgex)
00082 end do
00083 ft4(jj) = lagint_4th(r4,fr4,rc)
00084 end do
00085 fp4(kk) = lagint_4th(th4,ft4,thc)
00086 end do
00087 grv(irg,itg,ipg) = lagint_4th(phi4,fp4,phic)
00088 end if
00089
00090 end do
00091 end do
00092 end do
00093
00094 end subroutine interpo_fl2gr_midpoint