C   07/06/96 606071826  MEMBER NAME  BOOKEE   (S4)          FORTRAN
      SUBROUTINE BOOKEE
C
C     ENTRY AT END OF EVENT
C
      COMMON/BCS/IW(1)
      INTEGER IBS(3)/3*0/,INB(3)
      INTEGER NRUNS(15),NR/0/,NLN/50/,IDAT/0/
      REAL*8 DATE(2)
      LOGICAL*1 LD(8),LN(4)
      EQUIVALENCE (DATE(1),LD(1)),(NN,LN(1))
      LOGICAL CURR/.FALSE./
      IF(CURR) GOTO 2
      CURR=.TRUE.
      IBS(1)=IBLN('BOOK')
      IBS(2)=IBLN('BKST')
      IBS(3)=IBLN('HEAD')
C
C     FIND INDICES FOR BANKS (NAME(I),0) AND DETERMINE RUN NUMBER
C
    2 DO 8 I=1,3
      INB(I)=0
      IND=IBS(I)+1
    4 IND=IW(IND-1)
      IF(IND.EQ.0) GOTO 8
      IF(IW(IND-2)) 4,6,8
    6 INB(I)=IND
    8 CONTINUE
      IF(INB(3).EQ.0) GOTO 100
      NRUN=IW(INB(3)+1)
C
C     COMPARE BANKS (BOOK,0) AND (BKST,0)
C
   10 IF(INB(1).EQ.0) GOTO 14
      IF(INB(2).EQ.0) GOTO 30
      N =IW(INB(1))
      IF(IW(INB(2)).NE.N) GOTO 20
      DO 12 I=1,N
      IF(IW(INB(1)+I).NE.IW(INB(2)+I)) GOTO 20
   12 CONTINUE
      GOTO 50
   14 IF(INB(2).EQ.0) GOTO 100
C
C     CONTENTS ARE NOT IDENTICAL / PRINT RUN NUMBERS
C
   20 IF(NR.EQ.0) GOTO 30
      IF(NLN.LE.0) GOTO 22
      WRITE(6,103) (NRUNS(I),I=1,NR)
      NLN=NLN-1
      IF(NLN.EQ.0) WRITE(6,105)
   22 NR=0
C
C     STORE NEW CONTENT
C
   30 IND=INB(2)
      IF(IND.EQ.0) GOTO 32
      IF(INB(1).EQ.0) GOTO 31
      IF(IW(IND).EQ.IW(INB(1))) GOTO 34
   31 CALL BDLS('BKST',0)
      IF(INB(1).EQ.0) GOTO 100
   32 CALL BCRE(IND,'BKST',0,IW(INB(1)),&100,IER)
   34 N=IW(IND)
      DO 36 I=1,N
   36 IW(IND+I)=IW(INB(1)+I)
C
C     PRINT NEW CONTENT
C
   40 IF(NLN.EQ.0) GOTO 48
      JND=IND
      N=N/4
      DO 42 I=1,N
      IF(IW(JND+1).EQ.0) GOTO 44
   42 JND=JND+4
   44 JA=IND+1
      WRITE(6,101)
   46 JB=MIN0(JA+11,JND)
      WRITE(6,102) (IW(J),J=JA,JB)
      NLN=NLN-1
      JA=JB+1
      IF(JA.LT.JND) GOTO 46
      WRITE(6,102)
      NLN=NLN-1
      IF(NLN.GT.0) GOTO 48
      NLN=0
      WRITE(6,105)
   48 NR=0
C
C     CHECK NEW RUN NR AND STORE, IF DIFFERENT
C
   50 IF(NR.EQ.0) GOTO 56
      IF(NRUNS(NR).EQ.NRUN) GOTO 100
   52 IF(NR.LT.15) GOTO 56
      IF(NLN.LE.0) GOTO 54
      WRITE(6,103) (NRUNS(I),I=1,NR)
      NLN=NLN-1
      IF(NLN.EQ.0) WRITE(6,105)
   54 NR=0
   56 NR=NR+1
      NRUNS(NR)=NRUN
      GOTO 100
C
C
C
      ENTRY BOOKEJ
C
C     ENTRY AT JOB END
C
   60 IF(NR.EQ.0) GOTO 100
      IF(NLN.LE.0) GOTO 62
      WRITE(6,103) (NRUNS(I),I=1,NR)
      NLN=NLN-1
      IF(NLN.EQ.0) WRITE(6,105)
   62 NR=0
      GOTO 100
C
C
C
      ENTRY BOOKPR(NLINES)
C
C     ENTRY TO ALLOW NLINES OF PRINTOUT
C
   70 NLN=MAX0(0,NLINES)
      IF(IDAT.NE.0) GOTO 74
      CALL DAY(DATE(1),DATE(2))
      IDAT=0
      DO 72 I=1,3
      II=9-3*I
      DO 72 J=1,2
      LN(4)=LD(II+J)
   72 IDAT=IDAT*10+NN-240
   74 WRITE(6,104) NLN,IDAT
C
C
C
  100 RETURN
  101 FORMAT('0EVENT STATUS    ',
     1   3('    PGMNAME VERSION     PROC.DATE  '))
  102 FORMAT(' ....',12X,3(4X,2A4,I7,I14,2X))
  103 FORMAT(' .... IN RUNS  ',15I7)
  104 FORMAT('0EVENT STATUS    ',I7,' LINES OF PRINTOUT ALLOWED',
     1    55X,'TODAY IS',I7/)
  105 FORMAT('0EVENT STATUS    ',7X,'   PRINTOUT SUPPRESSED'/)
      END
