1 SUBROUTINE psgelq2( M, N, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, LWORK, M, N
14 REAL A( * ), TAU( * ), WORK( * )
164 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
165 $ lld_, mb_, m_, nb_, n_, rsrc_
166 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
167 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
168 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
170 parameter( one = 1.0e+0 )
174 CHARACTER COLBTOP, ROWBTOP
175 INTEGER IACOL, IAROW, I, ICTXT, J, K, LWMIN, MP, MYCOL,
176 $ myrow, npcol, nprow, nq
184 INTEGER INDXG2P, NUMROC
185 EXTERNAL indxg2p, numroc
188 INTRINSIC max,
min, mod, real
194 ictxt = desca( ctxt_ )
195 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
200 IF( nprow.EQ.-1 )
THEN
203 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
205 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
207 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
209 mp = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
210 $ myrow, iarow, nprow )
211 nq = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
212 $ mycol, iacol, npcol )
213 lwmin = nq +
max( 1, mp )
215 work( 1 ) = real( lwmin )
216 lquery = ( lwork.EQ.-1 )
217 IF( lwork.LT.lwmin .AND. .NOT.lquery )
223 CALL pxerbla( ictxt,
'PSGELQ2', -info )
224 CALL blacs_abort( ictxt, 1 )
226 ELSE IF( lquery )
THEN
232 IF( m.EQ.0 .OR. n.EQ.0 )
235 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
236 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
237 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
238 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
247 CALL pslarfg( n-j+ja, aii, i, j, a, i,
min( j+1, ja+n-1 ),
248 $ desca, desca( m_ ), tau )
250 IF( i.LT.ia+m-1 )
THEN
254 CALL pselset( a, i, j, desca, one )
255 CALL pslarf(
'Right', m-i+ia-1, n-j+ja, a, i, j, desca,
256 $ desca( m_ ), tau, a, i+1, j, desca, work )
258 CALL pselset( a, i, j, desca, aii )
262 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
263 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
265 work( 1 ) = real( lwmin )