     	SUBROUTINE IFLINE( ISY, SIZ, ISH, NPT, X, Y )
C
C  PROGRAMMER: RONG-SHENG ZHOU
C	       ALFRED UNIVERSITY	JULY-1985
C
C	THIS ROUTINE IMPLEMENTS A COMPREHENSIVE POLYLINE FUNCTION.
C
C       ISY --- AN INTEGER DESIGNATING THE SYMBOL TO BE USED.
C		IF ISY<0, NO LINE CONNECTIONS BUT SYMBOLS.
C
C	SIZ --- SIZE OF SYMBOLS IF AT ALL.
C
C	ISH --- PLOTTING MODE:
C		ISH = 0: NORMAL LINE &/ SYMBOL PLOT.
C		ISH = 1: AREA-FILL TO THE HORIZONTAL REFERENCE LINE.
C			 FILL-PATTERN = ISY
C		ISH =-1: AREA-FILL FROM THE 1ST POINT TO THE LAST POINT.
C			 FILL-PATTERN = ISY AND SYMBOLS ARE SKIPPED.
C		ISH = 2: STICK PLOT IN ADDITION.
C		ISH = 3: BAR PLOT IN ADDITION:
C			 BAR-WIDTH=SIZ; BAR-PATTERN=ISY; SYMBOLS ARE SKIPPED.
C
C       NPT --- NUMBER OF VERTICES IN THE ARRAY.
C		IF NPT<0, A SPLINE-CURVE IS GENERATED.
C
C       X,Y --- ARRAY OF SCALED ORDINATE AND ABCISSA VALUES.
C	X(NPT+1),Y(NPT+1) --- MINIMUM SCALED VALUES IN THE SET.
C	X(NPT+2),Y(NPT+2) --- INCREMENTAL VALUES PER INCH.
C	Y(NPT+3) ------------ HORIZONTAL REFERENCE LINE FOR STICK/BAR/AREA-FILL
C
	DIMENSION X(1), Y(1)
C
C  QUIT ON CTRL_C...
C
     	IF( IFCTRL_C() ) RETURN
C
C  INITIALIZE...
C
     	LSY  = ISY
    	ISYM = IABS(LSY)
    	SIZE = ABS(SIZ)
    	IF( SIZE.EQ.0.0 ) SIZE = 0.05
    	ISHD = IABS(ISH)
     	NNN  = NPT
    	NN   = IABS(NNN)
    	XMIN = X(NN+1)
    	YMIN = Y(NN+1)
    	DX   = X(NN+2)
    	DY   = Y(NN+2)
     	RL   = (Y(NN+3)-YMIN)/DY
    	NF   = 1
    	X0   = (X(NF)-XMIN)/DX
    	Y0   = (Y(NF)-YMIN)/DY
     	XO   = X0
     	YO   = Y0
C
C  TAKE CARE OF THE FIRST VERTEX...
C
     	IF( ISHD.EQ.0 .OR. ISHD.EQ.2 ) THEN
    	    IF( ISYM.EQ.0 ) THEN
     		CALL IFPLOT( X0, Y0, 3 )
     	    ELSE
     		CALL IFMARK( X0, Y0, SIZE, 0.0, ISYM )
     	    ENDIF
    	    IF( ISHD.EQ.2 ) THEN
     		CALL IFPLOT( X0, RL, 2 )
     		CALL IFPLOT( X0, Y0, 3 )
     	    ENDIF
     	ENDIF
     	IF( ISHD.EQ.3 ) THEN
     	    JFP = ISYM
     	    IF( JFP.GT.0 ) CALL IFFILL( JFP )
    	    CALL IFBARS( X0,0.5*(Y0+RL),SIZE,Y0-RL,0.0,0.0 )
     	    IF( JFP.GT.0 ) CALL IFFILL( 0 )
    	    CALL IFPLOT( X0, Y0, 3 )
     	    ISYM = 0
    	ENDIF
     	IF( ISHD.EQ.1 ) THEN
     	    JFP = LSY
     	    IF( JFP.EQ.0 ) JFP = 1
     	    CALL IFFILL( JFP )
     	    IF( ISH.LT.0 ) THEN
     		CALL IFPLOT( X0, Y0, 3 )
     	    ELSE
     		CALL IFPLOT( X0, RL, 3 )
     		CALL IFPLOT( X0, Y0, 2 )
     	    ENDIF
     	    LSY = 0
     	    ISYM= 0
     	ENDIF

    	NF = NF+1
	IF( NNN.GT.0 ) GOTO 9
    	NLP= NN-1
    	NFP= NF-1
    	U  = (X(NF)-X(NFP))/DX
    	V  = (Y(NF)-Y(NFP))/DY
    	U1 = (X(NN)-X(NLP))/DX
    	V1 = (Y(NN)-Y(NLP))/DY
    	SU = U
    	SV = V
    	IF (X(NFP)-X(NN)) 8,7,8
  7	IF (Y(NFP)-Y(NN)) 8,9,8
  8	NFP= NLP-1
    	SU = (X(NLP)-X(NFP))/DX
    	SV = (Y(NLP)-Y(NFP))/DY
    	CALL IFLINE_REFLX(U1,V1,SU,SV)
    	NFP= NF+1
    	U1 = (X(NFP)-X(NF))/DX
    	V1 = (Y(NFP)-Y(NF))/DY
    	CALL IFLINE_REFLX(U,V,U1,V1)
C
C  TAKE CARE OF THE REST OF VERTICES...
C
  9    	XA = 0.0
     	YA = 0.0
     	DIST = 0.0
     	DO I=1, NN-1

     	   IF( IFCTRL_C() ) RETURN
    	   XN = (X(NF)-XMIN)/DX
    	   YN = (Y(NF)-YMIN)/DY
     	   IF( LSY.LT.0 ) GOTO 10

     	   IF( ISYM.GT.0 ) THEN
     	       DIST = SQRT( (XN-X0)**2 + (YN-Y0)**2 )
     	       IF( DIST.LT.SIZE+0.01 ) GOTO 10
     	       DIST = 0.5*SIZE/(DIST-0.5*SIZE)
     	       XA = (X0+DIST*XN)/(1.0+DIST)
     	       YA = (Y0+DIST*YN)/(1.0+DIST)
     	       CALL IFPLOT( XA, YA, 3 )
     	       XA = XA - X0
     	       YA = YA - Y0
     	       DIST = 0.5*SIZE
     	   ENDIF

     	   IF( NNN.GT.0 ) THEN
     	       CALL IFPLOT( XN-XA, YN-YA, 2 )
     	   ELSE
     	       IF( I.LT.NN-1 ) THEN
     		   U2 = (X(NF+1)-XMIN)/DX - XN
     		   V2 = (Y(NF+1)-YMIN)/DY - YN
     	       ELSE
     		   U2 = SU
     		   V2 = SV
     	       ENDIF
     	       CALL IFLINE_FIT4( X0,Y0,XN,YN,U1,V1,U2,V2,DIST )
    	       U1 = U
    	       V1 = V
    	       U  = U2
    	       V  = V2
     	   ENDIF

  10	   IF( ISYM.GT.0 ) CALL IFMARK( XN, YN, SIZE, 0.0, ISYM )
  	   IF( ISHD.EQ.2 ) THEN
     	       CALL IFPLOT( XN, RL, 2 )
     	       CALL IFPLOT( XN, YN, 3 )
     	   ENDIF
    	   IF( ISHD.EQ.3 ) THEN
     	       IF( JFP.GT.0 ) CALL IFFILL( JFP )
    	       CALL IFBARS( XN,0.5*(YN+RL),SIZE,YN-RL,0.,0.0 )
     	       IF( JFP.GT.0 ) CALL IFFILL(  0  )
    	       CALL IFPLOT( XN, YN, 3 )
    	   ENDIF
    	   X0 = XN
    	   Y0 = YN
     	   NF = NF+1
     	ENDDO

999	IF( ISHD.EQ.1 ) THEN
     	    IF( ISH.GT.0 ) THEN
     		CALL IFPLOT( XN, RL, 2 )
     		CALL IFPLOT( XO, RL, 2 )
     	    ELSE
     		CALL IFPLOT( XO, YO, 2 )
     	    ENDIF
     	    CALL IFFILL( 0 )
     	ENDIF
     	RETURN
	END

     	SUBROUTINE IFLINE_FIT4(PX1,PY1,PX2,PY2,VECX1,VECY1,
     1                         VECX3,VECY3,SIZ)
     	WW=SIZ
	X1=PX1
	Y1=PY1
     	X2=PX2
     	Y2=PY2
    	VX3=PX2-X1
	VY3=PY2-Y1
	VX2=VECX1
	VY2=VECY1
	D2=VX2*VX2+VY2*VY2
	T=1.
	GO TO 7

6	T=0.
	VX2=VX3
	VY2=VY3
	VX3=VECX3
	VY3=VECY3
	D2=D3
	UX1=UX2
	UY1=UY2

7	D3=VX3*VX3+VY3*VY3
	UX2=D2*VX3+D3*VX2
	UY2=D2*VY3+D3*VY2
	DV=1.0/SQRT (UX2*UX2+UY2*UY2)
	UX2=DV*UX2
	UY2=DV*UY2
	IF(T)6,8,6

8	D=ABS(UX1*VX2+UY1*VY2)
	D1=D
	UUX1=D*UX1
	UUY1=D*UY1
	D=ABS(UX2*VX2+UY2*VY2)
	UUX2=D*UX2
	UUY2=D*UY2
	D=D+D1
	AX=UUX2+UUX1-VX2-VX2
	BX=VX2-UUX1-AX
	AY=UUY2+UUY1-VY2-VY2
	BY=VY2-UUY1-AY
	N=10.*D+1.
	D=1.0/FLOAT(N)

     	IBYP = 0

	DO 9 I=1, N

	T = T+D
	X = ((AX*T+BX)*T+UUX1)*T+X1
	Y = ((AY*T+BY)*T+UUY1)*T+Y1
     	IF( WW.EQ.0.0 ) GOTO 99
C
C  BYPASSING SYMBOLS...
C
     	DIST = SQRT( (X-X1)**2 + (Y-Y1)**2 )
     	IF( DIST.LT.WW ) GOTO 9
     	IF( IBYP.EQ.0 ) THEN
     	    IBYP = 1
     	    IF( DIST.GT.WW+0.01 ) THEN
     	    	DIST = WW/(DIST-WW)
     	    	X = (X1+DIST*X)/(1.0+DIST)
     	    	Y = (Y1+DIST*Y)/(1.0+DIST)
     		CALL IFPLOT( X,Y,3 )
     	    ENDIF
     	ENDIF
     	DIST = SQRT( (X-X2)**2 + (Y-Y2)**2 )
     	IF( DIST.GT.WW ) GOTO 99
     	IBYP = 2
     	IF( DIST.LT.WW-0.005 ) THEN
     	    DIST = SQRT( (XA-X2)**2 + (YA-Y2)**2 )
     	    DIST = WW/(DIST-WW)
     	    X = (X2+DIST*XA)/(1.0+DIST)
     	    Y = (Y2+DIST*YA)/(1.0+DIST)
     	ENDIF

99	CALL IFPLOT( X,Y,2 )
     	IF( IBYP.EQ.2 ) GOTO 999
     	XA = X
     	YA = Y

9	CONTINUE

999	RETURN
	END

     	SUBROUTINE IFLINE_REFLX(VX1,VY1,VX2,VY2)

	PS=VY1*VY1
	DS=VX1*VX1
	SS=DS+PS
    	IF( SS.EQ.0.0 ) RETURN
	DS=DS-PS
	PS=2.0*VX1*VY1
	TEMP=(PS*VY2+VX2*DS)/SS
	VY2=(PS*VX2-VY2*DS)/SS
	VX2=TEMP

	RETURN
	END

