1 SUBROUTINE pcggrqf( M, P, N, A, IA, JA, DESCA, TAUA, B, IB, JB,
2 $ DESCB, TAUB, WORK, LWORK, INFO )
10 INTEGER IA, IB, INFO, JA, JB, LWORK, M, N, P
13 INTEGER DESCA( * ), DESCB( * )
14 COMPLEX A( * ), B( * ), TAUA( * ), TAUB( * ), WORK( * )
257 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
258 $ lld_, mb_, m_, nb_, n_, rsrc_
259 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
260 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
261 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
264 INTEGER IACOL, IAROW, IBCOL, IBROW, ICOFFA, ICOFFB,
265 $ ictxt, iroffa, iroffb, lwmin, mpa0, mycol,
266 $ myrow, npcol, nprow, nqa0, nqb0, ppb0
273 INTEGER IDUM1( 1 ), IDUM2( 1 )
276 INTEGER INDXG2P, NUMROC
277 EXTERNAL indxg2p, numroc
286 ictxt = desca( ctxt_ )
287 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
292 IF( nprow.EQ.-1 )
THEN
295 CALL chk1mat( m, 1, n, 3, ia, ja, desca, 7, info )
296 CALL chk1mat( p, 2, n, 3, ib, jb, descb, 12, info )
298 iroffa = mod( ia-1, desca( mb_ ) )
299 icoffa = mod( ja-1, desca( nb_ ) )
300 iroffb = mod( ib-1, descb( mb_ ) )
301 icoffb = mod( jb-1, descb( nb_ ) )
302 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
304 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
306 ibrow = indxg2p( ib, descb( mb_ ), myrow, descb( rsrc_ ),
308 ibcol = indxg2p( jb, descb( nb_ ), mycol, descb( csrc_ ),
310 mpa0 = numroc( m+iroffa, desca( mb_ ), myrow, iarow, nprow )
311 nqa0 = numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
312 ppb0 = numroc( p+iroffb, descb( mb_ ), myrow, ibrow, nprow )
313 nqb0 = numroc( n+icoffb, descb( nb_ ), mycol, ibcol, npcol )
314 lwmin =
max( desca( mb_ ) * ( mpa0 + nqa0 + desca( mb_ ) ),
315 $
max(
max( ( desca( mb_ )*( desca( mb_ ) - 1 ) ) / 2,
316 $ ( ppb0 + nqb0 ) * desca( mb_ ) ) +
317 $ desca( mb_ ) * desca( mb_ ),
318 $ descb( nb_ ) * ( ppb0 + nqb0 + descb( nb_ ) ) ) )
320 work( 1 ) =
cmplx( real( lwmin ) )
321 lquery = ( lwork.EQ.-1 )
322 IF( iacol.NE.ibcol .OR. icoffa.NE.icoffb )
THEN
324 ELSE IF( desca( nb_ ).NE.descb( nb_ ) )
THEN
326 ELSE IF( ictxt.NE.descb( ctxt_ ) )
THEN
328 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
332 IF( lwork.EQ.-1 )
THEN
338 CALL pchk2mat( m, 1, n, 3, ia, ja, desca, 7, p, 2, n, 3, ib,
339 $ jb, descb, 12, 1, idum1, idum2, info )
343 CALL pxerbla( ictxt,
'PCGGRQF', -info )
345 ELSE IF( lquery )
THEN
351 CALL pcgerqf( m, n, a, ia, ja, desca, taua, work, lwork, info )
352 lwmin = int( work( 1 ) )
356 CALL pcunmrq(
'Right',
'Conjugate Transpose', p, n,
min( m, n ),
357 $ a,
max( ia, ia+m-n ), ja, desca, taua, b, ib, jb,
358 $ descb, work, lwork, info )
359 lwmin =
max( lwmin, int( work( 1 ) ) )
363 CALL pcgeqrf( p, n, b, ib, jb, descb, taub, work, lwork, info )
364 work( 1 ) =
cmplx( real(
max( lwmin, int( work( 1 ) ) ) ) )