```001:       SUBROUTINE SPOTRS( UPLO, N, NRHS, A, LDA, B, LDB, INFO )
002: *
003: *  -- LAPACK routine (version 3.2) --
004: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
005: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
006: *     November 2006
007: *
008: *     .. Scalar Arguments ..
009:       CHARACTER          UPLO
010:       INTEGER            INFO, LDA, LDB, N, NRHS
011: *     ..
012: *     .. Array Arguments ..
013:       REAL               A( LDA, * ), B( LDB, * )
014: *     ..
015: *
016: *  Purpose
017: *  =======
018: *
019: *  SPOTRS solves a system of linear equations A*X = B with a symmetric
020: *  positive definite matrix A using the Cholesky factorization
021: *  A = U**T*U or A = L*L**T computed by SPOTRF.
022: *
023: *  Arguments
024: *  =========
025: *
026: *  UPLO    (input) CHARACTER*1
027: *          = 'U':  Upper triangle of A is stored;
028: *          = 'L':  Lower triangle of A is stored.
029: *
030: *  N       (input) INTEGER
031: *          The order of the matrix A.  N >= 0.
032: *
033: *  NRHS    (input) INTEGER
034: *          The number of right hand sides, i.e., the number of columns
035: *          of the matrix B.  NRHS >= 0.
036: *
037: *  A       (input) REAL array, dimension (LDA,N)
038: *          The triangular factor U or L from the Cholesky factorization
039: *          A = U**T*U or A = L*L**T, as computed by SPOTRF.
040: *
041: *  LDA     (input) INTEGER
042: *          The leading dimension of the array A.  LDA >= max(1,N).
043: *
044: *  B       (input/output) REAL array, dimension (LDB,NRHS)
045: *          On entry, the right hand side matrix B.
046: *          On exit, the solution matrix X.
047: *
048: *  LDB     (input) INTEGER
049: *          The leading dimension of the array B.  LDB >= max(1,N).
050: *
051: *  INFO    (output) INTEGER
052: *          = 0:  successful exit
053: *          < 0:  if INFO = -i, the i-th argument had an illegal value
054: *
055: *  =====================================================================
056: *
057: *     .. Parameters ..
058:       REAL               ONE
059:       PARAMETER          ( ONE = 1.0E+0 )
060: *     ..
061: *     .. Local Scalars ..
062:       LOGICAL            UPPER
063: *     ..
064: *     .. External Functions ..
065:       LOGICAL            LSAME
066:       EXTERNAL           LSAME
067: *     ..
068: *     .. External Subroutines ..
069:       EXTERNAL           STRSM, XERBLA
070: *     ..
071: *     .. Intrinsic Functions ..
072:       INTRINSIC          MAX
073: *     ..
074: *     .. Executable Statements ..
075: *
076: *     Test the input parameters.
077: *
078:       INFO = 0
079:       UPPER = LSAME( UPLO, 'U' )
080:       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
081:          INFO = -1
082:       ELSE IF( N.LT.0 ) THEN
083:          INFO = -2
084:       ELSE IF( NRHS.LT.0 ) THEN
085:          INFO = -3
086:       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
087:          INFO = -5
088:       ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
089:          INFO = -7
090:       END IF
091:       IF( INFO.NE.0 ) THEN
092:          CALL XERBLA( 'SPOTRS', -INFO )
093:          RETURN
094:       END IF
095: *
096: *     Quick return if possible
097: *
098:       IF( N.EQ.0 .OR. NRHS.EQ.0 )
099:      \$   RETURN
100: *
101:       IF( UPPER ) THEN
102: *
103: *        Solve A*X = B where A = U'*U.
104: *
105: *        Solve U'*X = B, overwriting B with X.
106: *
107:          CALL STRSM( 'Left', 'Upper', 'Transpose', 'Non-unit', N, NRHS,
108:      \$               ONE, A, LDA, B, LDB )
109: *
110: *        Solve U*X = B, overwriting B with X.
111: *
112:          CALL STRSM( 'Left', 'Upper', 'No transpose', 'Non-unit', N,
113:      \$               NRHS, ONE, A, LDA, B, LDB )
114:       ELSE
115: *
116: *        Solve A*X = B where A = L*L'.
117: *
118: *        Solve L*X = B, overwriting B with X.
119: *
120:          CALL STRSM( 'Left', 'Lower', 'No transpose', 'Non-unit', N,
121:      \$               NRHS, ONE, A, LDA, B, LDB )
122: *
123: *        Solve L'*X = B, overwriting B with X.
124: *
125:          CALL STRSM( 'Left', 'Lower', 'Transpose', 'Non-unit', N, NRHS,
126:      \$               ONE, A, LDA, B, LDB )
127:       END IF
128: *
129:       RETURN
130: *
131: *     End of SPOTRS
132: *
133:       END
134: ```