1 SUBROUTINE pzunmql( SIDE, TRANS, M, N, K, A, IA, JA, DESCA, TAU,
2 $ C, IC, JC, DESCC, WORK, LWORK, INFO )
11 INTEGER IA, IC, INFO, JA, JC, K, LWORK, M, N
14 INTEGER DESCA( * ), DESCC( * )
15 COMPLEX*16 A( * ), C( * ), TAU( * ), WORK( * )
219 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
220 $ lld_, mb_, m_, nb_, n_, rsrc_
221 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
222 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
223 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
226 LOGICAL LEFT, LQUERY, NOTRAN
227 CHARACTER COLBTOP, ROWBTOP
228 INTEGER IAROW, ICCOL, ICOFFC, ICROW, ICTXT, IINFO, IPW,
229 $ iroffa, iroffc, j, j1, j2, j3, jb, lcm, lcmq,
230 $ lwmin, mi, mpc0, mycol, myrow, ni, npa0, npcol,
234 INTEGER IDUM1( 4 ), IDUM2( 4 )
243 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
244 EXTERNAL iceil, ilcm, indxg2p, lsame, numroc
247 INTRINSIC dble, dcmplx, ichar,
max,
min, mod
253 ictxt = desca( ctxt_ )
254 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
259 IF( nprow.EQ.-1 )
THEN
262 left = lsame( side,
'L' )
263 notran = lsame( trans,
'N' )
269 CALL chk1mat( m, 3, k, 5, ia, ja, desca, 9, info )
272 CALL chk1mat( n, 4, k, 5, ia, ja, desca, 9, info )
274 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 14, info )
276 iroffa = mod( ia-1, desca( mb_ ) )
277 iroffc = mod( ic-1, descc( mb_ ) )
278 icoffc = mod( jc-1, descc( nb_ ) )
279 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
281 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
283 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
285 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
286 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
289 lwmin =
max( ( desca( nb_ ) * ( desca( nb_ ) - 1 ) ) / 2,
290 $ ( mpc0 + nqc0 ) * desca( nb_ ) ) +
291 $ desca( nb_ ) * desca( nb_ )
293 npa0 = numroc( n+iroffa, desca( mb_ ), myrow, iarow,
295 lcm = ilcm( nprow, npcol )
297 lwmin =
max( ( desca( nb_ ) * ( desca( nb_ ) - 1 ) )
298 $ / 2, ( nqc0 +
max( npa0 + numroc( numroc(
299 $ n+icoffc, desca( nb_ ), 0, 0, npcol ),
300 $ desca( nb_ ), 0, 0, lcmq ), mpc0 ) ) *
301 $ desca( nb_ ) ) + desca( nb_ ) * desca( nb_ )
304 work( 1 ) = dcmplx( dble( lwmin ) )
305 lquery = ( lwork.EQ.-1 )
306 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
308 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'C' ) )
THEN
310 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
312 ELSE IF( .NOT.left .AND. desca( mb_ ).NE.descc( nb_ ) )
THEN
314 ELSE IF( left .AND. iroffa.NE.iroffc )
THEN
316 ELSE IF( left .AND. iarow.NE.icrow )
THEN
318 ELSE IF( .NOT.left .AND. iroffa.NE.icoffc )
THEN
320 ELSE IF( left .AND. desca( mb_ ).NE.descc( mb_ ) )
THEN
322 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
324 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
330 idum1( 1 ) = ichar(
'L' )
332 idum1( 1 ) = ichar(
'R' )
336 idum1( 2 ) = ichar(
'N' )
338 idum1( 2 ) = ichar(
'C' )
343 IF( lwork.EQ.-1 )
THEN
350 CALL pchk2mat( m, 3, k, 5, ia, ja, desca, 9, m, 3, n, 4, ic,
351 $ jc, descc, 14, 4, idum1, idum2, info )
353 CALL pchk2mat( n, 4, k, 5, ia, ja, desca, 9, m, 3, n, 4, ic,
354 $ jc, descc, 14, 4, idum1, idum2, info )
359 CALL pxerbla( ictxt,
'PZUNMQL', -info )
361 ELSE IF( lquery )
THEN
367 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
370 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
371 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
373 IF( ( left .AND. notran ) .OR.
374 $ ( .NOT.left .AND. .NOT.notran ) )
THEN
375 j1 =
min( iceil( ja, desca( nb_ ) )*desca( nb_ ), ja+k-1 ) + 1
379 j1 =
max( ( (ja+k-2) / desca( nb_ ) ) * desca( nb_ ) + 1, ja )
380 j2 =
min( iceil( ja, desca( nb_ ) )*desca( nb_ ), ja+k-1 ) + 1
387 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
389 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'D-ring' )
391 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
398 IF( ( left .AND. notran ) .OR.
399 $ ( .NOT.left .AND. .NOT.notran ) )
THEN
406 CALL pzunm2l( side, trans, mi, ni, jb, a, ia, ja, desca, tau,
407 $ c, ic, jc, descc, work, lwork, iinfo )
410 ipw = desca( nb_ ) * desca( nb_ ) + 1
412 jb =
min( desca( nb_ ), k-j+ja )
417 CALL pzlarft(
'Backward',
'Columnwise', nq-k+j+jb-ja, jb,
418 $ a, ia, j, desca, tau, work, work( ipw ) )
423 mi = m - k + j + jb - ja
428 ni = n - k + j + jb - ja
433 CALL pzlarfb( side, trans,
'Backward',
'Columnwise', mi, ni,
434 $ jb, a, ia, j, desca, work, c, ic, jc, descc,
438 IF( ( left .AND. .NOT.notran ) .OR.
439 $ ( .NOT.left .AND. notran ) )
THEN
446 CALL pzunm2l( side, trans, mi, ni, jb, a, ia, ja, desca, tau,
447 $ c, ic, jc, descc, work, lwork, iinfo )
450 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
451 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
453 work( 1 ) = dcmplx( dble( lwmin ) )