C.hr DRINV
C@
C....*...1.........2.........3.........4.........5.........6.........7.*
C
C     DRINV
C
C     PURPOSE
C     INVERT AN UPPPER TRIANGULAR MATRIX.
C
C     USAGE
C     CALL DRINV(A,N)
C
C     ARGUMENTS
C     A - AN N*(N+1)/2-VECTOR CONTAINING THE UPPER TRIANGLE OF AN UPPER
C         TRIANGULAR MATRIX STORED COLUMNWISE (STORAGE MODE 1).
C         CONTAINS THE MATRIX TO BE INVERTED ON ENTRY AND THE INVERSE,
C         WHICH IS UPPER TRIANGULAR, ON RETURN; REAL*8
C     N - THE NUMBER OF ROWS AND COLUMNS IN A
C         INPUT, INTEGER*4
C
C     REMARK
C     THE ROUTINE ASSUMES THAT THE MATRIX TO BE INVERTED WAS RETURNED BY
C     DMFSD AND DOES NO ERROR CHECKING.  THE CODE WAS LIFTED FROM THE
C     MIDSECTION OF SSP ROUTINE DSINV
C
      SUBROUTINE DRINV(A,N)
      implicit real*8 (a-h,o-z)
      save
      real*8 A,DIN,WORK
      DIMENSION A(N*(N+1)/2)
    1 IPIV=N*(N+1)/2
      IND=IPIV
      DO 6 I=1,N
      DIN=1.D0/A(IPIV)
      A(IPIV)=DIN
      MIN=N
      KEND=I-1
      LANF=N-KEND
      IF(KEND) 5,5,2
    2 J=IND
      DO 4 K=1,KEND
      WORK=0.D0
      MIN=MIN-1
      LHOR=IPIV
      LVER=J
      DO 3 L=LANF,MIN
      LVER=LVER+1
      LHOR=LHOR+L
    3 WORK=WORK+A(LVER)*A(LHOR)
      A(J)=-WORK*DIN
    4 J=J-MIN
    5 IPIV=IPIV-MIN
    6 IND=IND-1
    9 RETURN
      END
