1 SUBROUTINE pdgeqr2( M, N, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, LWORK, M, N
14 DOUBLE PRECISION 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.0d+0 )
174 CHARACTER COLBTOP, ROWBTOP
175 INTEGER I, II, IACOL, IAROW, ICTXT, J, JJ, K, LWMIN,
176 $ mp, mycol, myrow, npcol, nprow, nq
177 DOUBLE PRECISION AJJ, ALPHA
180 EXTERNAL blacs_abort, blacs_gridinfo,
chk1mat, dgebr2d,
181 $ dgebs2d, dlarfg, dscal,
infog2l,
186 INTEGER INDXG2P, NUMROC
187 EXTERNAL indxg2p, numroc
190 INTRINSIC dble,
max,
min, mod
196 ictxt = desca( ctxt_ )
197 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
202 IF( nprow.EQ.-1 )
THEN
205 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
207 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
209 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
211 mp = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
212 $ myrow, iarow, nprow )
213 nq = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
214 $ mycol, iacol, npcol )
215 lwmin = mp +
max( 1, nq )
217 work( 1 ) = dble( lwmin )
218 lquery = ( lwork.EQ.-1 )
219 IF( lwork.LT.lwmin .AND. .NOT.lquery )
225 CALL pxerbla( ictxt,
'PDGEQR2', -info )
226 CALL blacs_abort( ictxt, 1 )
228 ELSE IF( lquery )
THEN
234 IF( m.EQ.0 .OR. n.EQ.0 )
237 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
238 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
239 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
240 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
242 IF( desca( m_ ).EQ.1 )
THEN
243 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, ii,
245 IF( myrow.EQ.iarow )
THEN
246 nq = numroc( ja+n-1, desca( nb_ ), mycol, desca( csrc_ ),
248 i = ii+(jj-1)*desca( lld_ )
249 IF( mycol.EQ.iacol )
THEN
251 CALL dlarfg( 1, ajj, a( i ), 1, tau( jj ) )
253 alpha = one - tau( jj )
254 CALL dgebs2d( ictxt,
'Rowwise',
' ', 1, 1, alpha, 1 )
255 CALL dscal( nq-jj, alpha, a( i+desca( lld_ ) ),
258 CALL dgebs2d( ictxt,
'Columnwise',
' ', 1, 1, tau( jj ),
263 CALL dgebr2d( ictxt,
'Rowwise',
' ', 1, 1, alpha,
265 CALL dscal( nq-jj+1, alpha, a( i ), desca( lld_ ) )
268 ELSE IF( mycol.EQ.iacol )
THEN
269 CALL dgebr2d( ictxt,
'Columnwise',
' ', 1, 1, tau( jj ), 1,
282 CALL pdlarfg( m-j+ja, ajj, i, j, a,
min( i+1, ia+m-1 ), j,
284 IF( j.LT.ja+n-1 )
THEN
288 CALL pdelset( a, i, j, desca, one )
290 CALL pdlarf(
'Left', m-j+ja, n-j+ja-1, a, i, j, desca, 1,
291 $ tau, a, i, j+1, desca, work )
293 CALL pdelset( a, i, j, desca, ajj )
299 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
300 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
302 work( 1 ) = dble( lwmin )