00001 subroutine interpo_3D_initial_4th(fnc,char_co)
00002 use phys_constant, only : long, pi, nnrg, nntg, nnpg
00003 use grid_parameter, only : nrf, nrg, ntg, npg
00004 use coordinate_grav_r, only : rg
00005 use coordinate_grav_theta, only : thg
00006 use coordinate_grav_phi, only : phig
00007 use grid_temporary, only : nrftmp, nrgtmp, ntgtmp, npgtmp, &
00008 & rgtmp, thgtmp, phigtmp
00009 use make_array_3d
00010 implicit none
00011 real(long), pointer :: fnc(:,:,:)
00012 real(long), pointer :: fnctmp(:,:,:)
00013 real(long) :: rc, thc, phic
00014 real(long) :: r4(4), th4(4), phi4(4), fr4(4), ft4(4), fp4(4)
00015 integer :: irg, itg, ipg, ir, it, ip
00016 integer :: ir0, it0, ip0, irg0 , itg0 , ipg0, ii, jj, kk
00017 integer :: nrfnrg, nrfnrgtmp
00018 real(long), external :: lagint_4th
00019 character(len=4) :: char_co
00020
00021
00022
00023
00024 call alloc_array3d(fnctmp,0,nrgtmp,0,ntgtmp,0,npgtmp)
00025
00026 fnctmp(0:nrgtmp,0:ntgtmp,0:npgtmp) = 0.0d0
00027 fnctmp(0:nrgtmp,0:ntgtmp,0:npgtmp) = fnc(0:nrgtmp,0:ntgtmp,0:npgtmp)
00028
00029 if (char_co.eq.'sfco') then
00030 nrfnrg = nrf
00031 nrfnrgtmp = nrftmp
00032 else if (char_co.eq.'grco') then
00033 nrfnrg = nrg
00034 nrfnrgtmp = nrgtmp
00035 end if
00036
00037 do ipg = 0, npg
00038 phic = phig(ipg)
00039 do ip = 0, npgtmp
00040 if (phic.le.phigtmp(ip)) then
00041 ip0 = min0(max0(0,ip-2),npgtmp-3)
00042 exit
00043 end if
00044 end do
00045 do itg = 0, ntg
00046 thc = thg(itg)
00047 do it = 0, ntgtmp
00048 if (thc.le.thgtmp(it)) then
00049 it0 = min0(max0(0,it-2),ntgtmp-3)
00050 exit
00051 end if
00052 end do
00053 do irg = 0, nrfnrg
00054 rc = rg(irg)
00055 do ir = 0, nrgtmp
00056 if (rc.le.rgtmp(ir)) then
00057 ir0 = min0(max0(0,ir-2),nrfnrgtmp-3)
00058 exit
00059 end if
00060 end do
00061
00062 do ii = 1, 4
00063 irg0 = ir0 + ii - 1
00064 itg0 = it0 + ii - 1
00065 ipg0 = ip0 + ii - 1
00066 r4(ii) = rgtmp(irg0)
00067 th4(ii) = thgtmp(itg0)
00068 phi4(ii) = phigtmp(ipg0)
00069 end do
00070
00071 do kk = 1, 4
00072 ipg0 = ip0 + kk - 1
00073 do jj = 1, 4
00074 itg0 = it0 + jj - 1
00075 do ii = 1, 4
00076 irg0 = ir0 + ii - 1
00077 fr4(ii) = fnctmp(irg0,itg0,ipg0)
00078 end do
00079 ft4(jj) = lagint_4th(r4,fr4,rc)
00080 end do
00081 fp4(kk) = lagint_4th(th4,ft4,thc)
00082 end do
00083 fnc(irg,itg,ipg) = lagint_4th(phi4,fp4,phic)
00084
00085 end do
00086 end do
00087 end do
00088
00089 deallocate(fnctmp)
00090
00091 end subroutine interpo_3D_initial_4th