1 SUBROUTINE psgeqlf( 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 )
173 CHARACTER COLBTOP, ROWBTOP
174 INTEGER IACOL, IAROW, IINFO, ICTXT, IPW, J, JB, JL, JN,
175 $ k, lwmin, mp0, mu, mycol, myrow, npcol, nprow,
179 INTEGER IDUM1( 1 ), IDUM2( 1 )
187 INTEGER ICEIL, INDXG2P, NUMROC
188 EXTERNAL iceil, indxg2p, numroc
191 INTRINSIC 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 mp0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
213 $ myrow, iarow, nprow )
214 nq0 = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
215 $ mycol, iacol, npcol )
216 lwmin = desca( nb_ ) * ( mp0 + nq0 + desca( nb_ ) )
218 work( 1 ) = real( lwmin )
219 lquery = ( lwork.EQ.-1 )
220 IF( lwork.LT.lwmin .AND. .NOT.lquery )
223 IF( lwork.EQ.-1 )
THEN
229 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
234 CALL pxerbla( ictxt,
'PSGEQLF', -info )
236 ELSE IF( lquery )
THEN
242 IF( m.EQ.0 .OR. n.EQ.0 )
246 ipw = desca( nb_ ) * desca( nb_ ) + 1
247 jn =
min( iceil( ja+n-k, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
248 jl =
max( ( (ja+n-2) / desca( nb_ ) ) * desca( nb_ ) + 1, ja )
249 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
250 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
251 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'D-ring' )
252 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
254 IF( jl.GE.jn+1 )
THEN
258 DO 10 j = jl, jn+1, -desca( nb_ )
259 jb =
min( ja+n-j, desca( nb_ ) )
264 CALL psgeql2( m-n+j+jb-ja, jb, a, ia, j, desca, tau, work,
272 CALL pslarft(
'Backward',
'Columnwise', m-n+j+jb-ja, jb,
273 $ a, ia, j, desca, tau, work, work( ipw ) )
278 CALL pslarfb(
'Left',
'Transpose',
'Backward',
279 $
'Columnwise', m-n+j+jb-ja, j-ja, jb, a, ia,
280 $ j, desca, work, a, ia, ja, desca,
286 mu = m - n + jn - ja + 1
298 IF( mu.GT.0 .AND. nu.GT.0 )
299 $
CALL psgeql2( mu, nu, a, ia, ja, desca, tau, work, lwork,
302 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
303 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
305 work( 1 ) = real( lwmin )