interpo_gr2cgr_4th.f90

Go to the documentation of this file.
00001 subroutine interpo_gr2cgr_4th(fnc,cfn,xc,yc,zc)
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) ::  xc, yc, zc, rc, thc, phic, varpic
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 ! --- Interpolation from the central spherical grid 
00015 ! --- to a Cartesian grid point using 4th order Lagrange formula.
00016 !
00017   cfn = 0.0d0
00018 !
00019   rc     = dsqrt(dabs(xc**2 + yc**2 + zc**2))
00020   varpic = dsqrt(dabs(xc**2 + yc**2))
00021   thc  = dmod(2.0d0*pi + datan2(varpic,zc),2.0d0*pi)
00022   phic = dmod(2.0d0*pi + datan2(    yc,xc),2.0d0*pi)
00023 !
00024   do irg = 0, nrg+1
00025     if (rc.lt.rgex(irg).and.rc.ge.rgex(irg-1)) ir0 = min0(irg-2,nrg-3)
00026   end do
00027   do itg = 0, ntg+1
00028     if (thc.lt.thgex(itg).and.thc.ge.thgex(itg-1)) it0 = itg-2
00029   end do
00030   do ipg = 0, npg+1
00031     if (phic.lt.phigex(ipg).and.phic.ge.phigex(ipg-1)) ip0 = ipg-2
00032   end do
00033 !
00034   do ii = 1, 4
00035     irg0 = ir0 + ii - 1
00036     itg0 = it0 + ii - 1
00037     ipg0 = ip0 + ii - 1
00038     r4(ii) = rgex(irg0)
00039     th4(ii) = thgex(itg0)
00040     phi4(ii) = phigex(ipg0)
00041   end do
00042 !
00043 ! --  Center
00044 !  if (rc.eq.0.0d0) then
00045 !    cfn = fnc(0,0,0)
00046 !    return
00047 !  end if
00048 !
00049 ! --  general
00050 !
00051   do kk = 1, 4
00052     ipg0 = ip0 + kk - 1
00053     do jj = 1, 4
00054       itg0 = it0 + jj - 1
00055       do ii = 1, 4
00056         irg0 = ir0 + ii - 1
00057         irgex = irgex_r(irg0)
00058         itgex = itgex_r(itgex_th(itg0),irg0)
00059         ipgex = ipgex_r(ipgex_th(ipgex_phi(ipg0),itg0),irg0)
00060         fr4(ii) = fnc(irgex,itgex,ipgex)
00061       end do
00062       ft4(jj) = lagint_4th(r4,fr4,rc)
00063     end do
00064     fp4(kk) = lagint_4th(th4,ft4,thc)
00065   end do
00066   cfn = lagint_4th(phi4,fp4,phic)
00067 !
00068 end subroutine interpo_gr2cgr_4th

Generated on 27 Oct 2011 for Cocal by  doxygen 1.6.1