C     .TITLE GETCOP
C
C   2 JAN 75 - PAUL HENDERSON
C
C  PROGRAM TO RETRIEVE DATA FILES FOR 'CO-OP'
C
      LOGICAL T/.TRUE./,ISENSW
      INTEGER SIZE,UNIT/2/
      COMMON /OIL/IVECT(600)
C
   1  CALL CLEAR (T)
      CALL DISPLY (0,20000,IGET)
      IF (ISENSW(0)) WRITE (4,*) 'ASK 20000; GET',IGET
      CALL OPEN (2,'COOPS2BIN')
      CALL OPEN (3,'COOPS3BIN')
C
  99  ITAG = 0
C
C  READ 'CO' PART OF FIRST FIGURE
C
 100  READ (UNIT,END=7) INDEX
 101  IF (INDEX .NE. 1) GO TO 201
      READ (UNIT,END=7) SIZE
      READ (UNIT)(IVECT(K),K=1,SIZE)
      ITAG = ITAG + 1
      CALL DISPLY (6,ITAG,IVECT,1,SIZE)
      GO TO 100
C
C  READ 'OP' PART OF FIRST FIGURE
C
 200  READ (UNIT,END=7) INDEX
 201  IF (INDEX .NE. 2) GO TO 301
      READ (UNIT,END=7) SIZE
      READ (UNIT)(IVECT(K),K=1,SIZE)
      ITAG = ITAG + 1
      CALL DISPLY (6,ITAG,IVECT,1,SIZE)
      GO TO 200
C
C  READ 'CO' PART OF SECOND FIGURE
C
 300  READ (UNIT,END=7) INDEX
 301  IF (INDEX .NE. 3) GO TO 401
      READ (UNIT,END=7) SIZE
      READ (UNIT)(IVECT(K),K=1,SIZE)
      ITAG = ITAG + 1
      CALL DISPLY (6,ITAG,IVECT,1,SIZE)
      GO TO 300
C
C  READ 'OP' PART OF SECOND FIGURE
C
 400  READ (UNIT,END=6) INDEX
 401  IF (INDEX .NE. 4) GO TO 501
      READ (UNIT,END=7) SIZE
      READ (UNIT)(IVECT(K),K=1,SIZE)
      ITAG = ITAG + 1
      CALL DISPLY (6,ITAG,IVECT,1,SIZE)
      GO TO 400
C
C  END OF COMPLETE FIGURE OR INVALID SEQUENCE
C
 501  IF (INDEX .NE. 1) WRITE (4,*) 'INVALID INDEX:',INDEX
      CALL DISPLY (7,IGET)
      IF (ISENSW(0)) WRITE (4,*) '''DISPLY'' CORE LEFT',IGET
 502  IF (ISENSW(3)) GO TO 502
C
C  WIPE OUT EXISTING FIGURE
C
      CALL DISPLY (8)
      IF (UNIT .EQ. 4) GO TO 71
      GO TO 101
C
C  END OF FILE ENCOUNTERED.  IT MAY BE END OF FIRST SECTION
C
   6  UNIT = UNIT + 1
      INDEX = 1
      IF (UNIT .EQ. 4) GO TO 501
      GO TO 400
C
   7  WRITE (4,*) 'UNEXPECTED END OF FILE'
C
  71  PAUSE 7
      STOP 7
      END
