1 SUBROUTINE pcunmr2( 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 A( * ), C( * ), TAU( * ), WORK( * )
209 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
210 $ lld_, mb_, m_, nb_, n_, rsrc_
211 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
212 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
213 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
215 parameter( one = ( 1.0e+0, 0.0e+0 ) )
218 LOGICAL LEFT, LQUERY, NOTRAN
219 CHARACTER COLBTOP, ROWBTOP
220 INTEGER I, I1, I2, I3, IACOL, ICCOL, ICOFFA, ICOFFC,
221 $ icrow, ictxt, iroffc, lcm, lcmp, lwmin, mi,
222 $ mpc0, mycol, myrow, ni, npcol, nprow, nq, nqc0
228 $ pb_topget, pb_topset,
pxerbla
232 INTEGER ILCM, INDXG2P, NUMROC
233 EXTERNAL ilcm, indxg2p, lsame, numroc
242 ictxt = desca( ctxt_ )
243 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
248 IF( nprow.EQ.-1 )
THEN
251 left = lsame( side,
'L' )
252 notran = lsame( trans,
'N' )
258 CALL chk1mat( k, 5, m, 3, ia, ja, desca, 9, info )
261 CALL chk1mat( k, 5, n, 4, ia, ja, desca, 9, info )
263 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 14, info )
265 icoffa = mod( ja-1, desca( nb_ ) )
266 iroffc = mod( ic-1, descc( mb_ ) )
267 icoffc = mod( jc-1, descc( nb_ ) )
268 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
270 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
272 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
274 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
275 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
278 lcm = ilcm( nprow, npcol )
280 lwmin = mpc0 +
max(
max( 1, nqc0 ), numroc( numroc(
281 $ m+iroffc, desca( mb_ ), 0, 0, nprow ),
282 $ desca( mb_ ), 0, 0, lcmp ) )
284 lwmin = nqc0 +
max( 1, mpc0 )
287 work( 1 ) =
cmplx( real( lwmin ) )
288 lquery = ( lwork.EQ.-1 )
289 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
291 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'C' ) )
THEN
293 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
295 ELSE IF( left .AND. desca( nb_ ).NE.descc( mb_ ) )
THEN
297 ELSE IF( left .AND. icoffa.NE.iroffc )
THEN
299 ELSE IF( .NOT.left .AND. icoffa.NE.icoffc )
THEN
301 ELSE IF( .NOT.left .AND. iacol.NE.iccol )
THEN
303 ELSE IF( .NOT.left .AND. desca( nb_ ).NE.descc( nb_ ) )
THEN
305 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
307 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
314 CALL pxerbla( ictxt,
'PCUNMR2', -info )
315 CALL blacs_abort( ictxt, 1 )
317 ELSE IF( lquery )
THEN
323 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
326 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
327 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
329 IF( ( left .AND. .NOT.notran .OR. .NOT.left .AND. notran ) )
THEN
343 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
345 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
347 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'D-ring' )
356 mi = m - k + i - ia + 1
361 ni = n - k + i - ia + 1
366 CALL pclacgv( nq-k+i-ia, a, i, ja, desca, desca( m_ ) )
367 CALL pcelset2( aii, a, i, ja+nq-k+i-ia, desca, one )
369 CALL pclarfc( side, mi, ni, a, i, ja, desca, desca( m_ ),
370 $ tau, c, ic, jc, descc, work )
372 CALL pclarf( side, mi, ni, a, i, ja, desca, desca( m_ ),
373 $ tau, c, ic, jc, descc, work )
375 CALL pcelset( a, i, ja+nq-k+i-ia, desca, aii )
376 CALL pclacgv( nq-k+i-ia, a, i, ja, desca, desca( m_ ) )
380 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
381 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
383 work( 1 ) =
cmplx( real( lwmin ) )