      SUBROUTINE DLINDS(NCA,A,LDA,AINV,LDAINV,INFO)
C
C**********************************************************************
C
C   NAME- DLINDS
C
C   LANGUAGE- VS FORTRAN  TYPE- SUBROUTINE      COMPUTER- CRAY J916
C
C   VERSION- 1.0    DATE- 03/25/96   PROGRAMMER- T. GARDNER (HSTX)
C   VERSION- 1.1    DATE- 05/31/96   PROGRAMMER- T. GARDNER (HSTX)
C
C   FUNCTION- THIS SUBROUTINE PERFORMS THE SAME FUNCTION AS THE IMSL
C             ROUTINE BY THE SAME NAME.  IT COMPUTES THE INVERSE OF A
C             REAL SYMMETRIC POSITIVE DEFINITE MATRIX.  FOR USE WITH
C             CRAY (VERSION 3.0 OR HIGHER) VERSION OF SOFTWARE.
C
C   VERSION 1.1- AN EXTRA ARGUMENT WAS ADDED TO ALLOW THE ERROR
C                RETURN CODE FROM THE CALLED SUBROUTINES TO BE READ
C                FROM THE ROUTINE WHICH CALLED DLINDS.
C
C   CALLING SEQUENCE PARAMETERS-
C     VARIABLE          TYPE I/O  FUNCTION
C     --------          ---- ---  --------
C      NCA              INT   I   NUMBER OF COLUMNS IN A.
C      A                REAL  I   MATRIX (DIMENSION N X N) WHICH WILL BE
C                                 INVERTED.
C      LDA              INT   I   LEADING DIMENSION OF A.
C      AINV             REAL  O   N BY N MATRIX CONTAINING THE INVERSE
C                                 OF A.
C      LDAINV           INT   I   LEADING DIMENSION OF AINV AS SPECIFIED
C                                 IN THE CALLING PROGRAM.
C      INFO             INT   O   RETURN CODE FROM CALLED SUBROUTINES.
C
C
C   LOCAL PARAMETERS-
C     VARIABLE          TYPE  FUNCTION
C     --------          ----  --------
C     I, J              INT   LOOP COUNTERS.S
C     NROW	        INT   NUMBER OF ROWS TO BE COPIED
C     NCOL              INT   NUMBER OF COLUMNS TO BE COPIED
C
C     FUNCTIONS CALLED- SPOTRF,SPOTRI
C
C COMMENTS-
C --------
C THIS SUBROUTINE IS A SUBSTITUTE FOR THE IMSL ROUTINE DLINDS SINCE
C THE IMSL ROUTINES ARE NOT AVAILABLE ON THE CRAY.  VARIABLES AINV
C AND A MAY REFERENCE THE SAME MEMORY LOCATIONS IF VALUES FOR MATRIX
C A ARE NOT NEEDED.
C
C RETURN CODE:
C
C	INFO = 0  - NORMAL SUBROUTINE TERMINATION.
C	INFO <> 0 - THE INPUT MATRIX IS NOT POSITIVE DEFINITE.
C**********************************************************************
C
      REAL A(LDA,NCA), AINV(LDAINV,LDAINV)
      INTEGER NCA, LDA, LDAINV, I, J, INFO
      INTEGER*4 NCAI4, LDAI4, LDAINVI4, INFOI4
C
C COPY THE INPUT MATRIX TO THE OUTPUT MATRIX TO SAVE THE CONTENTS FROM
C BEING WRITTEN OVER.  FIRST MAKE SURE THAT THE INVERTED MATRIX DIMENSIO
C WILL NOT RESULT IN A COPY BEYOND THE BOUNDS OF THE MATRIX.
C
      IF (NCA .GT. LDAINV) THEN
        NROW = LDAINV
      ELSE
        NROW = NCA
      ENDIF
C
      IF (LDA .GT. LDAINV) THEN
        NCOL = LDAINV
      ELSE
        NCOL = LDA
      ENDIF
C
      DO 10 J = 1,NROW
         DO 10 I = 1,NCOL
            AINV(I,J) = A(I,J)
  10     CONTINUE
  20  CONTINUE
C
C COMPUTE THE CHOLESKY FACTORIZATION AND PLACE IT IN THE LOWER
C TRIANGLE OF THE MATRIX.  IF RETURN CODE IS NOT ZERO, THE INPUT
C MATRIX IS NOT POSITIVE DEFINITE.
C
C     CALL SPOTRF('L',NCA,AINV,LDAINV,INFO)
      NCAI4 = NCA
      LDAINVI4 = LDAINV
      INFOI4 = INFO
      CALL DPOTRF('L',NCAI4,AINV,LDAINVI4,INFOI4)
      NCA = NCAI4
      LDAINV = LDAINVI4
      INFO = INFOI4
      IF (INFO .EQ. 0) THEN
C
C THE CHOLESKY FACTORIZATION IS NOW USED TO GENERATE THE INVERSE
C OF THE MATRIX.  THIS IS PLACED IN THE LOWER TRIANGLE OF THE MATRIX.
C
C       CALL SPOTRI('L',NCA,AINV,LDAINV,INFO)
      NCAI4 = NCA
      LDAINVI4 = LDAINV
      INFOI4 = INFO
        CALL DPOTRI('L',NCAI4,AINV,LDAINVI4,INFOI4)
      NCA = NCAI4
      LDAINV = LDAINVI4
      INFO = INFOI4
C
C FILL IN THE UPPER TRIANGLE OF THE INVERTED MATRIX.
C
        DO 40 J = 1,NCA
           DO 30 I = J+1, LDAINV
              AINV(J,I) = AINV(I,J)
  30       CONTINUE
  40    CONTINUE
      ENDIF
C
      RETURN
      END
