1 SUBROUTINE psgeql2( M, N, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, LWORK, M, N
14 REAL A( * ), TAU( * ), WORK( * )
165 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
166 $ lld_, mb_, m_, nb_, n_, rsrc_
167 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
168 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
169 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
171 parameter( one = 1.0e+0 )
175 CHARACTER COLBTOP, ROWBTOP
176 INTEGER I, IACOL, IAROW, ICTXT, II, J, JJ, K, LWMIN,
177 $ mp, mycol, myrow, npcol, nprow, nq
183 $ pb_topset,
pxerbla, sgebr2d, sgebs2d,
187 INTEGER INDXG2P, NUMROC
188 EXTERNAL indxg2p, numroc
191 INTRINSIC max,
min, mod, real
197 ictxt = desca( ctxt_ )
198 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
203 IF( nprow.EQ.-1 )
THEN
206 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
208 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
210 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
212 mp = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
213 $ myrow, iarow, nprow )
214 nq = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
215 $ mycol, iacol, npcol )
216 lwmin = mp +
max( 1, nq )
218 work( 1 ) = real( lwmin )
219 lquery = ( lwork.EQ.-1 )
220 IF( lwork.LT.lwmin .AND. .NOT.lquery )
226 CALL pxerbla( ictxt,
'PSGEQL2', -info )
227 CALL blacs_abort( ictxt, 1 )
229 ELSE IF( lquery )
THEN
235 IF( m.EQ.0 .OR. n.EQ.0 )
238 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
239 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
240 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'D-ring' )
241 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
243 IF( desca( m_ ).EQ.1 )
THEN
245 $ nq = nq - mod( ja-1, desca( nb_ ) )
246 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii,
248 iacol = indxg2p( ja+n-1, desca( nb_ ), mycol, desca( csrc_ ),
250 IF( myrow.EQ.iarow )
THEN
251 IF( mycol.EQ.iacol )
THEN
252 i = ii+(jj+nq-2)*desca( lld_ )
254 CALL slarfg( 1, ajj, a( i ), 1, tau( jj+nq-1 ) )
256 alpha = one - tau( jj+nq-1 )
257 CALL sgebs2d( ictxt,
'Rowwise',
' ', 1, 1, alpha, 1 )
258 CALL sscal( nq-1, alpha, a( ii+(jj-1)*desca( lld_ ) ),
261 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
262 $ tau( jj+nq-1 ), 1 )
266 CALL sgebr2d( ictxt,
'Rowwise',
' ', 1, 1, alpha,
268 CALL sscal( nq, alpha, a( ii+(jj-1)*desca( lld_ ) ),
272 ELSE IF( mycol.EQ.iacol )
THEN
273 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
274 $ tau( jj+nq-1 ), 1, iarow, iacol )
280 DO 10 j = ja+k-1, ja, -1
286 CALL pslarfg( m-k+i-ia+1, ajj, m-k+i, n-k+j, a, ia,
287 $ n-k+j, desca, 1, tau )
291 CALL pselset( a, i+m-k, j+n-k, desca, one )
292 CALL pslarf(
'Left', m-k+i-ia+1, n-k+j-ja, a, ia, n-k+j,
293 $ desca, 1, tau, a, ia, ja, desca, work )
294 CALL pselset( a, i+m-k, j+n-k, desca, ajj )
300 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
301 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
303 work( 1 ) = real( lwmin )