	PROGRAM Spline
C
C	ROUTINE TO TEST AND DEMONSTRATE SPLSUB.FOR (SPLPLT)
C
	DIMENSION IBUF(30),X(20),Y(20)
	INTEGER ANS
	CALL ERRSET(0)
1	type 5
5	FORMAT(' ',T10,'S P L I N E  P L O T  R O U T I N E',/,
     1	' NUMBER OF DATA POINTS [4-20]? ',$)
	READ(5,6)N
6	FORMAT(I)
	IF((N.GE.4).AND.(N.LE.20))GOTO 9
	type 7
7	FORMAT(' ** IMPROPER NUMBER OF DATA POINTS - RANGE 4-20 **')
	GOTO 1
9	type 10
10	FORMAT(' ENTER X AND Y DATA (X IN ASCENDING ORDER)::')
	I=1
	WRITE(5,14)I
	read (5,12)X(1),Y(1)
12	FORMAT(2F)
	YMIN=Y(1)
	YMAX=YMIN
	DO 20 I=2,N
	type 14,I
14	FORMAT(' data pair ',I2,':',$)
	read (5,12)X(I),Y(I)
	IF(Y(I) .GT. YMAX)YMAX=Y(I)
	IF(Y(I) .LT. YMIN)YMIN=Y(I)
	IF(I.EQ.1)GOTO 20
	IF(X(I).GT.X(I-1))GOTO 20
	type 15
15	FORMAT(' ** X DATA MUST BE IN ASCENDING ORDER **')
	GOTO 9
20	CONTINUE
21	type 22
22	FORMAT(///' WHAT WINDOW SIZE WOULD YOU LIKE FOR THE SPLINE
	1 FIT [4-20]? ',$)
	read(5,6)NUMB
	IF((NUMB.GE.4).AND.(NUMB.LE.20))GOTO 25
	type 23
23	FORMAT(' ** WINDOW SIZE MUST BE IN THE RANGE OF 4-20 **')
	GOTO 21
25	IF(NUMB.LE.N)GOTO 28
	type 27
27	FORMAT(' ** WINDOW EXCEED AMOUNT OF DATA ENTERED **')
	GOTO 21
28	type 29
29	FORMAT(' scaling data.......')
	XMIN=X(1)
	XMAX=X(N)
	XINC=(XMAX-XMIN)/512.
	CALL GRINIT(IBUF) !INITIALIZE BUFFER
	CALL SPLPLT(IBUF,N,X,Y,NUMB,0,YMINS,YMAXS,XINC,mode,0)
	IF(YMAXS .GT. YMAX)YMAX=YMAXS
	IF(YMINS .LT. YMIN)YMIN=YMINS
C
C
	CALL GRREGN(IBUF,0,3) !ASSIGN BOTH GRAPHS TO
	CALL GRREGN(IBUF,1,3) !THE SAME REGION
	CALL GRSCAL(IBUF,XMIN,XMAX,YMIN,YMAX,0) !SCALE GRAPH 0
	CALL GRSCAL(IBUF,XMIN,XMAX,YMIN,YMAX,1) !SCALE GRAPH 1
	CALL GRAPHS(IBUF,1+2+4+64+128,X,Y,N,0.0,0) !PLOT THE ACTUAL DATA
	CALL GRCLN(IBUF,1)	!CLEAR PLOT FOR GRAPH 1
C
C
	CALL SPLPLT(IBUF,N,X,Y,NUMB,1,YMINS,YMAXS,XINC,mode,1)
	CALL VTMCUR(24,1) !POSITION CURSOR
	CALL SLEEP(5)
	CALL VTCLR
200	CALL EXIT
	END
