C   07/06/96 606071847  MEMBER NAME  GSTEER   (S4)          FORTRAN
      SUBROUTINE GSTEER(PGNAME,IVRCUR,MODE)
      COMMON/BCS/IW(1)
      COMMON/STEERC/JGOTO,NRUN,LRUN,JRETCD,JSW
      INTEGER PGNAME(2),IVRCUR,MODE,IEND/0/,IBS(2),INB(2),LND/-1/
      LOGICAL CURR/.FALSE./
      EXTERNAL BOOKEE
      IF(CURR) GOTO 10
C
C     INITIALIZE INDICES
C
      CURR=.TRUE.
      IBS(1)=IBLN('BKST')
      IBS(2)=IBLN('HEAD')
      LND=-1
C
C     FIND BANK INDICES
C
   10 DO 16 I=1,2
      INB(I)=0
      IND=IBS(I)+1
   12 IND=IW(IND-1)
      IF(IND.EQ.0) GOTO 16
      IF(IW(IND-2)+I-2) 12,14,16
   14 INB(I)=IND
   16 CONTINUE
C
C     UPDATE LAST ENTRY FROM RETURN CODE
C
   20 JGOTO=6
      IF(LND.LT.0) GOTO 30
      IND=INB(1)
      IF(IND.EQ.0) GOTO 30
      INCR=JRETCD
      IF(INCR.LT.0.OR.INCR.GT.10) INCR=11
      IW(IND+LND+5+INCR)=IW(IND+LND+5+INCR)+1
      LND=-1
C
C     CHECK PROCESSING OF THIS RECORD
C
   30 IF(IEND.EQ.1) GOTO 40
      IF(INB(2).EQ.0) GOTO 100
      IEVT=IW(INB(2)+4)
      IF(IEVT.NE.0) GOTO 100
      NRUN=IW(INB(2)+1)
   36 CALL BOOKCH(PGNAME,IVRCUR,IVROLD)
      IF(MODE.EQ.0) GOTO 38
      IF(MODE.EQ.1.AND.IVROLD.EQ.0) GOTO 38
      IF(MODE.EQ.2.AND.IVROLD.NE.IVRCUR) GOTO 38
      GOTO 100
   38 JGOTO=3
      CALL BOOKIN
C
C     FIND ENTRY IN (BKST,1)
C
   40 IND=INB(1)
      LND=0
      NW=0
      IF(IND.EQ.0) GOTO 52
      N=IW(IND)/20
      DO 42 I=1,N
      IF(IW(IND+LND+1).NE.PGNAME(1)) GOTO 42
      IF(IW(IND+LND+2).EQ.PGNAME(2)) GOTO 60
   42 LND=LND+20
C
C     ADD ENTRY TO (BKST,1)
C
   50 NW=IW(IND)
   52 IF(IEND.EQ.1) GOTO 72
      CALL BCRE(IND,'BKST',1,NW+20,&200,IER)
      IW(IND+LND+1)=PGNAME(1)
      IW(IND+LND+2)=PGNAME(2)
C
C     CHECK RUN SEQUENCE
C
   60 IF(IEND.EQ.1) GOTO 70
      IW(IND+LND+3)=MODE
      IW(IND+LND+4)=IW(IND+LND+4)+1
      JRETCD=0
      LRUN=IW(IND+LND+17)
      IF(NRUN.EQ.LRUN) GOTO 100
      IW(IND+LND+17)=NRUN
      JGOTO=4
      IF(LRUN.EQ.0) JGOTO=1
      GOTO 100
C
C     JOB END CASE
C
   70 LRUN=IW(IND+LND+17)
      IF(LRUN.EQ.0) GOTO 72
      IW(IND+LND+17)=0
      JGOTO=5
      LND=-1
      GOTO 100
   72 LND=-1
      JGOTO=6
      GOTO 100
C
C
C
      ENTRY GSTEND
C
C     ENTRY AT JOB END
C
   80 CALL BOOKEJ
      IEND=1
      CALL BLOC(IND,'BKST',1,&100)
      IF(LND.LT.0) GOTO 82
      INCR=JRETCD
      IF(INCR.LT.0.OR.INCR.GT.10) INCR=11
      IW(IND+LND+5+INCR)=IW(IND+LND+5+INCR)+1
   82 LND=-1
      WRITE(6,101)
      N=IW(IND)/20
      DO 84 I=1,N
      WRITE(6,102) (IW(IND+J),J=1,16)
      IF(IW(IND+4).NE.IW(IND+5)) GOTO 84
      WRITE(6,103) (IW(IND+J),J=1,2)
   84 IND=IND+20
      GOTO 100
C
C
C
      ENTRY GSTAGA
C
C     ENTRY TO START AGAIN
C
      IEND=0
      CALL BDLS('BKST',1)
C
C
C
  100 RETURN
  101 FORMAT('0PGNAME  MODE      SUM',9X,
     1   'STATISTIC ON PROCESSING RETURN CODES'/' -',5('----'),9X,
     2   '0',6X,'1',6X,'2',6X,'3',6X,'4',6X,'5',6X,'6',6X,'7',6X,
     3   '8',6X,'9',5X,'10  UNDEFINED')
  102 FORMAT(1X,2A4,I4,I9,3X,11I7,I11)
  103 FORMAT(1X,2A4,'<---',' RETURN CODE ALWAYS 0, NO PROCESSING DONE')

  104 FORMAT('0STOP IN GSTEER DUE TO INSUFFICIENT SPACE')
C
C     ERROR - INSUFFICIENT SPACE
C
  200 WRITE(6,104)
      CALL ABEND
      GOTO 100
      END
