C   07/06/96 606071817  MEMBER NAME  BGAR     (S4)          FORTG1
      SUBROUTINE BGAR(IGA)
C     BOS SUBPROGRAM =0.7=
C   18/10/82            MEMBER NAME  ACS      (S)           FORTRAN
      COMMON/ACS/
     1   ICOND,NLAST,NDUMP,NSPL,NAMAX,NAMAX1,NLIST,NPRIM,NFRS,NLST,
     2   NEXT,NCI,NFRE,IN,KPOS,LIND,ILOW,LFDI,LFDK,NCPL,
     3   NHISTH(11),
     4        NCOL,NZT,IBFI,NLAST1,ISLST,IMLST,INAMV,IOLST,IPLST,
     5   NER(10),
     6   NRECL,NERRL,NRIN,NROUT,NS,NEXTI,NEXTA,NEXTB,ISAVB,NSAVB,
     7   NHISTL(11),
     8        MARKWR,NOUT(3),IASW,NPRE,IDUMMY(1),NEOTP,NDUMP1
      COMMON/BCS/IW(1)
C
C     GARBAGE COLLECTION - ALL ACTIVE BANKS ARE SHIFTED TO BEGIN
      IGA=0
      IF(NFRE.EQ.0) GOTO 100
      NK=1+((10*(NEXT-2))/NLAST)
      NHISTH(NK)=NHISTH(NK)+1
      NK=1+((10*NCPL)/NLAST)
      NK=MIN0(10,NK)
      NHISTL(NK)=NHISTL(NK)+1
      NG  =0
      NSH =0
      LI  =2
      I=NFRS+3
      IF(ILOW.NE.NLST) I=ILOW
      GOTO 12
   10 I=I+NW
   12 IF(I.GT.NEXT) GOTO 30
      IF(IW(I).GE.0) GOTO 20
      IF(NSH.GT.0) GOTO 32
   14 NG=NG-IW(I)
      I=I-IW(I)
      GOTO 12
C
   20 NW=IW(I)+4
      IF(NG.EQ.0) GOTO 10
      LFDK=LI
      IF(I.EQ.IW(LI-1)) GOTO 24
      IF(NSH.EQ.0) GOTO 22
      CALL UCOPY2(IW(ISH),IW(ISH-NG),NSH)
      NSH=0
C     FIND POINTER TO THIS BANK
   22 IW(INAMV)=IW(I-3)
      LFDI=MOD(IABS(IW(I-3)),NPRIM)+NAMAX1
    1 LFDI=IW(LFDI+IPLST)
      IF(IW(LFDI+INAMV).NE.IW(INAMV)) GOTO 1
      IF(LFDI.EQ.0) LFDI=IBLN(IW(INAMV))
      LFDK=LFDI+1
      LFDI=IW(LFDI)
      GOTO 3
    2 LFDK=LFDI
      LFDI=IW(LFDI-1)
    3 IF(LFDI.EQ.0)        GOTO    200
      IF(IW(LFDI-2).LT.IW(I-2)) GOTO 2
      IF(IW(LFDI-2).GT.IW(I-2)) GOTO    200
   24 IW(LFDK-1)=IW(LFDK-1)-NG
      LI=I
      IF(NSH.EQ.0) ISH=I-3
      NSH=NSH+NW
      GOTO 10
C
   30 IF(NSH.EQ.0) GOTO 40
   32 CALL UCOPY2(IW(ISH),IW(ISH-NG),NSH)
      NSH=0
      LI=2
      IF(I.LT.NEXT) GOTO 14
C
   40 NEXT=NEXT-NG
      NFRE=NFRE-NG
      NCOL=NCOL+1
      IGA=1
      ILOW=NLST
C
  100 RETURN
  200 LFDI=I
      CALL BDMPA(32)
      GOTO 100
      END
