1 SUBROUTINE pcung2r( M, N, K, A, IA, JA, DESCA, TAU, WORK, LWORK,
10 INTEGER IA, INFO, JA, K, LWORK, M, N
14 COMPLEX 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( one = ( 1.0e+0, 0.0e+0 ),
165 $ zero = ( 0.0e+0, 0.0e+0 ) )
169 CHARACTER COLBTOP, ROWBTOP
170 INTEGER IACOL, IAROW, ICTXT, J, JJ, KQ, LWMIN, MPA0,
171 $ mycol, myrow, npcol, nprow, nqa0
180 INTEGER INDXG2L, INDXG2P, NUMROC
181 EXTERNAL indxg2l, indxg2p, numroc
190 ictxt = desca( ctxt_ )
191 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
196 IF( nprow.EQ.-1 )
THEN
199 CALL chk1mat( m, 1, n, 2, ia, ja, desca, 7, info )
201 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
203 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
205 mpa0 = numroc( m+mod( ia-1, desca( mb_ ) ), desca( mb_ ),
206 $ myrow, iarow, nprow )
207 nqa0 = numroc( n+mod( ja-1, desca( nb_ ) ), desca( nb_ ),
208 $ mycol, iacol, npcol )
209 lwmin = mpa0 +
max( 1, nqa0 )
211 work( 1 ) =
cmplx( real( lwmin ) )
212 lquery = ( lwork.EQ.-1 )
215 ELSE IF( k.LT.0 .OR. k.GT.n )
THEN
217 ELSE IF( lwork.LT.lwmin .AND. .NOT.lquery )
THEN
223 CALL pxerbla( ictxt,
'PCUNG2R', -info )
224 CALL blacs_abort( ictxt, 1 )
226 ELSE IF( lquery )
THEN
235 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rowbtop )
236 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', colbtop )
237 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise',
'D-ring' )
238 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise',
' ' )
242 CALL pclaset(
'All', k, n-k, zero, zero, a, ia, ja+k, desca )
243 CALL pclaset(
'All', m-k, n-k, zero, one, a, ia+k, ja+k, desca )
246 kq =
max( 1, numroc( ja+k-1, desca( nb_ ), mycol, desca( csrc_ ),
248 DO 10 j = ja+k-1, ja, -1
252 IF( j.LT.ja+n-1 )
THEN
253 CALL pcelset( a, ia+j-ja, j, desca, one )
254 CALL pclarf(
'Left', m-j+ja, ja+n-j-1, a, ia+j-ja, j, desca,
255 $ 1, tau, a, ia+j-ja, j+1, desca, work )
258 jj = indxg2l( j, desca( nb_ ), mycol, desca( csrc_ ), npcol )
259 iacol = indxg2p( j, desca( nb_ ), mycol, desca( csrc_ ),
262 $ tauj = tau(
min( jj, kq ) )
264 $
CALL pcscal( m-j+ja-1, -tauj, a, ia+j-ja+1, j, desca, 1 )
265 CALL pcelset( a, ia+j-ja, j, desca, one-tauj )
269 CALL pclaset(
'All', j-ja, 1, zero, zero, a, ia, j, desca )
273 CALL pb_topset( ictxt,
'Broadcast',
'Rowwise', rowbtop )
274 CALL pb_topset( ictxt,
'Broadcast',
'Columnwise', colbtop )
276 work( 1 ) =
cmplx( real( lwmin ) )