1 SUBROUTINE pzggqrf( N, M, P, 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*16 A( * ), B( * ), TAUA( * ), TAUB( * ), WORK( * )
256 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
257 $ lld_, mb_, m_, nb_, n_, rsrc_
258 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
259 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
260 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
264 INTEGER IACOL, IAROW, IBCOL, IBROW, ICOFFA, ICOFFB,
265 $ ictxt, iroffa, iroffb, lwmin, mqa0, mycol,
266 $ myrow, npa0, npb0, npcol, nprow, pqb0
273 INTEGER IDUM1( 1 ), IDUM2( 1 )
276 INTEGER INDXG2P, NUMROC
277 EXTERNAL indxg2p, numroc
280 INTRINSIC dble, dcmplx, int,
max,
min, mod
286 ictxt = desca( ctxt_ )
287 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
292 IF( nprow.EQ.-1 )
THEN
295 CALL chk1mat( n, 1, m, 2, ia, ja, desca, 7, info )
296 CALL chk1mat( n, 1, p, 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 npa0 = numroc( n+iroffa, desca( mb_ ), myrow, iarow, nprow )
311 mqa0 = numroc( m+icoffa, desca( nb_ ), mycol, iacol, npcol )
312 npb0 = numroc( n+iroffb, descb( mb_ ), myrow, ibrow, nprow )
313 pqb0 = numroc( p+icoffb, descb( nb_ ), mycol, ibcol, npcol )
314 lwmin =
max( desca( nb_ ) * ( npa0 + mqa0 + desca( nb_ ) ),
315 $
max(
max( ( desca( nb_ )*( desca( nb_ ) - 1 ) ) / 2,
316 $ ( pqb0 + npb0 ) * desca( nb_ ) ) +
317 $ desca( nb_ ) * desca( nb_ ),
318 $ descb( mb_ ) * ( npb0 + pqb0 + descb( mb_ ) ) ) )
320 work( 1 ) = dcmplx( dble( lwmin ) )
321 lquery = ( lwork.EQ.-1 )
322 IF( iarow.NE.ibrow .OR. iroffa.NE.iroffb )
THEN
324 ELSE IF( desca( mb_ ).NE.descb( mb_ ) )
THEN
326 ELSE IF( ictxt.NE.descb( ctxt_ ) )
THEN
328 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
338 CALL pchk2mat( n, 1, m, 2, ia, ja, desca, 7, n, 1, p, 3, ib,
339 $ jb, descb, 12, 1, idum1, idum2, info )
343 CALL pxerbla( ictxt,
'PZGGQRF', -info )
345 ELSE IF( lquery )
THEN
351 CALL pzgeqrf( n, m, a, ia, ja, desca, taua, work, lwork, info )
352 lwmin = int( work( 1 ) )
356 CALL pzunmqr(
'Left',
'Conjugate Transpose', n, p,
min( n, m ), a,
357 $ ia, ja, desca, taua, b, ib, jb, descb, work, lwork,
359 lwmin =
min( lwmin, int( work( 1 ) ) )
363 CALL pzgerqf( n, p, b, ib, jb, descb, taub, work, lwork, info )
364 work( 1 ) = dcmplx( dble(
max( lwmin, int( work( 1 ) ) ) ) )