      SUBROUTINE PLOTX(X,N)
C
C     PURPOSE--THIS SUBROUTINE YIELDS A ONE-PAGE PRINTER PLOT
C              OF X(I) VERSUS I.
C     INPUT ARGUMENTS--X      = THE SINGLE PRECISION VECTOR OF
C                               (UNSORTED OR SORTED) OBSERVATIONS
C                               TO BE PLOTTED VERTICALLY.
C                    --N      = THE INTEGER NUMBER OF OBSERVATIONS
C                               IN THE VECTOR X.
C     OUTPUT--A ONE-PAGE PRINTER PLOT OF X(I) VERSUS I.
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 PLOTX
C              SUBROUTINE.
C     REFERENCES--NONE.
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--JUNE      1972. 
C     UPDATED         --JANUARY   1975. 
C     UPDATED         --JULY      1975. 
C     UPDATED         --SEPTEMBER 1975. 
C     UPDATED         --OCTOBER   1975. 
C     UPDATED         --NOVEMBER  1975. 
C     UPDATED         --FEBRUARY  1976. 
C     UPDATED         --FEBRUARY  1977. 
C
C---------------------------------------------------------------------
C
      CHARACTER*4 IGRAPH
      CHARACTER*4 SBNAM1,SBNAM2
      CHARACTER*4 ALPH11,ALPH12,ALPH21,ALPH22
      CHARACTER*4 BLANK,HYPHEN,ALPHAI,ALPHAX
      CHARACTER*4 ALPHAM,ALPHAA,ALPHAD,ALPHAN,EQUAL
C
      DIMENSION X(1)
      DIMENSION YLABLE(11)
      COMMON /BLOCK1/ IGRAPH(55,130)
C
      DATA SBNAM1,SBNAM2/'PLOT','X   '/ 
      DATA ALPH11,ALPH12/'FIRS','T   '/ 
      DATA ALPH21,ALPH22/'SECO','ND  '/ 
      DATA BLANK,HYPHEN,ALPHAI,ALPHAX/' ','-','I','X'/
      DATA ALPHAM,ALPHAA,ALPHAD,ALPHAN,EQUAL/'M','A','D','N','='/
C
      IPR=6
      CUTOFF=(10.0**10)-1000.0
C
C     CHECK THE INPUT ARGUMENTS FOR ERRORS
C
      WRITE(IPR,998)
      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     DETERMINE THE VALUES TO BE LISTED ON THE LEFT VERTICAL AXIS
C
      DO200I=1,N
      IF(X(I).GE.CUTOFF)GOTO200
      YMIN=X(I)
      YMAX=X(I)
      GOTO250
  200 CONTINUE
  250 DO300I=1,N
      IF(X(I).GE.CUTOFF)GOTO300
      IF(X(I).LT.YMIN)YMIN=X(I)
      IF(X(I).GT.YMAX)YMAX=X(I)
  300 CONTINUE
      DO400I=1,9
      AIM1=I-1
      YLABLE(I)=YMAX-(AIM1/8.0)*(YMAX-YMIN)
  400 CONTINUE
C
C     DETERMINE THE VALUES TO BE LISTED ON THE BOTTOM HORIZONTAL AXIS.
C     DETERMINE XMIN, XMAX, XMID, X25 (=THE 25% POINT), AND 
C     X75 (=THE 75% POINT).
C
      XMIN=1.0
      XMAX=N
      XMID=(XMIN+XMAX)/2.0
      X25=0.75*XMIN+0.25*XMAX 
      X75=0.25*XMIN+0.75*XMAX 
C
C     BLANK OUT THE GRAPH
C
      DO1100I=1,45
      DO1200J=1,109 
      IGRAPH(I,J)=BLANK
 1200 CONTINUE
 1100 CONTINUE
C
C     PRODUCE THE VERTICAL AXES
C
      DO1300I=3,43
      IGRAPH(I,5)=ALPHAI
      IGRAPH(I,109)=ALPHAI
 1300 CONTINUE
      DO1400I=3,43,5
      IGRAPH(I,5)=HYPHEN
      IGRAPH(I,109)=HYPHEN
 1400 CONTINUE
      IGRAPH(3,1)=EQUAL
      IGRAPH(3,2)=ALPHAM
      IGRAPH(3,3)=ALPHAA
      IGRAPH(3,4)=ALPHAX
      IGRAPH(23,1)=EQUAL
      IGRAPH(23,2)=ALPHAM
      IGRAPH(23,3)=ALPHAI
      IGRAPH(23,4)=ALPHAD
      IGRAPH(43,1)=EQUAL
      IGRAPH(43,2)=ALPHAM
      IGRAPH(43,3)=ALPHAI
      IGRAPH(43,4)=ALPHAN
C
C     PRODUCE THE HORIZONTAL AXES
C
      DO1500J=7,107 
      IGRAPH(1,J)=HYPHEN
      IGRAPH(45,J)=HYPHEN
 1500 CONTINUE
      DO1600J=7,107,25
      IGRAPH(1,J)=ALPHAI
      IGRAPH(45,J)=ALPHAI
 1600 CONTINUE
      DO1700J=20,107,25
      IGRAPH(1,J)=ALPHAI
      IGRAPH(45,J)=ALPHAI
 1700 CONTINUE
C
C     DETERMINE THE (X,Y) PLOT POSITIONS
C
      RATIOY=40.0/(YMAX-YMIN) 
      RATIOX=100.0/(XMAX-XMIN)
      DO1800I=1,N
      IF(X(I).GE.CUTOFF)GOTO1800
      XI=I
      MX=RATIOX*(XI-XMIN)+0.5 
      MX=MX+7
      MY=RATIOY*(X(I)-YMIN)+0.5
      MY=43-MY
      IGRAPH(MY,MX)=ALPHAX
 1800 CONTINUE
C
C     WRITE OUT THE GRAPH
C
      WRITE(IPR,2102)
      DO2100I=1,45
      IP2=I+2
      IFLAG=IP2-(IP2/5)*5
      K=IP2/5
      IF(IFLAG.NE.0)WRITE(IPR,2105)(IGRAPH(I,J),J=1,109)
      IF(IFLAG.EQ.0)WRITE(IPR,2106)YLABLE(K),(IGRAPH(I,J),J=1,109)
 2100 CONTINUE
      WRITE(IPR,2107)XMIN,X25,XMID,X75,XMAX
C
 2102 FORMAT(1H ,   'THE FOLLOWING IS A PLOT OF X(I) (VERTICALLY) VERSUS
     1 I (HORIZONTALLY)')
 2105 FORMAT(1H ,20X,109A1)
 2106 FORMAT(1H ,F20.7,109A1) 
 2107 FORMAT(1H ,14X,F20.7,5X,F20.7,5X,F20.7,5X,F20.7,1X,F20.7)
  998 FORMAT(1H1)
C
      RETURN
      END 
