C   07/06/96 606071803  MEMBER NAME  BCHM     (S4)          FORTG1
      SUBROUTINE BCHM(IND,NZ,IER)
C     BOS SUBPROGRAM =1.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)
      INTEGER NZ(1)
C   30/04/96 604301841  MEMBER NAME  STAR     (BOSLIB.S)    FORTRAN
      REAL STAR/Z0000005C/,FF/Z000000FF/
      EQUIVALENCE (XNAME,INAME)
      LOGICAL NOTLOW
      REAL AND
      EXTERNAL AND
      NOTLOW(XNAME)=AND(XNAME,FF).NE.STAR
      IER=0
      NW=NZ(1)
      IF(NW) 20,10,30
C     ZERO MEANS MOVE TO END
   10 NN=IW(IND)+4
      IF(IND+IW(IND)+1.EQ.NEXT) GOTO 9
      IF(NEXT+NN.GT.NLST) GOTO 92
C     MOVE
      IW(INAMV)=IW(IND-3)
      LFDI=MOD(IABS(IW(INAMV)),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    91
      IF(IW(LFDI-2).LT.IW(IND-2)) GOTO 2
      IF(IW(LFDI-2).GT.IW(IND-2)) GOTO    91
      CALL UCOPY(IW(IND-3),IW(NEXT),NN)
      IW(IND)=-NN
      ILOW=MIN0(ILOW,IND)
      IND=NEXT+3
      NEXT=NEXT+NN
      IW(LFDK-1)=IND
      NFRE=NFRE+NN
    9 IF(NW) 40,100,40
C     NEGATIVE
   20 IF(IW(IND)+NW.LT.0) GOTO 91
      IF(IND+IW(IND)+1.EQ.NEXT) GOTO 40
      IF(NW.GT.(-4)) GOTO 10
      IW(IND)=IW(IND)+NW
      KND=IND+IW(IND)+4
      ILOW=MIN0(ILOW,KND)
      IW(KND)=NW
      NFRE=NFRE-NW
      GOTO 46
C     POSITIVE
   30 IF(IND+IW(IND)+1.NE.NEXT) GOTO 10
C     CHANGE LENGTH OF LAST BANK
   40 INAME=IW(IND-3)
      IF(NOTLOW(XNAME)) GOTO 45
      IF(NCPL+NW.GT.NSPL) GOTO 92
   45 IF(NEXT+NW.GT.NLST) GOTO 92
      IW(IND)=IW(IND)+NW
      NEXT=NEXT+NW
   46 INAME=IW(IND-3)
      IF(NOTLOW(XNAME)) GOTO 100
      NCPL=NCPL+NW
      GOTO 100
C
      ENTRY BCHF(IND,NZ,IER)
      IER=0
      NW=NZ(1)-IW(IND)
      IF(NW.GT.0) GOTO 30
      GOTO 100
C
      ENTRY BSTR(IND,NZ,IER)
      IF(IER.LE.0) GOTO 100
      CALL UCOPY2(NZ,IW(IND+1),IER)
      GOTO 100
C
      ENTRY BMRT(IND,NZ,IER)
      IND=0
      IF(IN.LE.0) GOTO 100
      DO 50 I=1,IN
      IF(I.GT.IER) GOTO 100
      IND=IND+1
      J=IW(NLST+I)
   50 NZ(IND)=IW(INAMV+J)
      GOTO 100
C     ERRORS
C     NOT ENOUGH SPACE
   92 IER=IER+1
C     BANK LENGTH WILL BECAME NEGATIVE OR
C     IND IS NOT A TRUE BANK INDEX
   91 IER=IER+1
C
  100 RETURN
      END
