      SUBROUTINE PLTXXT(X,N)
C
C     PURPOSE--THIS SUBROUTINE YIELDS A NARROW-WIDTH (71-CHARACTER)
C              PLOT OF X(I) VERSUS X(I-1).  ITS NARROW WIDTH MAKES IT 
C              APPROPRIATE FOR USE ON A TERMINAL. 
C              THIS TYPE OF PLOT (WHICH IS CALLED AN
C              AUTOCORRELATION PLOT OR A LAG 1 PLOT)
C              IS USEFUL IN EXAMINING FOR
C              AUTOCORRELATION IN A SEQUENCE OF OBSERVATIONS.
C              UNCORRELATED DATA WILL PRODUCE AN AUTOCORRELATION
C              PLOT WITH NO APPARENT STRUCTURE; AUTOCORRELATED
C              DATA WILL PRODUCE AN AUTOCORRELATION PLOT WITH
C              LINEAR, ELLIPTICAL, OR OTHER KINDS OF STRUCTURE.
C     INPUT ARGUMENTS--X      = THE SINGLE PRECISION VECTOR OF
C                               (UNSORTED) OBSERVATIONS
C                               TO BE GRAPHICALLY TESTED FOR
C                               AUTOCORRELATION.
C                    --N      = THE INTEGER NUMBER OF OBSERVATIONS
C                               IN THE VECTOR X.
C     OUTPUT--A NARROW-WIDTH (71-CHARACTER) TERMINAL PLOT
C             OF X(I) VERSUS X(I-1).
C             THE BODY OF THE PLOT (NOT COUNTING AXIS VALUES
C             AND MARGINS) IS 25 ROWS (LINES) AND 49 COLUMNS.
C     PRINTING--YES.
C     RESTRICTIONS--THERE IS NO RESTRICTION ON THE MAXIMUM VALUE
C                   OF N FOR THIS SUBROUTINE.
C     OTHER DATAPAC   SUBROUTINES NEEDED--NONE.
C     FORTRAN LIBRARY SUBROUTINES NEEDED--NONE.
C     MODE OF INTERNAL OPERATIONS--SINGLE PRECISION.
C     LANGUAGE--ANSI FORTRAN. 
C     COMMENT--VALUES IN THE VERTICAL AXIS VECTOR (X) WHICH ARE
C              EQUAL TO OR IN EXCESS OF 10.0**10 WILL NOT BE
C              PLOTTED.
C              THIS CONVENTION GREATLY SIMPLIFIES THE PROBLEM
C              OF PLOTTING WHEN SOME ELEMENTS IN THE VECTOR X
C              ARE 'MISSING DATA', OR WHEN WE PURPOSELY
C              WANT TO IGNORE CERTAIN ELEMENTS IN THE VECTOR X
C              FOR PLOTTING PURPOSES (THAT IS, WE DO NOT
C              WANT CERTAIN ELEMENTS IN X TO BE PLOTTED).
C              TO CAUSE SPECIFIC ELEMENTS IN X TO BE
C              IGNORED, WE REPLACE THE ELEMENTS BEFOREHAND
C              (BY, FOR EXAMPLE, USE OF THE   REPLAC   SUBROUTINE)
C              BY SOME LARGE VALUE (LIKE, SAY, 10.0**10) AND
C              THEY WILL SUBSEQUENTLY BE IGNORED IN THE PLTXXT
C              SUBROUTINE.
C            --NOTE THAT THE STORAGE REQUIREMENTS FOR THIS
C              (AND THE OTHER) TERMINAL PLOT SUBROUTINESS ARE .
C              VERY SMALL.
C              THIS IS DUE TO THE 'ONE LINE AT A TIME' ALGORITHM
C              EMPLOYED FOR THE PLOT.
C     REFERENCES--FILLIBEN, 'SOME USEFUL PROCEDURES FOR THE 
C                 STATISTICAL ANALYSIS OF DATA', UNPUBLISHED
C                 MANUSCRIPT (AVAILABLE FROM AUTHOR)
C                 PRESENTED AT THE FALL CONFERENCE
C                 OF THE CHEMICAL DIVISION OF THE AMERICAN
C                 SOCIETY FOR QUALITY CONTROL, KNOXVILLE,
C                 TENNESSEE, OCTOBER 19-20, 1972. 
C               --FILLIBEN, 'DATA EXPLORATION USING STAND-ALONE
C                 SUBROUTINES', UNPUBLISHED MANUSCRIPT
C                 (AVAILABLE FROM AUTHOR)
C                 PRESENTED AT THE 'STRATEGY FOR DATA ANALYSIS
C                 BY COMPUTERS' SESSION AT THE NATIONAL
C                 MEETING OF THE AMERICAN STATISTICAL ASSOCIATION,
C                 ST. LOUIS, MISSOURI, AUGUST 26-29, 1974.
C     WRITTEN BY--JAMES J. FILLIBEN
C                 STATISTICAL ENGINEERING LABORATORY (205.03)
C                 NATIONAL BUREAU OF STANDARDS
C                 WASHINGTON, D. C. 20234
C                 PHONE--301-921-2315
C     ORIGINAL VERSION--FEBRUARY  1974. 
C     UPDATED         --APRIL     1974. 
C     UPDATED         --OCTOBER   1974. 
C     UPDATED         --OCTOBER   1975. 
C     UPDATED         --NOVEMBER  1975. 
C     UPDATED         --FEBRUARY  1977. 
C
C---------------------------------------------------------------------
C
      CHARACTER*4 ILINE
      CHARACTER*4 IAXISC
      CHARACTER*4 SBNAM1,SBNAM2
      CHARACTER*4 ALPH11,ALPH12,ALPH21,ALPH22
      CHARACTER*4 BLANK,HYPHEN,ALPHAI,ALPHAX
C
      DIMENSION X(1)
      DIMENSION ILINE(72),X2LABL(10)
C
      DATA SBNAM1,SBNAM2/'PLTX','XT  '/ 
      DATA ALPH11,ALPH12/'FIRS','T   '/ 
      DATA ALPH21,ALPH22/'SECO','ND  '/ 
      DATA BLANK,HYPHEN,ALPHAI,ALPHAX/' ','-','I','X'/
C
      IPR=6
      CUTOFF=(10.0**10)-1000.0
C
C     CHECK THE INPUT ARGUMENTS FOR ERRORS
C
      IF(N.LT.1)GOTO52
      GOTO54
   52 WRITE(IPR,5)
      WRITE(IPR,10) 
      WRITE(IPR,15)ALPH21,ALPH22,SBNAM1,SBNAM2
      WRITE(IPR,20)N
      WRITE(IPR,5)
      RETURN
   54 CONTINUE
      IF(N.EQ.1)GOTO56
      GOTO58
   56 WRITE(IPR,5)
      WRITE(IPR,10) 
      WRITE(IPR,15)ALPH21,ALPH22,SBNAM1,SBNAM2
      WRITE(IPR,22)N
      WRITE(IPR,5)
      RETURN
   58 CONTINUE
C
      HOLD=X(1)
      DO60I=2,N
      IF(X(I).NE.HOLD)GOTO62
   60 CONTINUE
      WRITE(IPR,5)
      WRITE(IPR,10) 
      WRITE(IPR,15)ALPH11,ALPH12,SBNAM1,SBNAM2
      WRITE(IPR,30)HOLD
      WRITE(IPR,5)
      RETURN
   62 CONTINUE
C
      DO76I=1,N
      IF(X(I).LT.CUTOFF)GOTO78
   76 CONTINUE
      WRITE(IPR,5)
      WRITE(IPR,10) 
      WRITE(IPR,15)ALPH11,ALPH12,SBNAM1,SBNAM2
      WRITE(IPR,32) 
      WRITE(IPR,33)CUTOFF
      WRITE(IPR,5)
      RETURN
   78 CONTINUE
C
    5 FORMAT(1H ,'**************************************************',
     1'********************') 
   10 FORMAT(1H ,'                   FATAL ERROR                    ')
   15 FORMAT(1H ,'THE ',A4,A4,' INPUT ARGUMENT TO THE ',A4,A4,
     1' SUBROUTINE')
   20 FORMAT(1H ,'IS NON-NEGATIVE (WITH VALUE = ',I8,1H))
   22 FORMAT(1H ,'HAS THE VALUE 1')
   30 FORMAT(1H ,'HAS ALL ELEMENTS = ',E15.8)
   32 FORMAT(1H ,'HAS ALL ELEMENTS IN EXCESS OF THE CUTOFF')
   33 FORMAT(1H ,'VALUE OF ',E15.8)
C
C-----START POINT-----------------------------------------------------
C
C     DEFINE THE NUMBER OF ROWS AND COLUMNS WITHIN THE PLOT--
C     THIS HAS BEEN SET TO 25 ROWS AND 49 COLUMNS.
C
      NUMROW=25
      NUMCOL=49
      ANUMR=NUMROW
      ANUMRM=NUMROW-1
      ANUMCM=NUMCOL-1
      NUMR25=(NUMROW/4)+1
      NUMR50=(NUMROW/2)+1
      NUMR75=3*(NUMROW/4)+1
      IXDEL=(NUMCOL-1)/4
      NUMLAB=5
      ANUMLM=NUMLAB-1
C
C     WRITE OUT THE TOP HORIZONTAL AXIS OF THE PLOT, AND SKIP 1 LINE
C     FOR A MARGIN WITHIN THE PLOT.
C
      WRITE(IPR,999)
      WRITE(IPR,205)
      DO100ICOL=1,NUMCOL
      ILINE(ICOL)=HYPHEN
  100 CONTINUE
      DO200ICOL=1,NUMCOL,IXDEL
      ILINE(ICOL)=ALPHAI
  200 CONTINUE
      WRITE(IPR,305)(ILINE(I),I=1,NUMCOL)
      WRITE(IPR,310)BLANK
C
C     DETERMINE THE MIN AND MAX VALUES OF X.
C
      XMIN=X(1)
      XMAX=X(1)
      DO300I=1,N
      IF(X(I).GE.CUTOFF)GOTO300
      IF(X(I).LT.XMIN)XMIN=X(I)
      IF(X(I).GT.XMAX)XMAX=X(I)
  300 CONTINUE
      DELX=XMAX-XMIN
      XRWIDT=DELX/ANUMRM
      XCWIDT=DELX/ANUMCM
C
C     DETERMINE AND WRITE OUT THE PLOT POSITIONS ONE LINE AT A TIME.
C
      DO400IROW=1,NUMROW
      DO500ICOL=1,NUMCOL
      ILINE(ICOL)=BLANK
  500 CONTINUE
      AIROW=IROW
      XUPPER=XMAX+(1.5-AIROW)*XRWIDT
      XLABLE=XMAX+(1.0-AIROW)*XRWIDT
      XLOWER=XMAX+(0.5-AIROW)*XRWIDT
      IF(IROW.EQ.NUMROW)XLABLE=XMIN
      DO600I=2,N
      IM1=I-1
      IF(X(IM1).GE.CUTOFF)GOTO600
      IF(X(I).GE.CUTOFF)GOTO600
      IF(XLOWER.LE.X(I).AND.X(I).LT.XUPPER)GOTO650
      GOTO600
  650 ICOL=((X(IM1)-XMIN)/XCWIDT)+1.5
      ILINE(ICOL)=ALPHAX
  600 CONTINUE
      ICOLMX=1
      DO700ICOL=1,NUMCOL
      IF(ILINE(ICOL).EQ.ALPHAX)ICOLMX=ICOL
  700 CONTINUE
      IAXISC=ALPHAI 
      IF(IROW.EQ.1.OR.IROW.EQ.NUMROW)IAXISC=HYPHEN
      IF(IROW.EQ.NUMR25.OR.IROW.EQ.NUMR50.OR.IROW.EQ.NUMR75)
     1IAXISC=HYPHEN 
      WRITE(IPR,710)XLABLE,IAXISC,(ILINE(ICOL),ICOL=1,ICOLMX)
  400 CONTINUE
C
C     SKIP 1 LINE FOR A BOTTOM MARGIN WITHIN THE PLOT, WRITE OUT THE
C     BOTTOM HORIZONTAL AXIS, AND WRITE OUT THE X AXIS LABLES.
C
      WRITE(IPR,310)BLANK
      DO800ICOL=1,NUMCOL
      ILINE(ICOL)=HYPHEN
  800 CONTINUE
      DO900ICOL=1,NUMCOL,IXDEL
      ILINE(ICOL)=ALPHAI
  900 CONTINUE
      WRITE(IPR,305)(ILINE(ICOL),ICOL=1,NUMCOL)
      DO1000I=1,NUMLAB
      AIM1=I-1
      X2LABL(I)=XMIN+(AIM1/ANUMLM)*DELX 
 1000 CONTINUE
      WRITE(IPR,910)(X2LABL(I),I=1,NUMLAB)
C
  205 FORMAT(1H ,   'THE FOLLOWING IS A PLOT OF X(I) (VERTICALLY) VS. ,
     1 21HX(I-1) (HORIZONTALLY)')
  305 FORMAT(1H ,18X,54A1)
  310 FORMAT(1H ,15X,A1)
  710 FORMAT(1H ,E14.7,1X,A1,2X,50A1)
  910 FORMAT(1H ,9X,5E12.4)
  999 FORMAT(1H )
C
      RETURN
      END 
