1 SUBROUTINE psormrz( SIDE, TRANS, M, N, K, L, A, IA, JA, DESCA,
2 $ TAU, C, IC, JC, DESCC, WORK, LWORK, INFO )
11 INTEGER IA, IC, INFO, JA, JC, K, L, LWORK, M, N
14 INTEGER DESCA( * ), DESCC( * )
15 REAL A( * ), C( * ), TAU( * ), WORK( * )
224 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
225 $ lld_, mb_, m_, nb_, n_, rsrc_
226 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
227 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
228 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
231 LOGICAL LEFT, LQUERY, NOTRAN
232 CHARACTER COLBTOP, ROWBTOP, TRANST
233 INTEGER I, I1, I2, I3, IACOL, IB, ICC, ICCOL, ICOFFA,
234 $ icoffc, icrow, ictxt, iinfo, ipw, iroffc, jaa,
235 $ jcc, lcm, lcmp, lwmin, mi, mpc0, mqa0, mycol,
236 $ myrow, ni, npcol, nprow, nq, nqc0
239 INTEGER IDUM1( 5 ), IDUM2( 5 )
247 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
248 EXTERNAL iceil, ilcm, indxg2p, lsame, numroc
251 INTRINSIC ichar,
max,
min, mod, real
257 ictxt = desca( ctxt_ )
258 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
263 IF( nprow.EQ.-1 )
THEN
266 left = lsame( side,
'L' )
267 notran = lsame( trans,
'N' )
273 CALL chk1mat( k, 5, m, 3, ia, ja, desca, 10, info )
276 CALL chk1mat( k, 5, n, 4, ia, ja, desca, 10, info )
278 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 15, info )
280 icoffa = mod( ja-1, desca( nb_ ) )
281 iroffc = mod( ic-1, descc( mb_ ) )
282 icoffc = mod( jc-1, descc( nb_ ) )
283 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
285 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
287 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
289 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
290 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
293 mqa0 = numroc( m+icoffa, desca( nb_ ), mycol, iacol,
295 lcm = ilcm( nprow, npcol )
297 lwmin =
max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) )
298 $ / 2, ( mpc0 +
max( mqa0 + numroc( numroc(
299 $ m+iroffc, desca( mb_ ), 0, 0, nprow ),
300 $ desca( mb_ ), 0, 0, lcmp ), nqc0 ) ) *
301 $ desca( mb_ ) ) + desca( mb_ ) * desca( mb_ )
303 lwmin =
max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) ) / 2,
304 $ ( mpc0 + nqc0 ) * desca( mb_ ) ) +
305 $ desca( mb_ ) * desca( mb_ )
308 work( 1 ) = real( lwmin )
309 lquery = ( lwork.EQ.-1 )
310 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
312 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) )
THEN
314 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
316 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
318 ELSE IF( left .AND. desca( nb_ ).NE.descc( mb_ ) )
THEN
320 ELSE IF( left .AND. icoffa.NE.iroffc )
THEN
322 ELSE IF( .NOT.left .AND. icoffa.NE.icoffc )
THEN
324 ELSE IF( .NOT.left .AND. iacol.NE.iccol )
THEN
326 ELSE IF( .NOT.left .AND. desca( nb_ ).NE.descc( nb_ ) )
THEN
328 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
330 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
335 idum1( 1 ) = ichar(
'L' )
337 idum1( 1 ) = ichar(
'R' )
341 idum1( 2 ) = ichar(
'N' )
343 idum1( 2 ) = ichar(
'T' )
350 IF( lwork.EQ.-1 )
THEN
357 CALL pchk2mat( k, 5, m, 3, ia, ja, desca, 10, m, 3, n, 4,
358 $ ic, jc, descc, 15, 5, idum1, idum2, info )
360 CALL pchk2mat( k, 5, n, 4, ia, ja, desca, 10, m, 3, n, 4,
361 $ ic, jc, descc, 15, 5, idum1, idum2, info )
366 CALL pxerbla( ictxt,
'PSORMRZ', -info )
368 ELSE IF( lquery )
THEN
374 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
377 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
378 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
380 IF( ( left .AND. .NOT.notran ) .OR.
381 $ ( .NOT.left .AND. notran ) )
THEN
382 i1 =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
387 i1 =
max( ( (ia+k-2) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
388 i2 =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
401 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
403 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
405 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'D-ring' )
415 IF( ( left .AND. .NOT.notran ) .OR.
416 $ ( .NOT.left .AND. notran ) )
THEN
423 CALL psormr3( side, trans, mi, ni, ib, l, a, ia, ja, desca,
424 $ tau, c, ic, jc, descc, work, lwork, iinfo )
427 ipw = desca( mb_ )*desca( mb_ ) + 1
429 ib =
min( desca( mb_ ), k-i+ia )
434 CALL pslarzt(
'Backward',
'Rowwise', l, ib, a, i, jaa, desca,
435 $ tau, work, work( ipw ) )
452 CALL pslarzb( side, transt,
'Backward',
'Rowwise', mi, ni, ib,
453 $ l, a, i, jaa, desca, work, c, icc, jcc, descc,
457 IF( ( left .AND. .NOT.notran ) .OR.
458 $ ( .NOT.left .AND. notran ) )
THEN
465 CALL psormr3( side, trans, mi, ni, ib, l, a, ia, ja, desca,
466 $ tau, c, ic, jc, descc, work, lwork, iinfo )
469 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
470 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
472 work( 1 ) = real( lwmin )