1 SUBROUTINE pcgebd2( M, N, A, IA, JA, DESCA, D, E, TAUQ, TAUP,
10 INTEGER IA, INFO, JA, LWORK, M, N
15 COMPLEX A( * ), TAUP( * ), TAUQ( * ), WORK( * )
240 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
241 $ lld_, mb_, m_, nb_, n_, rsrc_
242 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
243 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
244 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
246 parameter( one = ( 1.0e+0, 0.0e+0 ),
247 $ zero = ( 0.0e+0, 0.0e+0 ) )
251 INTEGER I, IACOL, IAROW, ICOFFA, ICTXT, II, IROFFA, J,
252 $ jj, k, lwmin, mpa0, mycol, myrow, npcol, nprow,
257 INTEGER DESCD( DLEN_ ), DESCE( DLEN_ )
260 EXTERNAL blacs_abort, blacs_gridinfo, cgebr2d,
267 INTEGER INDXG2P, NUMROC
268 EXTERNAL indxg2p, numroc
277 ictxt = desca( ctxt_ )
278 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
283 IF( nprow.EQ.-1 )
THEN
286 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
288 iroffa = mod( ia-1, desca( mb_ ) )
289 icoffa = mod( ja-1, desca( nb_ ) )
290 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
292 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
294 mpa0 = numroc( m+iroffa, desca( mb_ ), myrow, iarow, nprow )
295 nqa0 = numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
296 lwmin =
max( mpa0, nqa0 )
298 work( 1 ) =
cmplx( real( lwmin ) )
299 lquery = ( lwork.EQ.-1 )
300 IF( iroffa.NE.icoffa )
THEN
302 ELSE IF( desca( mb_ ).NE.desca( nb_ ) )
THEN
304 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
311 CALL pxerbla( ictxt,
'PCGEBD2', -info )
312 CALL blacs_abort( ictxt, 1 )
314 ELSE IF( lquery )
THEN
318 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii, jj,
321 IF( m.EQ.1 .AND. n.EQ.1 )
THEN
322 IF( mycol.EQ.iacol )
THEN
323 IF( myrow.EQ.iarow )
THEN
324 i = ii+(jj-1)*desca( lld_ )
325 CALL clarfg( 1, a( i ), a( i ), 1, tauq( jj ) )
326 d( jj ) = real( a( i ) )
327 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, d( jj ),
329 CALL cgebs2d( ictxt,
'Columnwise',
' ', 1, 1, tauq( jj ),
332 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, d( jj ),
334 CALL cgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tauq( jj ),
349 CALL descset( descd, 1, ja+
min(m,n)-1, 1, desca( nb_ ), myrow,
350 $ desca( csrc_ ), desca( ctxt_ ), 1 )
351 CALL descset( desce, ia+
min(m,n)-1, 1, desca( mb_ ), 1,
352 $ desca( rsrc_ ), mycol, desca( ctxt_ ),
361 CALL pclarfg( m-k+1, alpha, i, j, a,
min( i+1, m+ia-1 ),
362 $ j, desca, 1, tauq )
363 CALL pselset( d, 1, j, descd, real( alpha ) )
364 CALL pcelset( a, i, j, desca, one )
368 CALL pclarfc(
'Left', m-k+1, n-k, a, i, j, desca, 1, tauq,
369 $ a, i, j+1, desca, work )
377 CALL pclacgv( n-k, a, i, j+1, desca, desca( m_ ) )
378 CALL pclarfg( n-k, alpha, i, j+1, a, i,
379 $
min( j+2, ja+n-1 ), desca, desca( m_ ),
381 CALL pselset( e, i, 1, desce, real( alpha ) )
382 CALL pcelset( a, i, j+1, desca, one )
386 CALL pclarf(
'Right', m-k, n-k, a, i, j+1, desca,
387 $ desca( m_ ), taup, a, i+1, j+1, desca,
389 CALL pcelset( a, i, j+1, desca,
cmplx( real( alpha ) ) )
390 CALL pclacgv( n-k, a, i, j+1, desca, desca( m_ ) )
392 CALL pcelset( taup, i, 1, desce, zero )
400 CALL descset( descd, ia+
min(m,n)-1, 1, desca( mb_ ), 1,
401 $ desca( rsrc_ ), mycol, desca( ctxt_ ),
403 CALL descset( desce, 1, ja+
min(m,n)-1, 1, desca( nb_ ), myrow,
404 $ desca( csrc_ ), desca( ctxt_ ), 1 )
412 CALL pclacgv( n-k+1, a, i, j, desca, desca( m_ ) )
413 CALL pclarfg( n-k+1, alpha, i, j, a, i,
414 $
min( j+1, ja+n-1 ), desca, desca( m_ ), taup )
415 CALL pselset( d, i, 1, descd, real( alpha ) )
416 CALL pcelset( a, i, j, desca, one )
420 CALL pclarf(
'Right', m-k, n-k+1, a, i, j, desca,
421 $ desca( m_ ), taup, a,
min( i+1, ia+m-1 ), j,
424 CALL pclacgv( n-k+1, a, i, j, desca, desca( m_ ) )
431 CALL pclarfg( m-k, alpha, i+1, j, a,
432 $
min( i+2, ia+m-1 ), j, desca, 1, tauq )
433 CALL pselset( e, 1, j, desce, real( alpha ) )
434 CALL pcelset( a, i+1, j, desca, one )
438 CALL pclarfc(
'Left', m-k, n-k, a, i+1, j, desca, 1,
439 $ tauq, a, i+1, j+1, desca, work )
440 CALL pcelset( a, i+1, j, desca,
cmplx( real( alpha ) ) )
442 CALL pcelset( tauq, 1, j, desce, zero )
447 work( 1 ) =
cmplx( real( lwmin ) )