1 SUBROUTINE pzgeql2( M, N, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, LWORK, M, N
14 COMPLEX*16 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.0d+0, 0.0d+0 ) )
175 CHARACTER COLBTOP, ROWBTOP
176 INTEGER I, IACOL, IAROW, ICTXT, II, J, JJ, K, LWMIN,
177 $ mp, mycol, myrow, npcol, nprow, nq
178 COMPLEX*16 AJJ, ALPHA
187 INTEGER INDXG2P, NUMROC
188 EXTERNAL indxg2p, numroc
191 INTRINSIC dble, dcmplx,
max,
min, mod
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 ) = dcmplx( dble( lwmin ) )
219 lquery = ( lwork.EQ.-1 )
220 IF( lwork.LT.lwmin .AND. .NOT.lquery )
226 CALL pxerbla( ictxt,
'PZGEQL2', -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 zlarfg( 1, ajj, a( i ), 1, tau( jj+nq-1 ) )
256 alpha = one - dconjg( tau( jj+nq-1 ) )
257 CALL zgebs2d( ictxt,
'Rowwise',
' ', 1, 1, alpha, 1 )
258 CALL zscal( nq-1, alpha, a( ii+(jj-1)*desca( lld_ ) ),
261 CALL zgebs2d( ictxt,
'Columnwise',
' ', 1, 1,
262 $ tau( jj+nq-1 ), 1 )
266 CALL zgebr2d( ictxt,
'Rowwise',
' ', 1, 1, alpha,
268 CALL zscal( nq, alpha, a( ii+(jj-1)*desca( lld_ ) ),
272 ELSE IF( mycol.EQ.iacol )
THEN
273 CALL zgebr2d( ictxt,
'Columnwise',
' ', 1, 1,
274 $ tau( jj+nq-1 ), 1, iarow, iacol )
280 DO 10 j = ja+k-1, ja, -1
286 CALL pzlarfg( m-k+i-ia+1, ajj, m-k+i, n-k+j, a, ia,
287 $ n-k+j, desca, 1, tau )
291 CALL pzelset( a, i+m-k, j+n-k, desca, one )
292 CALL pzlarfc(
'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 pzelset( 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 ) = dcmplx( dble( lwmin ) )