4
5
6
7
8
9
10
11
12 CHARACTER SYMM, TRANS, UPLO
13 INTEGER BWL, BWU, IA, IASEED, IBSEED,
14 $ IX, JA, JX, N, NRHS, WORKSIZ
15 DOUBLE PRECISION ANORM, RESID
16
17
18 INTEGER DESCA( * ), DESCX( * )
19 DOUBLE PRECISION A( * ), WORK( * ), X( * )
20
21 LOGICAL LSAME
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 DOUBLE PRECISION ZERO, ONE
165 parameter( one = 1.0d+0, zero = 0.0d+0 )
166 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
167 $ LLD_, MB_, M_, NB_, N_, RSRC_
168 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
169 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
170 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
171 INTEGER INT_ONE
172 parameter( int_one = 1 )
173
174
175 INTEGER IACOL, IAROW, ICTXT,
176 $ IIA, IIX, IPB, IPW,
177 $ IXCOL, IXROW, J, JJA, JJX, LDA,
178 $ MYCOL, MYROW, NB, NP, NPCOL, NPROW, NQ
179 INTEGER I, START
180 INTEGER BW, INFO, IPPRODUCT, WORK_MIN
181 DOUBLE PRECISION DIVISOR, EPS, RESID1, NORMX
182
183
184
185
186 EXTERNAL blacs_gridinfo, dgamx2d, dgebr2d,
187 $ dgebs2d, dgemm, dgerv2d, dgesd2d,
189
190
191 INTEGER IDAMAX, NUMROC
192 DOUBLE PRECISION PDLAMCH
194
195
196 INTRINSIC abs, dble,
max,
min, mod
197
198
199
200
201
202 ictxt = desca( ctxt_ )
203 nb = desca( nb_ )
204
205 IF(
lsame( symm,
'S' ) )
THEN
206 bw = bwl
207 start = 1
208 work_min =
max(5,nb)+2*nb
209 ELSE
211 IF(
lsame( uplo,
'D' ))
THEN
212 start = 1
213 ELSE
214 start = 2
215 ENDIF
216 work_min =
max(5,nb)+2*nb
217 ENDIF
218
219 IF ( worksiz .LT. work_min ) THEN
220 CALL pxerbla( ictxt,
'PDTLASCHK', -18 )
221 RETURN
222 END IF
223
224 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
225
227 resid = 0.0d+0
228 divisor = anorm * eps * dble( n )
229
230 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
231 $ iarow, iacol )
232 CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol, iix, jjx,
233 $ ixrow, ixcol )
234 np =
numroc( (3), desca( mb_ ), myrow, 0, nprow )
235 nq =
numroc( n, desca( nb_ ), mycol, 0, npcol )
236
237 ipb = 1
238 ipproduct = 1 + desca( nb_ )
239 ipw = 1 + 2*desca( nb_ )
240
241 lda = desca( lld_ )
242
243
244
245 IF(
lsame( symm,
'S' ))
THEN
246 CALL pdbmatgen( ictxt, uplo,
'D', bw, bw, n, bw+1,
247 $ desca( nb_ ), a, desca( lld_ ), 0, 0,
248 $ iaseed, myrow, mycol, nprow, npcol )
249 ELSE
250
251 CALL pdbmatgen( ictxt,
'N', uplo, bwl, bwu, n,
252 $ desca( mb_ ), desca( nb_ ), a,
253 $ desca( lld_ ), 0, 0, iaseed, myrow,
254 $ mycol, nprow, npcol )
255 ENDIF
256
257
258
259
260
261
262 IF( mycol.GT.0 ) THEN
263 CALL dgesd2d( ictxt, 1, 1, a( start+2), lda,
264 $ myrow, mycol-1 )
265 ENDIF
266
267 IF( mycol.LT.npcol-1 ) THEN
268 CALL dgesd2d( ictxt, 1, 1,
269 $ a( start+( desca( nb_ )-1 )*lda ),
270 $ lda, myrow, mycol+1 )
271 ENDIF
272
273
274
275 DO 220 i=0,desca( nb_ )-1
276 a( start+2+(i)*lda ) = a( start+2+(i+1)*lda )
277 220 CONTINUE
278
279 DO 230 i=desca( nb_ )-1,0,-1
280 a( start+(i+1)*lda ) = a( start+(i)*lda )
281 230 CONTINUE
282
283
284
285 IF( mycol.LT.npcol-1 ) THEN
286 CALL dgerv2d( ictxt, 1, 1,
287 $ a( start+2+( desca( nb_ )-1 )*lda ),
288 $ lda, myrow, mycol+1 )
289 ENDIF
290
291 IF( mycol.GT.0 ) THEN
292 CALL dgerv2d( ictxt, 1, 1, a( start), lda,
293 $ myrow, mycol-1 )
294 ENDIF
295
296
297
298 resid = 0.0
299
300 DO 40 j = 1, nrhs
301
302
303
304
305 CALL pdgbdcmv( bwl+bwu+1, bwl, bwu, trans, n, a, 1, desca,
306 $ 1, x( 1 + (j-1)*descx( lld_ )), 1, descx,
307 $ work( ipproduct ), work( ipw ),
308 $ (int_one+2)*int_one, info )
309
310
311
312
313 CALL pdmatgen( descx( ctxt_ ),
'No',
'No', descx( m_ ),
314 $ descx( n_ ), descx( mb_ ), descx( nb_ ),
315 $ work( ipb ), descx( lld_ ), descx( rsrc_ ),
316 $ descx( csrc_ ), ibseed, 0, nq, j-1, 1, mycol,
317 $ myrow, npcol, nprow )
318
319
320
321 CALL pdaxpy( n, -one, work( ipproduct ), 1, 1, descx, 1,
322 $ work( ipb ), 1, 1, descx, 1 )
323
324 CALL pdnrm2( n, normx,
325 $ x, 1, j, descx, 1 )
326
327 CALL pdnrm2( n, resid1,
328 $ work( ipb ), 1, 1, descx, 1 )
329
330
331
332
333 resid1 = resid1 / ( normx*divisor )
334
335 resid =
max( resid, resid1 )
336
337 40 CONTINUE
338
339 RETURN
340
341
342
subroutine pdmatgen(ictxt, aform, diag, m, n, mb, nb, a, lda, iarow, iacol, iseed, iroff, irnum, icoff, icnum, myrow, mycol, nprow, npcol)
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pbdtran(icontxt, adist, trans, m, n, nb, a, lda, beta, c, ldc, iarow, iacol, icrow, iccol, work)
double precision function pdlamch(ictxt, cmach)
subroutine pdbmatgen(ictxt, aform, aform2, bwl, bwu, n, mb, nb, a, lda, iarow, iacol, iseed, myrow, mycol, nprow, npcol)
subroutine pdgbdcmv(ldbw, bwl, bwu, trans, n, a, ja, desca, nrhs, b, ib, descb, x, work, lwork, info)
subroutine pxerbla(ictxt, srname, info)