1 SUBROUTINE psorgrq( M, N, K, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, K, LWORK, M, N
14 REAL A( * ), TAU( * ), WORK( * )
158 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
159 $ lld_, mb_, m_, nb_, n_, rsrc_
160 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
161 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
162 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
164 parameter( zero = 0.0e+0 )
168 CHARACTER COLBTOP, ROWBTOP
169 INTEGER I, IACOL, IAROW, IB, ICTXT, IINFO, IN, IPW,
170 $ lwmin, mpa0, mycol, myrow, npcol, nprow, nqa0
173 INTEGER IDUM1( 2 ), IDUM2( 2 )
181 INTEGER ICEIL, INDXG2P, NUMROC
182 EXTERNAL iceil, indxg2p, numroc
185 INTRINSIC min, mod, real
191 ictxt = desca( ctxt_ )
192 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
197 IF( nprow.EQ.-1 )
THEN
200 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 7, info )
202 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
204 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
206 mpa0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
207 $ myrow, iarow, nprow )
208 nqa0 = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
209 $ mycol, iacol, npcol )
210 lwmin = desca( mb_ ) * ( mpa0 + nqa0 + desca( mb_ ) )
212 work( 1 ) = real( lwmin )
213 lquery = ( lwork.EQ.-1 )
216 ELSE IF( k.LT.0 .OR. k.GT.m )
THEN
218 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
224 IF( lwork.EQ.-1 )
THEN
230 CALL pchk1mat( m, 1, n, 2, ia, ja, desca, 7, 2, idum1, idum2,
235 CALL pxerbla( ictxt,
'PSORGRQ', -info )
237 ELSE IF( lquery )
THEN
246 ipw = desca( mb_ )*desca( mb_ ) + 1
247 in =
min( iceil( ia+m-k, desca( mb_ ) )*desca( mb_ ), ia+m-1 )
248 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
249 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
250 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
' ' )
251 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
'I-ring' )
255 CALL pslaset(
'All', in-ia+1, m-in+ia-1, zero, zero, a, ia,
256 $ ja+n-m+in-ia+1, desca )
260 CALL psorgr2( in-ia+1, n-m+in-ia+1, in-ia-m+k+1, a, ia, ja, desca,
261 $ tau, work, lwork, iinfo )
265 DO 10 i = in+1, ia+m-1, desca( mb_ )
266 ib =
min( ia+m-i, desca( mb_ ) )
271 CALL pslarft(
'Backward',
'Rowwise', n-m+i+ib-ia, ib, a, i, ja,
272 $ desca, tau, work, work( ipw ) )
276 CALL pslarfb(
'Right',
'Transpose',
'Backward',
'Rowwise',
277 $ i-ia, n-m+i+ib-ia, ib, a, i, ja, desca, work, a,
278 $ ia, ja, desca, work( ipw ) )
282 CALL psorgr2( ib, n-m+i+ib-ia, ib, a, i, ja, desca, tau, work,
288 CALL pslaset(
'All', ib, m-i-ib+ia, zero, zero, a, i,
289 $ ja+n-m+i+ib-ia, desca )
293 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
294 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
296 work( 1 ) = real( lwmin )