1 SUBROUTINE psormlq( 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( * )
219 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
220 $ lld_, mb_, m_, nb_, n_, rsrc_
221 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
222 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
223 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
226 LOGICAL LEFT, LQUERY, NOTRAN
227 CHARACTER COLBTOP, ROWBTOP, TRANST
228 INTEGER I, I1, I2, I3, IACOL, IB, ICC, ICCOL, ICOFFA,
229 $ icoffc, icrow, ictxt, iinfo, ipw, iroffc, jcc,
230 $ lcm, lcmp, lwmin, mi, mpc0, mqa0, mycol, myrow,
231 $ ni, npcol, nprow, nq, nqc0
234 INTEGER IDUM1( 4 ), IDUM2( 4 )
242 INTEGER ICEIL, ILCM, INDXG2P, NUMROC
243 EXTERNAL iceil, ilcm, indxg2p, lsame, numroc
246 INTRINSIC ichar,
max,
min, mod, real
252 ictxt = desca( ctxt_ )
253 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
258 IF( nprow.EQ.-1 )
THEN
261 left = lsame( side,
'L' )
262 notran = lsame( trans,
'N' )
268 CALL chk1mat( k, 5, m, 3, ia, ja, desca, 9, info )
271 CALL chk1mat( k, 5, n, 4, ia, ja, desca, 9, info )
273 CALL chk1mat( m, 3, n, 4, ic, jc, descc, 14, info )
275 icoffa = mod( ja-1, desca( nb_ ) )
276 iroffc = mod( ic-1, descc( mb_ ) )
277 icoffc = mod( jc-1, descc( nb_ ) )
278 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
280 icrow = indxg2p( ic, descc( mb_ ), myrow, descc( rsrc_ ),
282 iccol = indxg2p( jc, descc( nb_ ), mycol, descc( csrc_ ),
284 mpc0 = numroc( m+iroffc, descc( mb_ ), myrow, icrow, nprow )
285 nqc0 = numroc( n+icoffc, descc( nb_ ), mycol, iccol, npcol )
288 mqa0 = numroc( m+icoffa, desca( nb_ ), mycol, iacol,
290 lcm = ilcm( nprow, npcol )
292 lwmin =
max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) )
293 $ / 2, ( mpc0 +
max( mqa0 + numroc( numroc(
294 $ m+iroffc, desca( mb_ ), 0, 0, nprow ),
295 $ desca( mb_ ), 0, 0, lcmp ), nqc0 ) ) *
296 $ desca( mb_ ) ) + desca( mb_ ) * desca( mb_ )
298 lwmin =
max( ( desca( mb_ ) * ( desca( mb_ ) - 1 ) ) / 2,
299 $ ( mpc0 + nqc0 ) * desca( mb_ ) ) +
300 $ desca( mb_ ) * desca( mb_ )
303 work( 1 ) = real( lwmin )
304 lquery = ( lwork.EQ.-1 )
305 IF( .NOT.left .AND. .NOT.lsame( side,
'R' ) )
THEN
307 ELSE IF( .NOT.notran .AND. .NOT.lsame( trans,
'T' ) )
THEN
309 ELSE IF( k.LT.0 .OR. k.GT.nq )
THEN
311 ELSE IF( left .AND. desca( nb_ ).NE.descc( mb_ ) )
THEN
313 ELSE IF( left .AND. icoffa.NE.iroffc )
THEN
315 ELSE IF( .NOT.left .AND. icoffa.NE.icoffc )
THEN
317 ELSE IF( .NOT.left .AND. iacol.NE.iccol )
THEN
319 ELSE IF( .NOT.left .AND. desca( nb_ ).NE.descc( nb_ ) )
THEN
321 ELSE IF( ictxt.NE.descc( ctxt_ ) )
THEN
323 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
328 idum1( 1 ) = ichar(
'L' )
330 idum1( 1 ) = ichar(
'R' )
334 idum1( 2 ) = ichar(
'N' )
336 idum1( 2 ) = ichar(
'T' )
341 IF( lwork.EQ.-1 )
THEN
348 CALL pchk2mat( k, 5, m, 3, ia, ja, desca, 9, m, 3, n, 4, ic,
349 $ jc, descc, 14, 4, idum1, idum2, info )
351 CALL pchk2mat( k, 5, n, 4, ia, ja, desca, 9, m, 3, n, 4, ic,
352 $ jc, descc, 14, 4, idum1, idum2, info )
357 CALL pxerbla( ictxt,
'PSORMLQ', -info )
359 ELSE IF( lquery )
THEN
365 IF( m.EQ.0 .OR. n.EQ.0 .OR. k.EQ.0 )
368 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
369 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
371 IF( ( left .AND. notran ) .OR.
372 $ ( .NOT.left .AND. .NOT.notran ) )
THEN
373 i1 =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
378 i1 =
max( ( (ia+k-2) / desca( mb_ ) ) * desca( mb_ ) + 1, ia )
379 i2 =
min( iceil( ia, desca( mb_ ) ) * desca( mb_ ), ia+k-1 )
390 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
392 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'D-ring' )
394 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
404 IF( ( left .AND. notran ) .OR. ( .NOT.left .AND. .NOT.notran ) )
405 $
CALL psorml2( side, trans, m, n, i1-ia, a, ia, ja, desca, tau,
406 $ c, ic, jc, descc, work, lwork, iinfo )
408 ipw = desca( mb_ ) * desca( mb_ ) + 1
410 ib =
min( desca( mb_ ), k-i+ia )
415 CALL pslarft(
'Forward',
'Rowwise', nq-i+ia, ib, a, i, ja+i-ia,
416 $ desca, tau, work, work( ipw ) )
433 CALL pslarfb( side, transt,
'Forward',
'Rowwise', mi, ni, ib,
434 $ a, i, ja+i-ia, desca, work, c, icc, jcc, descc,
438 IF( ( left .AND. .NOT.notran ) .OR. ( .NOT.left .AND. notran ) )
439 $
CALL psorml2( side, trans, m, n, i2-ia, a, ia, ja, desca, tau,
440 $ c, ic, jc, descc, work, lwork, iinfo )
442 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
443 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
445 work( 1 ) = real( lwmin )