00001 subroutine correct_MW_source_C0At(sou,intp)
00002   use phys_constant, only : long, pi
00003   use grid_parameter, only : nrg, ntg, npg
00004   use coordinate_grav_r, only : hrg
00005   use def_matter, only : rs
00006   use interface_interpo_linear_type0_2Dsurf
00007   implicit none
00008   real(long), pointer :: sou(:,:,:)
00009   real(long) :: hsurf
00010   integer    :: irg, itg, ipg, irg_surf, intp, ipo
00011   real(long), external :: lagint_2nd
00012   real(long) :: x(2),y(2), v
00013 
00014 
00015 
00016 
00017   do ipg = 1, npg
00018     do itg = 1, ntg
00019       call interpo_linear_type0_2Dsurf(hsurf,rs,itg,ipg)
00020       do irg = 1, nrg
00021         if (hsurf < hrg(irg)) then 
00022           irg_surf = irg
00023           exit
00024         end if
00025       end do
00026 
00027       do ipo = 1, intp
00028         irg = irg_surf
00029 
00030         x(1) = hrg(irg-intp-1)
00031         x(2) = hrg(irg-intp-2)
00032         y(1) = sou(irg-intp-1,itg,ipg)
00033         y(2) = sou(irg-intp-2,itg,ipg)
00034         v    = hrg(irg-ipo)
00035         sou(irg-ipo,itg,ipg) = lagint_2nd(x,y,v)
00036 
00037         x(1) = hrg(irg+intp+0)
00038         x(2) = hrg(irg+intp+1)
00039         y(1) = sou(irg+intp+0,itg,ipg)
00040         y(2) = sou(irg+intp+1,itg,ipg)
00041         v    = hrg(irg+ipo -1)
00042         sou(irg+ipo-1,itg,ipg) = lagint_2nd(x,y,v)
00043 
00044       end do
00045 
00046     end do
00047   end do
00048 
00049 end subroutine correct_MW_source_C0At