      real*8 function CGrdPntD2(lon,lat,dt,row,col,hd)
!利用距离平方反比方法内插(lon,lat)处的函数值
!2005年4月20日,章传银
!-------------------------------------------------------------
      implicit none
	integer row,col,ii,jj,ki,kj,kn
	real*8::dt(row,col),hd(6),mdr
	real*8::qi,dm,rr,lat,lon,lat0,lon0,RAD,ae
!-------------------------------------------------------------
      RAD=datan(1.d0)/45.d0;ae=6378000
	ii=nint((lat-hd(3))/hd(6)+0.5d0)
	jj=nint((lon-hd(1))/hd(5)+0.5d0)
	qi=0.d0;dm=0.d0;CGrdPntD2=0.d0
      mdr=hd(5)*RAD*ae*1.d-3
	do ki=ii-9,ii+9
	  lat0=hd(3)+(real(ki)-0.5d0)*hd(6)
	  do kj=jj-9,jj+9
	    lon0=hd(1)+(real(kj)-0.5d0)*hd(5)
	    rr=((lon-lon0)*dcos(lat*RAD))**2+(lat-lat0)**2
	    rr=rr*ae**2+mdr**2
	    if(ki>0 .and. kj>0 .and. ki<=row .and. kj<=col)then
            if(dt(ki,kj)<9900.d0)then
	        qi=qi+1.d0/rr;dm=dm+dt(ki,kj)/rr
            endif
          endif
	  enddo
	enddo
	if(qi>1.d-16)CGrdPntD2=dm/qi
9100  continue
      end
