C.hr DCOND2
C@
C....*...1.........2.........3.........4.........5.........6.........7.*
C     DCOND2    5/15/74
C
C     PURPOSE
C     IMPROVE ACCURACY OF DSWEEP WHEN DIAGONAL ELEMENTS OF A ARE NOT OF
C     THE SAME ORDER OF MAGNITUDE.
C
C     USAGE
C     CALL DCOND2(A,N,S,0)
C     CALL DSWEEP(A,N,EPS,IER)
C     CALL DCOND2(A,N,S,1)
C
C     ARGUMENTS
C     A   - SYMMETRIC POSITIVE DEFINITE N BY N MATRIX STORED COLUMNWISE.
C           (STORAGE MODE 0)
C           REAL*8
C     N   - NUMBER OF ROWS AND COLUMNS OF A.  LENGTH OF S.
C           INTEGER*4
C     S   - WORK VECTOR OF LENGTH N.
C           REAL*8
C     ISW - INTEGER SWITCH.
C           INTEGER*4
C
C     REMARK
C     THE USAGE
C     CALL DCOND2(A,N,S,0)
C     WILL RETURN A CORRELATION MATRIX IN A AND THE STANDARD ERRORS IN
C     S WHEN A IS A VARIANCE-COVARIANCE MATRIX.
C
C
C
      SUBROUTINE DCOND2(A,N,S,ISW)
      implicit real*8 (a-h,o-z)
      save
      REAL*8 A(N,N),S(N)
      IF(ISW.EQ.1) GO TO 20
      DO 10 I=1,N
10    S(I)=DSQRT(A(I,I))
20    DO 30 I=1,N
      DO 30 J=1,N
30    IF(S(I)*S(J).NE.0.D0)
     &A(I,J)=A(I,J)/(S(I)*S(J))
      RETURN
      END
