$NOFLOATCALLS
$STORAGE: 2
	SUBROUTINE LINFIT(ID1X,ID2X,IRCOL,ID1,ID2,N,A,B,DEL)
	REAL*8 A,B,XY,SX2,SX,SY
	REAL*8 XI,YI,SY2,EN,DEL,WRK
	INTEGER*2 N,ID1X,ID2X,IRCOL,ID1,ID2
	INTEGER*2 IC,IR,KK,KKK,I
C FIT LINE TO EQUALLY SPACED POINTS...
C Y=BX+A
	SY2=0.
	EN=N
	XY=0.
	SX2=0.
	SX=0.
	SY=0.
	IC=IRCOL
	IR=1-IRCOL
C IRCOL IS 0 OR 1 FOR ACROSS OR DOWN
	DO 10 I=1,N
C IF ID1X < 0 THEN FORM IT HERE AS ID1+I-1
	IF (ID1X.GT.0)GOTO 20
C FORM XI
	XI=ID1+I-1
	GOTO 30
20	CONTINUE
C INPUT XI
	KK=ID1X+IC*(I-1)
	KKK=ID2X+IR*(I-1)
	CALL XVBLGT(KK,KKK,XI)
30	CONTINUE
C GET YI IN ANY CASE...
	KK=ID1+IC*(I-1)
	KKK=ID2+IR*(I-1)
	CALL XVBLGT(KK,KKK,YI)
	XY=XY+XI*YI
C FORM SUMS NEEDED TO FIT LINE...
	SX2=SX2+XI*XI
	SX=SX+XI
	SY=SY+YI
	SY2=SY2+YI*YI
10	CONTINUE
C NOW GET SLOPE
	WRK=((XY-(SX*SY)/EN)/(SX2-(SX*SX)/EN))
	B=WRK
C THEN INTERCEPT
	WRK=(SY/EN)-B*(SX/EN)
	A=WRK
	WRK=DSQRT((SY2-(A*SY+B*XY))/EN)
	DEL=WRK
C DEL = ERROR
	RETURN
	END
