1 SUBROUTINE pdgebdrv( M, N, A, IA, JA, DESCA, D, E, TAUQ, TAUP,
10 INTEGER INFO, IA, JA, M, N
14 DOUBLE PRECISION A( * ), D( * ), E( * ), TAUP( * ), TAUQ( * ),
153 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
154 $ lld_, mb_, m_, nb_, n_, rsrc_
155 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
156 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
157 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
158 DOUBLE PRECISION EIGHT, ONE, ZERO
159 parameter( eight = 8.0d+0, one = 1.0d+0, zero = 0.0d+0 )
162 INTEGER I, IACOL, IAROW, ICTXT, IIA, IL, IPTP, IPTQ,
163 $ ipv, ipw, ipwk, ioff, iv, j, jb, jja, jl, jv,
164 $ k, mn, mp, mycol, myrow, nb, npcol, nprow, nq
165 DOUBLE PRECISION ADDBND, D1, D2, E1, E2
168 INTEGER DESCD( DLEN_ ), DESCE( DLEN_ ), DESCV( DLEN_ ),
177 INTEGER INDXG2P, NUMROC
178 DOUBLE PRECISION PDLAMCH
179 EXTERNAL indxg2p, numroc, pdlamch
182 INTRINSIC abs,
max,
min, mod
188 ictxt = desca( ctxt_ )
189 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
193 ioff = mod( ia-1, nb )
194 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
196 mp = numroc( m+ioff, nb, myrow, iarow, nprow )
197 nq = numroc( n+ioff, nb, mycol, iacol, npcol )
207 il =
max( ( (ia+mn-2) / nb )*nb + 1, ia )
208 jl =
max( ( (ja+mn-2) / nb )*nb + 1, ja )
209 iarow = indxg2p( il, nb, myrow, desca( rsrc_ ), nprow )
210 iacol = indxg2p( jl, nb, mycol, desca( csrc_ ), npcol )
211 CALL descset( descv, ia+m-il, nb, nb, nb, iarow, iacol, ictxt,
213 CALL descset( descw, nb, ja+n-jl, nb, nb, iarow, iacol, ictxt,
216 addbnd = eight * pdlamch( ictxt,
'eps' )
222 CALL descset( descd, 1, ja+mn-1, 1, desca( nb_ ), myrow,
223 $ desca( csrc_ ), desca( ctxt_ ), 1 )
224 CALL descset( desce, ia+mn-1, 1, desca( mb_ ), 1,
225 $ desca( rsrc_ ), mycol, desca( ctxt_ ),
233 CALL pdelget(
' ',
' ', d2, d, 1, ja+j, descd )
234 CALL pdelget(
'Columnwise',
' ', d1, a, ia+j, ja+j, desca )
235 IF( j.LT.(mn-1) )
THEN
236 CALL pdelget(
' ',
' ', e2, e, ia+j, 1, desce )
237 CALL pdelget(
'Rowwise',
' ', e1, a, ia+j, ja+j+1,
241 IF( ( abs( d1 - d2 ).GT.( abs( d2 ) * addbnd ) ) .OR.
242 $ ( abs( e1 - e2 ).GT.( abs( e2 ) * addbnd ) ) )
246 DO 20 j = jl, ja+nb-ioff, -nb
247 jb =
min( ja+n-j, nb )
253 CALL pdlarft(
'Forward',
'Columnwise', m-k+1, jb, a, i, j,
254 $ desca, tauq, work( iptq ), work( ipwk ) )
258 CALL pdlacpy(
'Lower', m-k+1, jb, a, i, j, desca,
259 $ work( ipv ), iv, jv, descv )
260 CALL pdlaset(
'Upper', m-k+1, jb, zero, one, work( ipv ),
265 CALL pdlaset(
'Lower', m-k, jb, zero, zero, a, i+1, j,
270 CALL pdlarft(
'Forward',
'Rowwise', n-k, jb, a, i, j+1,
271 $ desca, taup, work( iptp ), work( ipwk ) )
275 CALL pdlacpy(
'Upper', jb, n-k, a, i, j+1, desca,
276 $ work( ipw ), iv, jv+1, descw )
277 CALL pdlaset(
'Lower', jb, n-k, zero, one, work( ipw ), iv,
282 CALL pdlaset(
'Upper', jb, n-k-1, zero, zero, a, i, j+2,
287 CALL pdlarfb(
'Left',
'No transpose',
'Forward',
288 $
'Columnwise', m-k+1, n-k+1, jb, work( ipv ),
289 $ iv, jv, descv, work( iptq ), a, i, j, desca,
294 CALL pdlarfb(
'Right',
'Transpose',
'Forward',
'Rowwise',
295 $ m-k+1, n-k, jb, work( ipw ), iv, jv+1, descw,
296 $ work( iptp ), a, i, j+1, desca, work( ipwk ) )
298 descv( m_ ) = descv( m_ ) + nb
299 descv( rsrc_ ) = mod( descv( rsrc_ ) + nprow - 1, nprow )
300 descv( csrc_ ) = mod( descv( csrc_ ) + npcol - 1, npcol )
301 descw( n_ ) = descw( n_ ) + nb
302 descw( rsrc_ ) = descv( rsrc_ )
303 descw( csrc_ ) = descv( csrc_ )
309 jb =
min( n, nb - ioff )
315 CALL pdlarft(
'Forward',
'Columnwise', m, jb, a, ia, ja, desca,
316 $ tauq, work( iptq ), work( ipwk ) )
320 CALL pdlacpy(
'Lower', m, jb, a, ia, ja, desca, work( ipv ),
322 CALL pdlaset(
'Upper', m, jb, zero, one, work( ipv ), iv, jv,
327 CALL pdlaset(
'Lower', m-1, jb, zero, zero, a, ia+1, ja,
332 CALL pdlarft(
'Forward',
'Rowwise', n-1, jb, a, ia, ja+1,
333 $ desca, taup, work( iptp ), work( ipwk ) )
337 CALL pdlacpy(
'Upper', jb, n-1, a, ia, ja+1, desca,
338 $ work( ipw ), iv, jv+1, descw )
339 CALL pdlaset(
'Lower', jb, n-1, zero, one, work( ipw ), iv,
344 CALL pdlaset(
'Upper', jb, n-2, zero, zero, a, ia, ja+2,
349 CALL pdlarfb(
'Left',
'No transpose',
'Forward',
'Columnwise',
350 $ m, n, jb, work( ipv ), iv, jv, descv,
351 $ work( iptq ), a, ia, ja, desca, work( ipwk ) )
355 CALL pdlarfb(
'Right',
'Transpose',
'Forward',
'Rowwise', m,
356 $ n-1, jb, work( ipw ), iv, jv+1, descw,
357 $ work( iptp ), a, ia, ja+1, desca, work( ipwk ) )
361 CALL descset( descd, ia+mn-1, 1, desca( mb_ ), 1,
362 $ desca( rsrc_ ), mycol, desca( ctxt_ ),
364 CALL descset( desce, 1, ja+mn-2, 1, desca( nb_ ), myrow,
365 $ desca( csrc_ ), desca( ctxt_ ), 1 )
372 CALL pdelget(
' ',
' ', d2, d, ia+j, 1, descd )
373 CALL pdelget(
'Rowwise',
' ', d1, a, ia+j, ja+j, desca )
374 IF( j.LT.(mn-1) )
THEN
375 CALL pdelget(
' ',
' ', e2, e, 1, ja+j, desce )
376 CALL pdelget(
'Columnwise',
' ', e1, a, ia+j+1, ja+j,
380 IF( ( abs( d1 - d2 ).GT.( abs( d2 ) * addbnd ) ) .OR.
381 $ ( abs( e1 - e2 ).GT.( abs( e2 ) * addbnd ) ) )
385 DO 40 i = il, ia+nb-ioff, -nb
386 jb =
min( ia+m-i, nb )
392 CALL pdlarft(
'Forward',
'Columnwise', m-k, jb, a, i+1, j,
393 $ desca, tauq, work( iptq ), work( ipwk ) )
397 CALL pdlacpy(
'Lower', m-k, jb, a, i+1, j, desca,
398 $ work( ipv ), iv+1, jv, descv )
399 CALL pdlaset(
'Upper', m-k, jb, zero, one, work( ipv ),
404 CALL pdlaset(
'Lower', m-k-1, jb, zero, zero, a, i+2, j,
409 CALL pdlarft(
'Forward',
'Rowwise', n-k+1, jb, a, i, j,
410 $ desca, taup, work( iptp ), work( ipwk ) )
414 CALL pdlacpy(
'Upper', jb, n-k+1, a, i, j, desca,
415 $ work( ipw ), iv, jv, descw )
416 CALL pdlaset(
'Lower', jb, n-k+1, zero, one, work( ipw ),
421 CALL pdlaset(
'Upper', jb, n-k, zero, zero, a, i, j+1,
426 CALL pdlarfb(
'Left',
'No transpose',
'Forward',
427 $
'Columnwise', m-k, n-k+1, jb, work( ipv ),
428 $ iv+1, jv, descv, work( iptq ), a, i+1, j,
429 $ desca, work( ipwk ) )
433 CALL pdlarfb(
'Right',
'Transpose',
'Forward',
'Rowwise',
434 $ m-k+1, n-k+1, jb, work( ipw ), iv, jv, descw,
435 $ work( iptp ), a, i, j, desca, work( ipwk ) )
437 descv( m_ ) = descv( m_ ) + nb
438 descv( rsrc_ ) = mod( descv( rsrc_ ) + nprow - 1, nprow )
439 descv( csrc_ ) = mod( descv( csrc_ ) + npcol - 1, npcol )
440 descw( n_ ) = descw( n_ ) + nb
441 descw( rsrc_ ) = descv( rsrc_ )
442 descw( csrc_ ) = descv( csrc_ )
448 jb =
min( m, nb - ioff )
454 CALL pdlarft(
'Forward',
'Columnwise', m-1, jb, a, ia+1, ja,
455 $ desca, tauq, work( iptq ), work( ipwk ) )
459 CALL pdlacpy(
'Lower', m-1, jb, a, ia+1, ja, desca,
460 $ work( ipv ), iv+1, jv, descv )
461 CALL pdlaset(
'Upper', m-1, jb, zero, one, work( ipv ), iv+1,
466 CALL pdlaset(
'Lower', m-2, jb, zero, zero, a, ia+2, ja,
471 CALL pdlarft(
'Forward',
'Rowwise', n, jb, a, ia, ja, desca,
472 $ taup, work( iptp ), work( ipwk ) )
476 CALL pdlacpy(
'Upper', jb, n, a, ia, ja, desca, work( ipw ),
478 CALL pdlaset(
'Lower', jb, n, zero, one, work( ipw ), iv, jv,
483 CALL pdlaset(
'Upper', jb, n-1, zero, zero, a, ia, ja+1,
488 CALL pdlarfb(
'Left',
'No transpose',
'Forward',
'Columnwise',
489 $ m-1, n, jb, work( ipv ), iv+1, jv, descv,
490 $ work( iptq ), a, ia+1, ja, desca, work( ipwk ) )
494 CALL pdlarfb(
'Right',
'Transpose',
'Forward',
'Rowwise', m, n,
495 $ jb, work( ipw ), iv, jv, descw, work( iptp ),
496 $ a, ia, ja, desca, work( ipwk ) )
499 CALL igsum2d( ictxt,
'All',
' ', 1, 1, info, 1, -1, 0 )