1 SUBROUTINE psormr2( 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 REAL 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 )
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
231 INTEGER ILCM, INDXG2P, NUMROC
232 EXTERNAL ilcm, indxg2p, lsame, numroc
235 INTRINSIC max, mod, real
241 ictxt = desca( ctxt_ )
242 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
247 IF( nprow.EQ.-1 )
THEN
250 left = lsame( side,
'L' )
251 notran = lsame( trans,
'N' )
257 CALL chk1mat( k, 5, m, 3, ia, ja, desca, 9, info )
260 CALL chk1mat( k, 5, n, 4, ia, ja, desca, 9, info )
262 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 14, info )
264 icoffa = mod( ja-1, desca( nb_ ) )
265 iroffc = mod( ic-1, descc( mb_ ) )
266 icoffc = mod( jc-1, descc( nb_ ) )
267 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
269 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
271 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
273 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
274 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
277 lcm = ilcm( nprow, npcol )
279 lwmin = mpc0 +
max(
max( 1, nqc0 ), numroc( numroc(
280 $ m+iroffc, desca( mb_ ), 0, 0, nprow ),
281 $ desca( mb_ ), 0, 0, lcmp ) )
283 lwmin = nqc0 +
max( 1, mpc0 )
286 work( 1 ) = real( lwmin )
287 lquery = ( lwork.EQ.-1 )
288 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
290 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) )
THEN
292 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
294 ELSE IF( left .AND. desca( nb_ ).NE.descc( mb_ ) )
THEN
296 ELSE IF( left .AND. icoffa.NE.iroffc )
THEN
298 ELSE IF( .NOT.left .AND. icoffa.NE.icoffc )
THEN
300 ELSE IF( .NOT.left .AND. iacol.NE.iccol )
THEN
302 ELSE IF( .NOT.left .AND. desca( nb_ ).NE.descc( nb_ ) )
THEN
304 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
306 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
313 CALL pxerbla( ictxt,
'PSORMR2', -info )
314 CALL blacs_abort( ictxt, 1 )
316 ELSE IF( lquery )
THEN
322 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
325 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
326 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
328 IF( ( left .AND. .NOT.notran .OR. .NOT.left .AND. notran ) )
THEN
342 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
344 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
346 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'D-ring' )
355 mi = m - k + i - ia + 1
360 ni = n - k + i - ia + 1
365 CALL pselset2( aii, a, i, ja+nq-k+i-ia, desca, one )
366 CALL pslarf( side, mi, ni, a, i, ja, desca, desca( m_ ),
367 $ tau, c, ic, jc, descc, work )
368 CALL pselset( a, i, ja+nq-k+i-ia, desca, aii )
372 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
373 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
375 work( 1 ) = real( lwmin )