C
C **	PROGRAM TO PLOT THE OUTPUT OF INTCAL
C
C **	PROGRAMMER ROBERT L. SNYDER
C		   ALFRED UNIVERSITY
C		   ALFRED, N.Y. 14802
C
	CHARACTER*40 NFILE
	BYTE TITLE(80)
	DIMENSION PLTX(102),PLTY(102)
	COMMON /IO/ IO5,IO6,IO7,IO10,IO20
	DATA IO5,IO6,IO7,IO10,IO20,IO30/5,6,6,10,20,30/
C
C  HAS THE USER SET THE TERMINAL TO NOWRAP?
C
	WRITE(IO6,1000)
1000	FORMAT(/' HP PLOT ROUTINE FOR INTCAL OUTPUT'//
     1  ' DID YOU SET TERM/NOWRAP BEFORE STARTING? (Y/N)')
	READ(IO5,1010)IN
1010	FORMAT(A1)
	IF(IN.EQ.'N')CALL EXIT
C
C  READ IN THE DATA DEFINING THE CALCULATED CURVE FROM THE DATA
C  FILE PREPARED BY INTCAL (I.E. INTCAL.PLT)
C
	OPEN(UNIT=IO10,NAME='INTCAL.PLT',STATUS='OLD',
     1  FORM='UNFORMATTED')
	READ(IO10)NUM,(PLTX(I),PLTY(I),I=1,NUM)
C
C  PLOT THE CALCULATED CURVE
C
	CALL MYPLOT(PLTX,PLTY,NUM,0,0)
C
C  READ THE UNCORRECTED DELTA TWO THETAS IN FOR PLOTTING
C
	READ(IO10)NUM,(PLTX(I),PLTY(I),I=1,NUM)
C
C  PLOT THE RAW DATA
C
	M = 2
	CALL MYPLOT(PLTX,PLTY,NUM,M,-1)
	CALL EXIT
	END

	SUBROUTINE MYPLOT(X,Y,N,M,IP)
C
C  IF M=0 FIRST CALL DRAW AXIS
C  IF M=1 SUBSEQUENT CALL USE THE OLD SCALE FACTORS
C  IF M=2 LAST CALL EXIT AFTER PLOTTING
C
C  IF IP = -1 DRAW SYMBOLS ONLY
C  IF IP = 0  DRAW LINE ONLY
C  IF IP = +1 DRAW LINE AND SYMBOLS
C
	CHARACTER*20 IXT, IYT
	DIMENSION X(102),Y(102)
	COMMON /IO/ IO5,IO6,IO7,IO10,IO20
	DATA IXT/ 'OBSERVED TWO-THETA  '/
	DATA IYT/ 'DELTA TWO-THETA     '/
	IPEN = 1
C
C  CONVERT FROM DOUBLE PRECISSION
C
C	DO 10 I=1,N
C	X(I) = PLX(I)
C10	Y(I) = PLY(I)
	IF(M.GT.0)GO TO 100
C
C  SET UP THE PLOT
C
	IS = 0
	CALL START(0.,0.)
	CALL PLOT(1.0,1.0,-3)
	CALL SCALE(X,8.,N,1)
	CALL SCALE(Y,10.,N,1)
	FX = X(N+1)
	DX = X(N+2)
	FY = Y(N+1)
	DY = Y(N+2)
	CALL AXIS(0.0,0.0,IXT,-18,8.,0.0,
     1  FX,DX)
	CALL AXIS(0.0,0.0,IYT,13,10.,90.0,
     1  FY,DY)
100	X(N+1) = FX
	X(N+2) = DX
	Y(N+1) = FY
	Y(N+2) = DY
	IS = IS + 1
C
C  INCREMENT THE PEN COLOR
C
	IPEN = IPEN + 1
	CALL NEWPEN(IPEN)
	CALL LINE(X,Y,N,1,IP,IS)
	IF(M.LT.2)GO TO 999
	CALL END
999	RETURN
	END

