	subroutine grf1
	common	/comdim/ncd(256)


C	vt100 graphic display NCD() on NLINES lines high NCHARScharct wide
C	 variables	H0% ,dimNCD()
C	 		E$,V1$,V2$ vt control
C	 		I% I1% fornext step
C	 		G1,G2,G0 min,max,scal
C	 		G,G%,G0%,G1%,G2% grfplot
C	
	COMMON/GRFCOM/NLINES,NCHARS,NG0,G,G0,G1,G2

	INTEGER*2 NG0,G,G0,G1,G2

	LOGICAL*1 TTINI(11) ,GMAX(8) ,GMIN(9) ,CR(2)
	LOGICAL*1 BUFF(9) ,TTEND(4)

	DATA	TTINI/27,'[','H',27,'[','J',15,27,'(','0',0/
	DATA	GMAX/' ','>',' ','M','A','X',':',"200/
	DATA	GMIN/' ',10,'>',' ','M','I','N',':',"200/
	DATA	CR/13,"200/
	DATA	TTEND/27,'(','B',0/

C		number of lines ,characters , used for graph
	NLINES=10
	NCHARS=80
	NG0=1
	BUFF(7)="200
	BUFF(8)="200

C		---find G1min G2max G0scal I1step
1	G1=32767
	G2=-32767
	DO 2,I=2,NCD(1)+1
	IF ( NCD(I).LT.G1 )	G1=NCD(I)
	IF ( NCD(I).GT.G2 )	G2=NCD(I)
2	CONTINUE

	G0=1
	IF ( G2.NE.G1 )	G0=(G2-G1)/(NLINES*5)
	I1STEP=1 
	IF ( NCHARS.LT.NCD(1) ) I1STEP=NCD(1)/NCHARS
C		--- set terminal +  axe
	CALL	PRINT (TTINI)
	G=G2 
	CALL	GPLOT
	CALL	PRINT (GMAX)
	CALL IENCOD(1,BUFF,6,G2)
	CALL	PRINT (BUFF)
	CALL	PRINT (CR)

	IF (G1.GT.0 ) GOTO 10

	G=0
	DO 4,I=2,NCD(1),I1STEP
	CALL	GPLOT
4	CONTINUE

	CALL	PRINT (CR)

C		--- PLOT points
10	DO 20,I=2,NCD(1),I1STEP
	G=NCD(I)
20	CALL	GPLOT

	CALL	PRINT (CR)
	G=G1
	CALL	GPLOT
	CALL	PRINT (GMIN)
	CALL IENCOD(1,BUFF,6,G1)
	CALL	PRINT (BUFF)
	CALL PRINT (TTEND)

	end

	SUBROUTINE GPLOT
	COMMON/GRFCOM/NLINES,NCHARS,NG0,G,G0,G1,G2

	INTEGER*2 NG0,G,G0,G1,G2

	LOGICAL*1 UP(3) , DOWN(2) ,GOUT(2)
	DATA	DOWN/10,"200/
	DATA	UP/27,'M',"200/

	NG1=(G-G1)/G0 
	NG2=NLINES-(NG1/5)

	IF (NG2.LE.NG0) GOTO 3
	DO 2,NG=NG0,NG2-1
	CALL PRINT (DOWN)
	NG0=NG0+1
2	CONTINUE

3	IF (NG0.LE.NG2) GOTO 5
	DO 4,NG=NG2,NG0-1
	CALL PRINT (UP)
	NG0=NG0-1
4	CONTINUE

5	GOUT(1)=(115-NG1+(5*(NG1/5)))
	GOUT(2)="200
	CALL PRINT (GOUT)

	END
