1 SUBROUTINE pdorm2r( 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 DOUBLE PRECISION 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.0d+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,
chk1mat, dgebr2d,
228 $ dgebs2d, dgerv2d, dgesd2d, dscal,
230 $ pb_topget, pb_topset,
pxerbla
234 INTEGER ILCM, INDXG2P, NUMROC
235 EXTERNAL ilcm, indxg2p, lsame, numroc
238 INTRINSIC dble,
max, mod
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 ) = dble( 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,
'T' ) )
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,
'PDORM2R', -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
338 ajj = one - tau( jj )
339 CALL dgebs2d( ictxt,
'Rowwise',
' ', 1, 1, ajj, 1 )
340 CALL dscal( nq-jcc+1, ajj,
341 $ c( icc+(jcc-1)*descc( lld_ ) ),
344 CALL dgebr2d( ictxt,
'Rowwise',
' ', 1, 1, ajj, 1,
346 CALL dscal( nq-jcc+1, ajj,
347 $ c( icc+(jcc-1)*descc( lld_ ) ),
352 IF( mycol.EQ.iacol )
THEN
353 ajj = one - tau( jj )
356 IF( iacol.NE.iccol )
THEN
358 $
CALL dgesd2d( ictxt, 1, 1, ajj, 1, myrow, iccol )
360 $
CALL dgerv2d( ictxt, 1, 1, ajj, 1, myrow, iacol )
363 IF( mycol.EQ.iccol )
THEN
364 mp = numroc( ic+m-1, descc( mb_ ), myrow, descc( rsrc_ ),
366 CALL dscal( mp-icc+1, ajj, c( icc+(jcc-1)*
367 $ descc( lld_ ) ), 1 )
374 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
375 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
377 IF( left .AND. .NOT.notran .OR. .NOT.left .AND. notran )
THEN
391 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'D-ring' )
393 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
395 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
418 CALL pdelset2( ajj, a, ia+j-ja, j, desca, one )
419 CALL pdlarf( side, mi, ni, a, ia+j-ja, j, desca, 1, tau, c,
420 $ icc, jcc, descc, work )
421 CALL pdelset( a, ia+j-ja, j, desca, ajj )
425 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
426 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
430 work( 1 ) = dble( lwmin )