      SUBROUTINE PLOTCO(Y,N)
C
C     THIS ROUTINE YIELDS A MULTI-PAGE (IF NECESSARY) PLOT OF THE AUTOCORRELATIO
C     COEFFICIENT R(K) VERSUS THE LAG K 
C     THERE IS NO RESTRICTION ON THE MAXIMUM VALUE OF N FOR THIS ROUTINE.
C     PRINTING--YES 
C     SUBROUTINES NEEDED--NONE
C     WRITTEN BY JAMES J. FILLIBEN, STATISTICAL ENGINEERING LABORATORY (205.03) 
C     NATIONAL BUREAU OF STANDARDS, WASHINGTON, D.C. 20234     JUN 1972
C                                                      UPDATED FEB 1975
C     UPDATED         --NOVEMBER  1975. 
C     UPDATED         --FEBRUARY  1976. 
C
C---------------------------------------------------------------------
C
      CHARACTER*4 IGRAPH
      CHARACTER*4 BLANK,STAR,HYPHEN,ALPHAI
      DIMENSION Y(1)
      COMMON /BLOCK1/ IGRAPH(55,130)
      DIMENSION YLABLE(11)
      DIMENSION IX(25)
C
      DATA BLANK,STAR,HYPHEN,ALPHAI/' ','*','-','I'/
C
      IPR=6
C
C     CHECK THE INPUT ARGUMENTS FOR ERRORS
C
      IF(N.LT.1)GOTO50
      IF(N.EQ.1)GOTO55
      HOLD=Y(1)
      DO60I=2,N
      IF(Y(I).NE.HOLD)GOTO90
   60 CONTINUE
      WRITE(IPR, 9)HOLD
      GOTO90
   50 WRITE(IPR,15) 
      WRITE(IPR,47)N
      RETURN
   55 WRITE(IPR,18) 
      RETURN
   90 CONTINUE
    9 FORMAT(1H ,   '***** NON-FATAL DIAGNOSTIC--THE FIRST  INPUT ARGUME
     1NT (A VECTOR) TO THE PLOTCO SUBROUTINE HAS ALL ELEMENTS = ' ,
     1E15.8,' *****')
   15 FORMAT(1H ,   '***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE
     1 PLOTCO SUBROUTINE IS NON-POSITIVE *****')
   18 FORMAT(1H ,   '***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUME
     1NT TO THE PLOTCO SUBROUTINE HAS THE VALUE 1 *****')
   47 FORMAT(1H , '***** THE VALUE OF THE ARGUMENT IS ',I8   ,' *****')
C
C-----START POINT-----------------------------------------------------
C
C     DETERMINE THE Y VALUES TO BE LISTED ON THE LEFT VERTICAL AXIS
C
      YMIN=-1.0
      YMAX=1.0
      DO110I=1,11
      YLABLE(I)=FLOAT(6-I)/5.0
  110 CONTINUE
C
C     DETERMINE DISTANCES BETWEEN HORIZONTAL PLOT POINTS AND DISTANCES BETWEEN
C     HASH MARKS ON THE X AXIS
C
      IF(N.LE.24)IDEL=5
      IF(25.LE.N.AND.N.LE.40)IDEL=3
      IF(41.LE.N.AND.N.LE.60)IDEL=2
      IF(61.LE.N)IDEL=1
      IAXDEL=10
      IF(N.LE.24)IAXDEL=5
      IF(25.LE.N.AND.N.LE.40)IAXDEL=15
C
C     DETERMINE THE NUMBER OF PAGES THE PLOT WILL TAKE UP
C
      NUMPAG=((N-1)/120)+1
C
C     OPERATE  ON EACH PAGE
C
      DO120IZ=1,NUMPAG
C
C     DETERMINE THE X-AXIS VALUES
C
      IXMIN=0
      IXMAX=N
      IF(N.LE.24)GOTO130
      IF(25.LE.N.AND.N.LE.40)GOTO135
      IF(41.LE.N.AND.N.LE.60)GOTO140
      IXMAX=120*IZ
      IXMIN=IXMAX-120
      I=0 
  150 I=I+1
      IX(I)=IXMIN+10*(I-1)
      IF(I.LT.13)GOTO150
      GOTO145
  130 DO131I=1,25
      IX(I)=I-1
  131 CONTINUE
      GOTO145
  135 DO136I=1,9
      IX(I)=5*(I-1) 
  136 CONTINUE
      GOTO145
  140 DO141I=1,13
      IX(I)=5*(I-1) 
  141 CONTINUE
C
C     BLANK OUT THE GRAPH
C
  145 DO100I=1,55
      DO200J=1,130
      IGRAPH(I,J)=BLANK
  200 CONTINUE
  100 CONTINUE
C
C     PRODUCE THE Y AXIS
C
      DO300I=5,55
      IGRAPH(I,10)=ALPHAI
      IGRAPH(I,130)=ALPHAI
  300 CONTINUE
      DO350I=5,55,5 
      IGRAPH(I,10)=HYPHEN
      IGRAPH(I,130)=HYPHEN
  350 CONTINUE
C
C     PRODUCE THE X AXIS
C
      DO400J=10,130 
      IGRAPH(55,J)=HYPHEN
      IGRAPH(30,J)=HYPHEN
      IGRAPH(5,J)=HYPHEN
  400 CONTINUE
      DO450J=10,130,IAXDEL
      IGRAPH(55,J)=ALPHAI
      IGRAPH(5,J)=ALPHAI
  450 CONTINUE
C
C     DETERMINE THE (X,Y) PLOT POSITIONS
C
      IMIN=IXMIN+1
      IMAX=IXMAX
      IF(IMAX.GT.N)IMAX=N
      RATIOY=50.0/(YMAX-YMIN) 
      DO600I=IMIN,IMAX
      MX=MOD(I,120) 
      MX=MX*IDEL
      IF(MX.EQ.0)MX=120
      MX=MX+10
      MY=RATIOY*(Y(I)-YMIN)+0.5
      MY=55-MY
      IGRAPH(MY,MX)=STAR
      JMAX=MAX0(MY,30)
      JMIN=MIN0(MY,30)
      DO650J=JMIN,JMAX
      IGRAPH(J,MX)=STAR
  650 CONTINUE
  600 CONTINUE
C
C     WRITE OUT THE GRAPH
C
      WRITE(IPR,998)
      IF(IZ.EQ.1)WRITE(IPR,702)N
      IF(IZ.GE.2)WRITE(IPR,704)
      WRITE(IPR,999)
      IF(N.LE.24)WRITE(IPR,707)(IX(I),I=1,25)
      IF(25.LE.N.AND.N.LE.40)WRITE(IPR,708)(IX(I),I=1,9)
      IF(41.LE.N)WRITE(IPR,709)(IX(I),I=1,13)
      DO700I=5,55
      IFLAG=I-(I/5)*5
      K=I/5
      IF(IFLAG.NE.0)WRITE(IPR,705)(IGRAPH(I,J),J=1,130)
      IF(IFLAG.EQ.0)WRITE(IPR,706)YLABLE(K),(IGRAPH(I,J),J=10,130)
  700 CONTINUE
      IF(N.LE.24)WRITE(IPR,707)(IX(I),I=1,25)
      IF(25.LE.N.AND.N.LE.40)WRITE(IPR,708)(IX(I),I=1,9)
      IF(41.LE.N)WRITE(IPR,709)(IX(I),I=1,13)
  120 CONTINUE
  702 FORMAT(' THE TOTAL NUMBER OF POINTS PLOTTED (ON ALL PAGES) IS ',
     1I5) 
  704 FORMAT(1H ,  'THE PLOT ON THIS PAGE IS A CONTINUATION OF THE PLOT
     1ON THE PREVIOUS PAGE')
  705 FORMAT(1H ,130A1)
  706 FORMAT(1H ,F9.2,130A1)
  707 FORMAT(1H ,6X,24(I4,1X),I4)
  708 FORMAT(1H ,6X,8(I4,11X),I4)
  709 FORMAT(1H ,6X,12(I4,6X),I4)
  998 FORMAT(1H1)
  999 FORMAT(1H )
      RETURN
      END 
