3
4
5
6
7
8
9
10 INTEGER IA, INFO, JA, LWORK, M, N
11
12
13 INTEGER DESCA( * )
14 REAL D( * ), E( * )
15 COMPLEX A( * ), TAUP( * ), TAUQ( * ), WORK( * )
16
17
18
19
20
21
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
242 $ LLD_, MB_, M_, NB_, N_, RSRC_
243 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
244 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
245 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
246 COMPLEX ONE
247 parameter( one = ( 1.0e+0, 0.0e+0 ) )
248
249
250 LOGICAL LQUERY
251 CHARACTER COLCTOP, ROWCTOP
252 INTEGER I, IACOL, IAROW, ICTXT, IINFO, IOFF, IPW, IPY,
253 $ IW, J, JB, JS, JW, K, L, LWMIN, MN, MP, MYCOL,
254 $ MYROW, NB, NPCOL, NPROW, NQ
255
256
257 INTEGER DESCWX( DLEN_ ), DESCWY( DLEN_ ), IDUM1( 1 ),
258 $ IDUM2( 1 )
259
260
263 $ pb_topget, pb_topset,
pxerbla
264
265
266 INTEGER INDXG2L, INDXG2P, NUMROC
268
269
271
272
273
274
275
276 ictxt = desca( ctxt_ )
277 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
278
279
280
281 info = 0
282 IF( nprow.EQ.-1 ) THEN
283 info = -(600+ctxt_)
284 ELSE
285 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
286 IF( info.EQ.0 ) THEN
287 nb = desca( mb_ )
288 ioff = mod( ia-1, desca( mb_ ) )
289 iarow =
indxg2p( ia, nb, myrow, desca( rsrc_ ), nprow )
290 iacol =
indxg2p( ja, nb, mycol, desca( csrc_ ), npcol )
291 mp =
numroc( m+ioff, nb, myrow, iarow, nprow )
292 nq =
numroc( n+ioff, nb, mycol, iacol, npcol )
293 lwmin = nb*( mp+nq+1 ) + nq
294
295 work( 1 ) =
cmplx( real( lwmin ) )
296 lquery = ( lwork.EQ.-1 )
297 IF( ioff.NE.mod( ja-1, desca( nb_ ) ) ) THEN
298 info = -5
299 ELSE IF( nb.NE.desca( nb_ ) ) THEN
300 info = -(600+nb_)
301 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery ) THEN
302 info = -12
303 END IF
304 END IF
305 IF( lquery ) THEN
306 idum1( 1 ) = -1
307 ELSE
308 idum1( 1 ) = 1
309 END IF
310 idum2( 1 ) = 12
311 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
312 $ info )
313 END IF
314
315 IF( info.LT.0 ) THEN
316 CALL pxerbla( ictxt,
'PCGEBRD', -info )
317 RETURN
318 ELSE IF( lquery ) THEN
319 RETURN
320 END IF
321
322
323
325 IF( mn.EQ.0 )
326 $ RETURN
327
328
329
330 CALL pb_topget( ictxt, 'Combine', 'Columnwise', colctop )
331 CALL pb_topget( ictxt, 'Combine', 'Rowwise', rowctop )
332 CALL pb_topset( ictxt, 'Combine', 'Columnwise', '1-tree' )
333 CALL pb_topset( ictxt, 'Combine', 'Rowwise', '1-tree' )
334
335 ipy = mp * nb + 1
336 ipw = nq * nb + ipy
337
338 CALL descset( descwx, m+ioff, nb, nb, nb, iarow, iacol, ictxt,
340 CALL descset( descwy, nb, n+ioff, nb, nb, iarow, iacol, ictxt,
341 $ nb )
342
343 mp =
numroc( m+ia-1, nb, myrow, desca( rsrc_ ), nprow )
344 nq =
numroc( n+ja-1, nb, mycol, desca( csrc_ ), npcol )
345 k = 1
346 jb = nb - ioff
347 iw = ioff + 1
348 jw = ioff + 1
349
350 DO 10 l = 1, mn+ioff-nb, nb
351 i = ia + k - 1
352 j = ja + k - 1
353
354
355
356
357
358 CALL pclabrd( m-k+1, n-k+1, jb, a, i, j, desca, d, e, tauq,
359 $ taup, work, iw, jw, descwx, work( ipy ), iw,
360 $ jw, descwy, work( ipw ) )
361
362
363
364
365 CALL pcgemm( 'No transpose', 'No transpose', m-k-jb+1,
366 $ n-k-jb+1, jb, -one, a, i+jb, j, desca,
367 $ work( ipy ), iw, jw+jb, descwy, one, a, i+jb,
368 $ j+jb, desca )
369 CALL pcgemm( 'No transpose', 'No transpose', m-k-jb+1,
370 $ n-k-jb+1, jb, -one, work, iw+jb, jw, descwx, a, i,
371 $ j+jb, desca, one, a, i+jb, j+jb, desca )
372
373
374
375 IF( m.GE.n ) THEN
376 js =
min(
indxg2l( i+jb-1, nb, 0, desca( rsrc_ ), nprow ),
377 $ mp )
378 IF( js.GT.0 )
379 $
CALL pcelset( a, i+jb-1, j+jb, desca,
cmplx( e( js ) ) )
380 ELSE
381 js =
min(
indxg2l( j+jb-1, nb, 0, desca( csrc_ ), npcol ),
382 $ nq )
383 IF( js.GT.0 )
384 $
CALL pcelset( a, i+jb, j+jb-1, desca,
cmplx( e( js ) ) )
385 END IF
386
387 k = k + jb
388 jb = nb
389 iw = 1
390 jw = 1
391 descwx( m_ ) = descwx( m_ ) - jb
392 descwx( rsrc_ ) = mod( descwx( rsrc_ ) + 1, nprow )
393 descwx( csrc_ ) = mod( descwx( csrc_ ) + 1, npcol )
394 descwy( n_ ) = descwy( n_ ) - jb
395 descwy( rsrc_ ) = mod( descwy( rsrc_ ) + 1, nprow )
396 descwy( csrc_ ) = mod( descwy( csrc_ ) + 1, npcol )
397
398 10 CONTINUE
399
400
401
402 CALL pcgebd2( m-k+1, n-k+1, a, ia+k-1, ja+k-1, desca, d, e, tauq,
403 $ taup, work, lwork, iinfo )
404
405 CALL pb_topset( ictxt, 'Combine', 'Columnwise', colctop )
406 CALL pb_topset( ictxt, 'Combine', 'Rowwise', rowctop )
407
408 work( 1 ) =
cmplx( real( lwmin ) )
409
410 RETURN
411
412
413
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
subroutine descset(desc, m, n, mb, nb, irsrc, icsrc, ictxt, lld)
integer function indxg2l(indxglob, nb, iproc, isrcproc, nprocs)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pcelset(a, ia, ja, desca, alpha)
subroutine pcgebd2(m, n, a, ia, ja, desca, d, e, tauq, taup, work, lwork, info)
subroutine pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
subroutine pclabrd(m, n, nb, a, ia, ja, desca, d, e, tauq, taup, x, ix, jx, descx, y, iy, jy, descy, work)
subroutine pxerbla(ictxt, srname, info)