C   07/06/96 606071825  MEMBER NAME  BOOKCH   (S4)          FORTRAN
      SUBROUTINE BOOKCH(PGNAME,IVRCUR,IVROLD)
C
C     SUBROUTINE BOOKCH WITH ADDITIONAL ENTRY BOOKIN CAN BE USED
C     TO CHECK, WETHER A CERTAIN PROGRAM IS ALREADY APPLIED TO THE
C     DATA AND TO GET THE VERSION-NR, WITH WHICH THE PROCESSING WAS
C     DONE, AND TO RECORD THE PROCESSING OF A MODUL, TOGETHER WITH
C     THE USED VERSION-NR AND THE DATE OF PROCESSING.
C
C                    -------  ------
C        CALL BOOKCH('PGNAME',IVRCUR,IVROLD)
C                                    ------
C
C            'PGNAME' = NAME OF PROGRAM (2A4, LEFT ADJUSTED)
C             IVRCUR  = CURRENT VERSION-NR = DATE OF INTRODUCTION
C                       AS INTEGER OF THE FORM YYMMDD
C
C             IVROLD  = 0              IF EVENT NOT
C                                      YET PROCESSED WITH THE PROGRAM
C                     = VERSION-NR     IF ALREADY PROCCESSED
C
C
C        CALL BOOKIN
C
C             THE INFORMATION FROM THE PREVIOUS CALL TO BOOKCH IS
C             RECORDED IN A BANK ('BOOK',0) FOR THE CURRENT EVENT
C
      COMMON/BCS/IW(1)
C
C     ENTRY TO GET OLD VERSION-NR IVROLD FROM BANK (BOOK,0) FOR
C     THE PROGRAM PGNAME
C
      INTEGER PGNAME(2),IVRCUR,IVROLD
      INTEGER IDEF/0/,IENT(4),NN/0/
      LOGICAL CURR/.FALSE./
      REAL*8 DATE(2)
      LOGICAL*1 LD(8),LN(4)
      EQUIVALENCE (DATE(1),LD(1)),(NN,LN(1))
      IF(CURR) GOTO 10
      CURR=.TRUE.
C
C     DETERMINE PROCESSING DATE
C
      CALL DAY(DATE(1),DATE(2))
      IDAT=0
      DO 2 I=1,3
      II=9-3*I
      DO 2 J=1,2
      LN(4)=LD(II+J)
    2 IDAT=IDAT*10+NN-240
      IBOK=IBLN('BOOK')
C
C     STORE NEW ENTRY IN LOCAL ARRAY
C
   10 IDEF=1
      IENT(1)=PGNAME(1)
      IENT(2)=PGNAME(2)
      IENT(3)=IVRCUR
      IENT(4)=IDAT
C
C     RESET OLD VERSION-NR
C
   20 IVROLD=0
C
C     FIND BANK (BOOK,0)
C
   30 IND=IBOK+1
   32 IND=IW(IND-1)
      IF(IND.EQ.0) GOTO 100
      IF(IW(IND-2)) 32,40,100
C
C     FIND ENTRY IN BANK (BOOK,0) FOR PGNAME
C
   40 N=IW(IND)/4
      IF(N.EQ.0) GOTO 100
      JND=IND
      DO 42 I=1,N
      IF(IW(JND+1).NE.IENT(1)) GOTO 42
      IF(IW(JND+2).EQ.IENT(2)) GOTO 44
   42 JND=JND+4
      GOTO 100
   44 IVROLD=IW(JND+3)
      GOTO 100
C
C
C
      ENTRY BOOKIN
C
C     ENTRY TO ADD NEW ENTRY INTO BANK (BOOK,0) FROM LOCAL ARRAY
C
   50 IF(IDEF.EQ.0) GOTO 100
      IDEF=0
      NW=0
C
C     FIND BANK (BOOK,0)
C
   60 IND=IBOK+1
   62 IND=IW(IND-1)
      IF(IND.EQ.0) GOTO   82
      IF(IW(IND-2)) 62,70,82
C
C     FIND ENTRY IN BANK (BOOK,0) FOR PGNAME
C
   70 N=IW(IND)/4
      JND=IND
      KND=0
      IF(N.EQ.0) GOTO 82
      DO 74 I=1,N
      IF(IW(JND+1).NE.IENT(1)) GOTO 72
      IF(IW(JND+2).EQ.IENT(2)) GOTO 92
   72 IF(KND.NE.0) GOTO 74
      IF(IW(JND+1).EQ.0.AND.IW(JND+2).EQ.0) KND=JND
   74 JND=JND+4
      IF(KND.NE.0) GOTO 90
C
C     CREATE NEW BANK (BOOK,0) OR INCREASE LENGTH
C
   80 NW=IW(IND)
   82 NW=NW+12
      CALL BCRE(IND,'BOOK',0,NW,&100,IER)
      CALL BSAW(1,'BOOK')
      GOTO 70
C
C     STORE ENTRY IN BANK (BOOK,0)
C
   90 JND=KND
   92 DO 94 I=1,4
   94 IW(JND+I)=IENT(I)
C
C
C
  100 RETURN
      END
