1@extract -b incpath.inc
2@extract -b @(incd)/type.inc type=@(@type)
3@ROUT spsv
4 @type sreal dreal scplx dcplx
5PROGRAM LA_@(pre)SPSV_ET_EXAMPLE
6 @type sherm dherm
7PROGRAM LA_@(pre)HPSV_ET_EXAMPLE
8 @type !
9@extract -b @(incd)/header.inc -case0
10!  .. USE STATEMENTS
11   USE LA_PRECISION, ONLY: WP => @(upr)P
12 @type sreal dreal scplx dcplx
13   USE F90_LAPACK, ONLY: LA_SPSV
14 @type sherm dherm
15   USE F90_LAPACK, ONLY: LA_HPSV
16 @type !
17!  .. IMPLICIT STATEMENT ..
18   IMPLICIT NONE
19!  .. PARAMETERS ..
20 @type sreal dreal
21   CHARACTER(LEN=*), PARAMETER :: FMT = '(8(1X,F10.3))'
22 @type scplx dcplx sherm dherm
23   CHARACTER(LEN=*), PARAMETER :: FMT = '(4(1X,1H(,F7.3,1H,,F7.3,1H):))'
24 @type !
25   INTEGER, PARAMETER :: NIN=5, NOUT=6
26!  .. LOCAL SCALARS ..
27   INTEGER :: I, J, K, FAIL, N, NRHS, NS
28!  .. LOCAL ARRAYS ..
29   INTEGER, ALLOCATABLE :: PIV(:)
30   @(type)(WP), ALLOCATABLE :: A(:), B(:,:)
31   REAL(WP), ALLOCATABLE :: AA(:), BB(:,:)
32!  .. EXECUTABLE STATEMENTS ..
33 @type sreal dreal scplx dcplx
34   WRITE (NOUT,*) '@(pre)SPSV ET_Example Program Results.'
35 @type sherm dherm
36   WRITE (NOUT,*) '@(pre)SPSV ET_Example Program Results.'
37 @type !
38   READ ( NIN, * )   ! SKIP HEADING IN DATA FILE
39   READ ( NIN, * ) N, NRHS
40   PRINT *, 'N = ', N, ' NRHS = ', NRHS
41   NS = N*(N+1)/2
42   ALLOCATE ( A(NS), AA(NS), B(N,NRHS), BB(N,NRHS), PIV(N) )
43!
44        READ (NIN, *) AA
45      BB = 0.0_WP
46      DO K = 1, NRHS
47         DO I = 1, N
48            DO J = 1, I
49               BB(J,K) = BB(J,K) + AA(J+(I-1)*I/2)
50               IF ( J /= I ) BB(I,K) = BB(I,K) + AA(J+(I-1)*I/2)
51            ENDDO
52         ENDDO
53         BB(:,K) = BB(:,K)*K
54      ENDDO
55   A=AA; B=BB
56      WRITE(NOUT,*) 'The matrix A:'
57      DO I = 1, N
58        WRITE (NOUT,*) 'J = ', I; WRITE (NOUT,FMT) (A(J+(I-1)*I/2),J=1,I)
59      ENDDO
60      WRITE(NOUT,*) 'The RHS matrix B:'
61      DO J = 1, NRHS
62        WRITE (NOUT,*) 'RHS', J; WRITE (NOUT,FMT) B(:,J)
63      ENDDO
64!
65   WRITE ( NOUT, * )'---------------------------------------------------------'
66   WRITE ( NOUT, * )
67 @type sreal dreal scplx dcplx
68   WRITE ( NOUT, * )'Details of LA_@(pre)SPSV LAPACK Subroutine Results.'
69   WRITE ( NOUT, * )
70!
71   WRITE(NOUT,*)
72   WRITE(NOUT,*) 'CALL LA_SPSV(A, B )'
73   A=AA; B=BB
74   IF (NRHS .GT. 1) THEN
75      CALL LA_SPSV( A, B )
76   ELSE
77      CALL LA_SPSV( A, B(1:N,1) )
78   END IF
79   WRITE(NOUT,*)'   B - the solution vectors computed by LA_SPSV:'
80   DO J = 1, NRHS
81      WRITE (NOUT,FMT) B(:,J)
82   END DO
83!
84   WRITE(NOUT,*)
85   WRITE(NOUT,*) 'CALL LA_SPSV( A, B, ''L'' )'
86   DO I = 1,N
87      DO J = I, N
88         A(J+(I-1)*(2*N-I)/2) = AA(I+J*(J-1)/2)
89      ENDDO
90   ENDDO
91   B = BB
92   CALL LA_SPSV( A, B, 'L' )
93   WRITE(NOUT,*)'   B - the solution vectors computed by LA_SPSV:'
94   DO J = 1, NRHS
95      WRITE (NOUT,FMT) B(:,J)
96   END DO
97   WRITE(NOUT,*)
98   WRITE(NOUT,*) 'CALL LA_SPSV( A, B(1:N,1), IPIV=PIV, INFO=FAIL )'
99   A=AA; B=BB
100   CALL LA_SPSV( A, B(1:N,1), IPIV=PIV, INFO=FAIL )
101   WRITE(NOUT,*)'B - the solution vectors computed by LA_SPSV, INFO = ', FAIL
102   WRITE (NOUT,FMT) B(1:N,1)
103   WRITE (NOUT,*) 'Pivots: ', PIV
104!
105END PROGRAM LA_@(pre)SPSV_ET_EXAMPLE
106 @type sherm dherm
107   WRITE ( NOUT, * )'Details of LA_@(pre)HPSV LAPACK Subroutine Results.'
108   WRITE ( NOUT, * )
109!
110   WRITE(NOUT,*)
111   WRITE(NOUT,*) 'CALL LA_HPSV(A, B )'
112   A=AA; B=BB
113   IF (NRHS .GT. 1) THEN
114      CALL LA_HPSV( A, B )
115   ELSE
116      CALL LA_HPSV( A, B(1:N,1) )
117   END IF
118   WRITE(NOUT,*)'   B - the solution vectors computed by LA_HPSV:'
119   DO J = 1, NRHS
120      WRITE (NOUT,FMT) B(:,J)
121   END DO
122!
123   WRITE(NOUT,*)
124   WRITE(NOUT,*) 'CALL LA_HPSV( A, B, ''L'' )'
125   DO I = 1,N
126      DO J = I, N
127         A(J+(I-1)*(2*N-I)/2) = AA(I+J*(J-1)/2)
128      ENDDO
129   ENDDO
130   B = BB
131   CALL LA_HPSV( A, B, 'L' )
132   WRITE(NOUT,*)'   B - the solution vectors computed by LA_HPSV:'
133   DO J = 1, NRHS
134      WRITE (NOUT,FMT) B(:,J)
135   END DO
136   WRITE(NOUT,*)
137   WRITE(NOUT,*) 'CALL LA_HPSV( A, B(1:N,1), IPIV=PIV, INFO=FAIL )'
138   A=AA; B=BB
139   CALL LA_HPSV( A, B(1:N,1), IPIV=PIV, INFO=FAIL )
140   WRITE(NOUT,*)'B - the solution vectors computed by LA_HPSV, INFO = ', FAIL
141   WRITE (NOUT,FMT) B(1:N,1)
142   WRITE (NOUT,*) 'Pivots: ', PIV
143!
144END PROGRAM LA_@(pre)HPSV_ET_EXAMPLE
145 @type !
146