1 SUBROUTINE psgeqrf( 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 )
172 CHARACTER COLBTOP, ROWBTOP
173 INTEGER I, IACOL, IAROW, ICOFF, ICTXT, IINFO, IPW, J,
174 $ jb, jn, k, lwmin, mp0, mycol, myrow, npcol,
178 INTEGER IDUM1( 1 ), IDUM2( 1 )
185 INTEGER ICEIL, INDXG2P, NUMROC
186 EXTERNAL iceil, indxg2p, numroc
189 INTRINSIC min, mod, real
195 ictxt = desca( ctxt_ )
196 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
201 IF( nprow.EQ.-1 )
THEN
204 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 6, info )
206 icoff = mod( ja-1, desca( nb_ ) )
207 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
209 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
211 mp0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
212 $ myrow, iarow, nprow )
213 nq0 = numroc( n+icoff, desca( nb_ ), mycol, iacol, npcol )
214 lwmin = desca( nb_ ) * ( mp0 + nq0 + desca( nb_ ) )
216 work( 1 ) = real( lwmin )
217 lquery = ( lwork.EQ.-1 )
218 IF( lwork.LT.lwmin .AND. .NOT.lquery )
221 IF( lwork.EQ.-1 )
THEN
227 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
232 CALL pxerbla( ictxt,
'PSGEQRF', -info )
234 ELSE IF( lquery )
THEN
240 IF( m.EQ.0 .OR. n.EQ.0 )
244 ipw = desca( nb_ ) * desca( nb_ ) + 1
245 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
246 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
247 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'I-ring' )
248 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
252 jn =
min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+k-1 )
257 CALL psgeqr2( m, jb, a, ia, ja, desca, tau, work, lwork, iinfo )
259 IF( ja+jb.LE.ja+n-1 )
THEN
264 CALL pslarft(
'Forward',
'Columnwise', m, jb, a, ia, ja, desca,
265 $ tau, work, work( ipw ) )
269 CALL pslarfb(
'Left',
'Transpose',
'Forward',
'Columnwise', m,
270 $ n-jb, jb, a, ia, ja, desca, work, a, ia, ja+jb,
271 $ desca, work( ipw ) )
276 DO 10 j = jn+1, ja+k-1, desca( nb_ )
277 jb =
min( k-j+ja, desca( nb_ ) )
283 CALL psgeqr2( m-j+ja, jb, a, i, j, desca, tau, work, lwork,
286 IF( j+jb.LE.ja+n-1 )
THEN
291 CALL pslarft(
'Forward',
'Columnwise', m-j+ja, jb, a, i, j,
292 $ desca, tau, work, work( ipw ) )
296 CALL pslarfb(
'Left',
'Transpose',
'Forward',
'Columnwise',
297 $ m-j+ja, n-j-jb+ja, jb, a, i, j, desca, work,
298 $ a, i, j+jb, desca, work( ipw ) )
303 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
304 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
306 work( 1 ) = real( lwmin )