1 SUBROUTINE psggrqf( 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 REAL A( * ), B( * ), TAUA( * ), TAUB( * ), WORK( * )
258 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
259 $ lld_, mb_, m_, nb_, n_, rsrc_
260 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
261 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
262 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
265 INTEGER IACOL, IAROW, IBCOL, IBROW, ICOFFA, ICOFFB,
266 $ ictxt, iroffa, iroffb, lwmin, mpa0, mycol,
267 $ myrow, npcol, nprow, nqa0, nqb0, ppb0
274 INTEGER IDUM1( 1 ), IDUM2( 1 )
277 INTEGER INDXG2P, NUMROC
278 EXTERNAL indxg2p, numroc
281 INTRINSIC int,
max,
min, mod, real
287 ictxt = desca( ctxt_ )
288 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
293 IF( nprow.EQ.-1 )
THEN
296 CALL chk1mat( m, 1, n, 3, ia, ja, desca, 7, info )
297 CALL chk1mat( p, 2, n, 3, ib, jb, descb, 12, info )
299 iroffa = mod( ia-1, desca( mb_ ) )
300 icoffa = mod( ja-1, desca( nb_ ) )
301 iroffb = mod( ib-1, descb( mb_ ) )
302 icoffb = mod( jb-1, descb( nb_ ) )
303 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
305 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
307 ibrow = indxg2p( ib, descb( mb_ ), myrow, descb( rsrc_ ),
309 ibcol = indxg2p( jb, descb( nb_ ), mycol, descb( csrc_ ),
311 mpa0 = numroc( m+iroffa, desca( mb_ ), myrow, iarow, nprow )
312 nqa0 = numroc( n+icoffa, desca( nb_ ), mycol, iacol, npcol )
313 ppb0 = numroc( p+iroffb, descb( mb_ ), myrow, ibrow, nprow )
314 nqb0 = numroc( n+icoffb, descb( nb_ ), mycol, ibcol, npcol )
315 lwmin =
max( desca( mb_ ) * ( mpa0 + nqa0 + desca( mb_ ) ),
316 $
max(
max( ( desca( mb_ )*( desca( mb_ ) - 1 ) ) / 2,
317 $ ( ppb0 + nqb0 ) * desca( mb_ ) ) +
318 $ desca( mb_ ) * desca( mb_ ),
319 $ descb( nb_ ) * ( ppb0 + nqb0 + descb( nb_ ) ) ) )
321 work( 1 ) = real( lwmin )
322 lquery = ( lwork.EQ.-1 )
323 IF( iacol.NE.ibcol .OR. icoffa.NE.icoffb )
THEN
325 ELSE IF( desca( nb_ ).NE.descb( nb_ ) )
THEN
327 ELSE IF( ictxt.NE.descb( ctxt_ ) )
THEN
329 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
333 IF( lwork.EQ.-1 )
THEN
339 CALL pchk2mat( m, 1, n, 3, ia, ja, desca, 7, p, 2, n, 3, ib,
340 $ jb, descb, 12, 1, idum1, idum2, info )
344 CALL pxerbla( ictxt,
'PSGGRQF', -info )
346 ELSE IF( lquery )
THEN
352 CALL psgerqf( m, n, a, ia, ja, desca, taua, work, lwork, info )
353 lwmin = int( work( 1 ) )
357 CALL psormrq(
'Right',
'Transpose', p, n,
min( m, n ), a,
358 $
max( ia, ia+m-n ), ja, desca, taua, b, ib, jb,
359 $ descb, work, lwork, info )
360 lwmin =
max( lwmin, int( work( 1 ) ) )
364 CALL psgeqrf( p, n, b, ib, jb, descb, taub, work, lwork, info )
365 work( 1 ) = real(
max( lwmin, int( work( 1 ) ) ) )