1 SUBROUTINE pcunm2r( 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 IACOL, IAROW, ICCOL, ICOFFC, ICROW, ICTXT, ICC,
221 $ ii, iroffa, iroffc, j, j1, j2, j3, jcc, jj,
222 $ lcm, lcmq, lwmin, mi, mp, mpc0, mycol, myrow,
223 $ ni, npcol, nprow, nq, nqc0
227 EXTERNAL blacs_abort, blacs_gridinfo, cgebr2d,
228 $ cgebs2d, cgerv2d, cgesd2d,
chk1mat,
234 INTEGER ILCM, INDXG2P, NUMROC
235 EXTERNAL ilcm, indxg2p, lsame, numroc
238 INTRINSIC cmplx, conjg,
max, mod, real
244 ictxt = desca( ctxt_ )
245 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
250 IF( nprow.EQ.-1 )
THEN
253 left = lsame( side,
'L' )
254 notran = lsame( trans,
'N' )
260 CALL chk1mat( m, 3, k, 5, ia, ja, desca, 9, info )
263 CALL chk1mat( n, 4, k, 5, ia, ja, desca, 9, info )
265 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 14, info )
267 iroffa = mod( ia-1, desca( mb_ ) )
268 iroffc = mod( ic-1, descc( mb_ ) )
269 icoffc = mod( jc-1, descc( nb_ ) )
270 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
272 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
274 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
276 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
277 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
280 lwmin = mpc0 +
max( 1, nqc0 )
282 lcm = ilcm( nprow, npcol )
284 lwmin = nqc0 +
max(
max( 1, mpc0 ), numroc( numroc(
285 $ n+icoffc, desca( nb_ ), 0, 0, npcol ),
286 $ desca( nb_ ), 0, 0, lcmq ) )
289 work( 1 ) =
cmplx( real( lwmin ) )
290 lquery = ( lwork.EQ.-1 )
291 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
293 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'C' ) )
THEN
295 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
297 ELSE IF( .NOT.left .AND. desca( mb_ ).NE.descc( nb_ ) )
THEN
299 ELSE IF( left .AND. iroffa.NE.iroffc )
THEN
301 ELSE IF( left .AND. iarow.NE.icrow )
THEN
303 ELSE IF( .NOT.left .AND. iroffa.NE.icoffc )
THEN
305 ELSE IF( left .AND. desca( mb_ ).NE.descc( mb_ ) )
THEN
307 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
309 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
316 CALL pxerbla( ictxt,
'PCUNM2R', -info )
317 CALL blacs_abort( ictxt, 1 )
319 ELSE IF( lquery )
THEN
325 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
328 IF( desca( m_ ).EQ.1 )
THEN
329 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii,
331 CALL infog2l( ic, jc, descc, nprow, npcol, myrow, mycol, icc,
332 $ jcc, icrow, iccol )
334 IF( myrow.EQ.iarow )
THEN
335 nq = numroc( jc+n-1, descc( nb_ ), mycol, descc( csrc_ ),
337 IF( mycol.EQ.iacol )
THEN
339 ajj = one - tau( jj )
341 ajj = one - conjg( tau( jj ) )
343 CALL cgebs2d( ictxt,
'Rowwise',
' ', 1, 1, ajj, 1 )
344 CALL cscal( nq-jcc+1, ajj,
345 $ c( icc+(jcc-1)*descc( lld_ ) ),
348 CALL cgebr2d( ictxt,
'Rowwise',
' ', 1, 1, ajj, 1,
350 CALL cscal( nq-jcc+1, ajj,
351 $ c( icc+(jcc-1)*descc( lld_ ) ),
356 IF( mycol.EQ.iacol )
THEN
358 ajj = one - tau( jj )
360 ajj = one - conjg( tau( jj ) )
364 IF( iacol.NE.iccol )
THEN
366 $
CALL cgesd2d( ictxt, 1, 1, ajj, 1, myrow, iccol )
368 $
CALL cgerv2d( ictxt, 1, 1, ajj, 1, myrow, iacol )
371 IF( mycol.EQ.iccol )
THEN
372 mp = numroc( ic+m-1, descc( mb_ ), myrow, descc( rsrc_ ),
374 CALL cscal( mp-icc+1, ajj, c( icc+(jcc-1)*
375 $ descc( lld_ ) ), 1 )
382 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
383 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
385 IF( left .AND. .NOT.notran .OR. .NOT.left .AND. notran )
THEN
399 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'D-ring' )
401 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
403 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
426 CALL pcelset2( ajj, a, ia+j-ja, j, desca, one )
428 CALL pclarf( side, mi, ni, a, ia+j-ja, j, desca, 1, tau,
429 $ c, icc, jcc, descc, work )
431 CALL pclarfc( side, mi, ni, a, ia+j-ja, j, desca, 1, tau,
432 $ c, icc, jcc, descc, work )
434 CALL pcelset( a, ia+j-ja, j, desca, ajj )
438 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
439 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
443 work( 1 ) =
cmplx( real( lwmin ) )