      SUBROUTINE ZHESL (H,LDH,N,IPVT,B)
      INTEGER LDH,N,IPVT(N)
      DOUBLE COMPLEX H(LDH,N),B(N)
C
C     *** PURPOSE:
C
C     ZHESL SOLVES THE COMPLEX UPPER HESSENBERG SYSTEM
C                   H*X = B
C     USING THE FACTORS COMPUTED BY ZHECO OR ZHEFA.
C     THE LINPACK ANALOGUE OF ZHESL IS ZGESL.
C
C     ON ENTRY:
C
C        H    DOUBLE COMPLEX(LDH,N)
C             THE OUTPUT FROM ZHECO OR ZHEFA.
C
C        LDH  INTEGER
C             THE LEADING OR ROW DIMENSION OF THE ARRAY H AS
C             DECLARED IN THE MAIN CALLING PROGRAM.
C
C        N    INTEGER
C             THE ORDER OF THE MATRIX H.
C
C        IPVT INTEGER(N)
C             THE PIVOT VECTOR FROM ZHECO OR ZHEFA.
C
C        B    DOUBLE COMPLEX(N)
C             THE RIGHT HAND SIDE VECTOR.
C
C     ON RETURN:
C
C        B    THE SOLUTION VECTOR X (= (INVERSE(H)*B).
C
C     ERROR CONDITION:
C
C        A DIVISION BY ZERO WILL OCCUR IF THE INPUT FACTOR CONTAINS A
C        ZERO ON THE DIAGONAL.  TECHNICALLY, THIS INDICATES SINGULARITY
C        BUT IT IS OFTEN CAUSED BY IMPROPER ARGUMENTS OR IMPROPER
C        SETTING OF LDH.  IT WILL NOT OCCUR IF THE SUBROUTINES ARE
C        CALLED CORRECTLY AND IF ZHECO HAS SET RCOND .GT. 0.0
C        OR ZHEFA HAS SET INFO .EQ. 0.
C
C     TO COMPUTE  INVERSE(H)*G  WHERE G IS A MATRIX WITH M COLUMNS
C          CALL ZHECO (H,LDH,N,IPVT,RCOND,Z)
C          IF (RCOND IS TOO SMALL) GO TO ...
C          DO 10 J = 1,M
C             CALL ZHESL (H,LDH,N,IPVT,G(1,J))
C       10 CONTINUE
C
C     THIS VERSION DATED MAY 1980.
C     ALAN J. LAUB, UNIVERSITY OF SOUTHERN CALIFORNIA.
C
C     SUBROUTINES AND FUNCTIONS CALLED:
C
C     NONE
C
C     INTERNAL VARIABLES:
C
      INTEGER I,K,KB,L,NM1
      DOUBLE COMPLEX T
C
C     FORTRAN FUNCTIONS CALLED:
C
C     NONE
C
      IF (N .EQ. 1) GO TO 50
      NM1 = N-1
C
C     FIRST SOLVE  L*Y = B
C
      DO 20 K = 1,NM1
         L = IPVT(K)
         T = B(L)
         IF (L .EQ. K) GO TO 10
         B(L) = B(K)
         B(K) = T
   10    CONTINUE
         B(K+1) = B(K+1)-T*H(K+1,K)
   20 CONTINUE
C
C     NOW SOLVE  U*X = Y
C
      DO 40 KB = 1,NM1
         K = N-KB
         B(K+1) = B(K+1)/H(K+1,K+1)
         T = -B(K+1)
         DO 30 I = 1,K
              B(I) = B(I)+T*H(I,K+1)
   30    CONTINUE
   40 CONTINUE
   50 CONTINUE
      B(1) = B(1)/H(1,1)
      RETURN
      END
