      SUBROUTINE BNDACC (G,MDG,NB,IP,IR,MT,JT)                          BND00100
C     C.L.LAWSON AND R.J.HANSON, JET PROPULSION LABORATORY, 1973 JUN 12 BND00200
C     TO APPEAR IN 'SOLVING LEAST SQUARES PROBLEMS', PRENTICE-HALL, 1974BND00300
C          SEQUENTIAL ALGORITHM FOR BANDED LEAST SQUARES PROBLEM..      BND00400
C          ACCUMULATION PHASE.      FOR SOLUTION PHASE USE BNDSOL.      BND00500
C                                                                       BND00600
C     THE CALLING PROGRAM MUST SET IR=1 AND IP=1 BEFORE THE FIRST CALL  BND00700
C     TO BNDACC FOR A NEW CASE.                                         BND00800
C                                                                       BND00900
C     THE SECOND SUBSCRIPT OF G( ) MUST BE DIMENSIONED AT LEAST         BND01000
C     NB+1 IN THE CALLING PROGRAM.                                      BND01100
      DIMENSION G(MDG,1)                                                BND01200
      ZERO=0.                                                           BND01300
C                                                                       BND01400
C              ALG. STEPS 1-4 ARE PERFORMED EXTERNAL TO THIS SUBROUTINE.BND01500
C                                                                       BND01600
      NBP1=NB+1                                                         BND01700
      IF (MT.LE.0) RETURN                                               BND01800
C                                             ALG. STEP 5               BND01900
      IF (JT.EQ.IP) GO TO 70                                            BND02000
C                                             ALG. STEPS 6-7            BND02100
      IF (JT.LE.IR) GO TO 30                                            BND02200
C                                             ALG. STEPS 8-9            BND02300
      DO 10 I=1,MT                                                      BND02400
        IG1=JT+MT-I                                                     BND02500
        IG2=IR+MT-I                                                     BND02600
        DO 10 J=1,NBP1                                                  BND02700
   10   G(IG1,J)=G(IG2,J)                                               BND02800
C                                             ALG. STEP 10              BND02900
      IE=JT-IR                                                          BND03000
      DO 20 I=1,IE                                                      BND03100
        IG=IR+I-1                                                       BND03200
        DO 20 J=1,NBP1                                                  BND03300
   20   G(IG,J)=ZERO                                                    BND03400
C                                             ALG. STEP 11              BND03500
      IR=JT                                                             BND03600
C                                             ALG. STEP 12              BND03700
   30 MU=MIN0(NB-1,IR-IP-1)                                             BND03800
      IF (MU.EQ.0) GO TO 60                                             BND03900
C                                             ALG. STEP 13              BND04000
      DO 50 L=1,MU                                                      BND04100
C                                             ALG. STEP 14              BND04200
        K=MIN0(L,JT-IP)                                                 BND04300
C                                             ALG. STEP 15              BND04400
        LP1=L+1                                                         BND04500
        IG=IP+L                                                         BND04600
        DO 40 I=LP1,NB                                                  BND04700
          JG=I-K                                                        BND04800
   40     G(IG,JG)=G(IG,I)                                              BND04900
C                                             ALG. STEP 16              BND05000
        DO 50 I=1,K                                                     BND05100
        JG=NBP1-I                                                       BND05200
   50   G(IG,JG)=ZERO                                                   BND05300
C                                             ALG. STEP 17              BND05400
   60 IP=JT                                                             BND05500
C                                             ALG. STEPS 18-19          BND05600
   70 MH=IR+MT-IP                                                       BND05700
      KH=MIN0(NBP1,MH)                                                  BND05800
C                                             ALG. STEP 20              BND05900
      DO 80 I=1,KH                                                      BND06000
   80   CALL H12 (1,I,MAX0(I+1,IR-IP+1),MH,G(IP,I),1,RHO,               BND06100
     1            G(IP,I+1),1,MDG,NBP1-I)                               BND06200
C                                             ALG. STEP 21              BND06300
      IR=IP+KH                                                          BND06400
C                                             ALG. STEP 22              BND06500
      IF (KH.LT.NBP1) GO TO 100                                         BND06600
C                                             ALG. STEP 23              BND06700
      DO 90 I=1,NB                                                      BND06800
   90   G(IR-1,I)=ZERO                                                  BND06900
C                                             ALG. STEP 24              BND07000
  100 CONTINUE                                                          BND07100
C                                             ALG. STEP 25              BND07200
      RETURN                                                            BND07300
      END                                                               BND07400
