C   14/10/82            MEMBER NAME  TESTWR   (S)           FORTRAN77
      SUBROUTINE TESTWR(NBUF,MODE)
      COMMON/BCS/IW(1)
      CALL BWRO(1,NBUF,MODE)
      NREC=0
      DO 50 K=1,500
C     CREATE HEAD
      DO 10 J=1,3
      CALL BCRE(IND,'HEAD',J,20,&100,IER)
      DO 5 I=1,20
    5 IW(IND+I)=I
   10 CONTINUE
C     CREATE DATA
      NJ=MOD(K,7)+3
      DO 20 J=1,NJ
      NW=10+J
      IF(J.EQ.9) NW=2000
      CALL BCRE(IND,'DATA',J,NW,&100,IER)
      DO 15 I=1,NW
   15 IW(IND+I)=I*100
   20 CONTINUE
C     WRITE
      CALL BMLT(2,'HEADDATA')
   30 CALL BWRS(1,NBUFL,INIW)
      IF(INIW.EQ.0) GOTO 40
      NREC=NREC+1
      IF(NREC.GE.7777) CALL BPRS('BUFF',1)
      CALL BFWR(1,NBUFL,IW(INIW))
      GOTO 30
C     DELETE
   40 CALL BMLT(2,'HEADDATA')
      CALL BDLG
C
   50 CONTINUE
      CALL BMLT(0,DUMMY)
      CALL BWRS(1,NBUFL,INIW)
      IF(INIW.EQ.0) GOTO 60
      CALL BFWR(1,NBUFL,IW(INIW))
   60 CONTINUE
      CALL BSTA
      REWIND 1
      CALL BDLS('+BUF',1)
      CALL BGAR(IGA)
      RETURN
  100 STOP
      END
