C   07/06/96 606071827  MEMBER NAME  BOUTP    (S4)          FORTG1
      SUBROUTINE BOUTP(NTOT,INIW)
C     BOS SUBPROGRAM =3.8=
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)
      REAL RW(1)
      EQUIVALENCE (RW(1),IW(1))
      INTEGER ITWO/2/
      EQUIVALENCE (TWO,ITWO)
      REAL OR
      EXTERNAL OR
C     ASSEMBLE BANKS IN CONTIGUOUS LOCATIONS
      MODE=-1
      GOTO 10
C
      ENTRY BORDP(NTOT,INIW)
      MODE=NTOT
      NREL=INIW
   10 INIW=0
      NROUT=NROUT+1
      IORD=0
      NTOT=0
      INDA=0
      J=0
   20 J=J+1
      IF(J.GT.IN) GOTO 30
      IND=IW(NLST+J)
      NIND=IW(IND)
      IF(NIND.NE.0) RW(IOLST+IND)=OR(RW(IOLST+IND),TWO)
      IND=NIND
      IF(IND.EQ.0) GOTO 20
      IF(INDA.EQ.0) INDA=IND
   25 IF(IND.NE.INDA+NTOT) IORD=1
      NTOT=NTOT+4+IW(IND)
      IND=IW(IND-1)
      IF(IND) 20,20,25
   30 IF(NTOT.NE.0) INIW=INDA-3
      IF(NTOT.EQ.0) GOTO 100
      IF(MODE) 60,40,50
   40 IF(NTOT+1.LE.NREL) GOTO 60
   45 INIW=0
      GOTO 100
   50 IF(NTOT+1.GT.NREL) GOTO 45
      IF(IORD.EQ.0) GOTO 100
      IF(NEXT+NTOT.GT.NLST) GOTO 45
C     ORDER LOOP
   60 IF(IORD.EQ.0) GOTO 100
      NEXTX=NEXT
      ISW=0
      IF(NEXT+NTOT.GT.NLST) ISW=-1
   70 J=0
   72 J=J+1
      IF(J.GT.IN) GOTO 82
      IND=IW(NLST+J)
      IND=IW(IND)
      IF(IND.LE.0) GOTO 72
C     BANK
   74 IF(ISW.NE.0) GOTO 76
      NW=IW(IND)+4
      CALL UCOPY2(IW(IND-3),IW(NEXTX),NW)
      NEXTX=NEXTX+NW
      GOTO 80
C     MOVE
   76 IF(ISW.GT.0) GOTO 78
      ISW=1
      NA1=IW(IND-3)
      NR1=IW(IND-2)
   78 CALL BCHM(IND,0,IER)
      IF(IER.EQ.0) GOTO 80
      NA2=IW(IND-3)
      NR2=IW(IND-2)
      CALL BGAR(IGA)
      CALL BLOC(IND,NA2,NR2,*90)
      CALL BCHM(IND,0,IER)
      IF(IER.NE.0) GOTO 90
C
   80 IND=IW(IND-1)
      IF(IND) 72,72,74
   82 INIW=NEXT
      IF(ISW) 90,100,84
   84 CALL BLOC(IND,NA1,NR1,*90)
      INIW=IND-3
      GOTO 100
C     ERROR OR TOO LARGE
   90 INIW=0
      IF(MODE+1.EQ.0) NTOT=0
  100 RETURN
      END
