      PARAMETER (maxd=361,maxc=313,maxmc=365)
	REAL ki(maxc),vi(maxd),ds(maxd,maxc)
	REAL dok(maxmc),dov(maxmc),dsmc(maxmc)
	CHARACTER*255 st
	PRINT '("Nhap kinh, vi cua cac diem cua mat cat:")'
      READ '(A)', st
	ndiem=0
	DO j=1,LEN(st)
        IF (st(j:j).EQ.',') THEN
	    ndiem=ndiem+1
          st(j:j)=' '
	  ENDIF
	ENDDO
	ndiem=(ndiem+1)/2
	READ(st,*) (dok(j),dov(j),j=1,ndiem)
	OPEN(1,FILE='hdata\huan\scsdata\scs5.dep')
	READ(1,*) d1,d2,v1,v2,delta !Mo file Etopo5.dep de doc cac do sau
	READ(1,*) nd,nc
	DO k=nd,1,-1
        READ(1,*) (ds(k,j),j=1,nc)
	ENDDO
      CLOSE(1) !Doc xong mang do sau cua Bien Dong
	delta=delta/60.0 !Chuyen delta tu phut thanh do thap phan
      ki(1)=d1 !Xac dinh vi tri kinh tuyen cua do sau DS
	DO j=2,nc
        ki(j)=ki(j-1)+delta
	ENDDO
	vi(1)=v1 !Xac dinh vi tri vi tuyen cua do sau DS
	DO j=2,nd
	  vi(j)=vi(j-1)+delta
	ENDDO
      DO k=1,ndiem   !Xac dinh do sau tai tung diem cua mat cat
	  DO i=1,nd-1 !Xac dinh 2 cot trai,phai bao quanh kinh do tung diem cua mat cat
	    DO j=1,nc-1
	      IF (dov(k).GE.vi(i).AND.dov(k).LE.vi(i+1).AND. 
     *          dok(k).GE.ki(j).AND.dok(k).LE.ki(j+1)) THEN
	        i1=i
	        i2=i+1
	        j1=j
	        j2=j+1
	        ul=ds(i2,j1)
	        dl=ds(i1,j1)
	        ur=ds(i2,j2)
	        dr=ds(i1,j2)
	        a=dl+(dr-dl)/delta*(dok(k)-ki(j1))
              b=ul+(ur-ul)/delta*(dok(k)-ki(j1))
              dsmc(k)=a+(b-a)/delta*(dov(k)-vi(i1))
	      ENDIF
	    ENDDO
	  ENDDO
	ENDDO
	OPEN(2,FILE='ketqua.bln',STATUS='UNKNOWN')
	vitri=0.0
	WRITE(2,*) ndiem
	WRITE(2,*) vitri,dsmc(1)
	DO j=2,ndiem
        vitri=vitri+SQRT((dok(j)-dok(j-1))**2+(dov(j)-dov(j-1))**2)
	  WRITE(2,'(F7.2,F10.2)') vitri,-dsmc(j)
	ENDDO
	CLOSE(2)
	END