1 SUBROUTINE pclacon( N, V, IV, JV, DESCV, X, IX, JX, DESCX, EST,
10 INTEGER IV, IX, JV, JX, KASE, N
14 INTEGER DESCV( * ), DESCX( * )
15 COMPLEX V( * ), X( * )
146 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
147 $ lld_, mb_, m_, nb_, n_, rsrc_
148 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
149 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
150 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
152 parameter( itmax = 5 )
154 parameter( one = 1.0e+0, two = 2.0e+0 )
156 parameter( czero = ( 0.0e+0, 0.0e+0 ),
157 $ cone = ( 1.0e+0, 0.0e+0 ) )
160 INTEGER I, ICTXT, IIVX, IMAXROW, IOFFVX, IROFF, ITER,
161 $ ivxcol, ivxrow, j, jlast, jjvx, jump, k,
162 $ mycol, myrow, np, npcol, nprow
163 REAL ALTSGN, ESTOLD, SAFMIN, TEMP
170 EXTERNAL blacs_gridinfo, ccopy, cgebr2d, cgebs2d,
175 INTEGER INDXG2L, INDXG2P, INDXL2G, NUMROC
177 EXTERNAL indxg2l, indxg2p, indxl2g, numroc, pslamch
180 INTRINSIC abs,
cmplx, real
189 ictxt = descx( ctxt_ )
190 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
192 CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol,
193 $ iivx, jjvx, ivxrow, ivxcol )
194 IF( mycol.NE.ivxcol )
196 iroff = mod( ix-1, descx( mb_ ) )
197 np = numroc( n+iroff, descx( mb_ ), myrow, ivxrow, nprow )
198 IF( myrow.EQ.ivxrow )
200 ioffvx = iivx + (jjvx-1)*descx( lld_ )
202 safmin = pslamch( ictxt,
'Safe minimum' )
204 DO 10 i = ioffvx, ioffvx+np-1
205 x( i ) =
cmplx( one / real( n ) )
212 GO TO ( 20, 40, 70, 90, 120 )jump
219 IF( myrow.EQ.ivxrow )
THEN
220 v( ioffvx ) = x( ioffvx )
221 est = abs( v( ioffvx ) )
222 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
224 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
230 CALL pscsum1( n, est, x, ix, jx, descx, 1 )
231 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
232 IF( myrow.EQ.ivxrow )
THEN
233 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
235 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
240 DO 30 i = ioffvx, ioffvx+np-1
241 IF( abs( x( i ) ).GT.safmin )
THEN
242 x( i ) = x( i ) /
cmplx( abs( x( i ) ) )
255 CALL pcmax1( n, xmax, j, x, ix, jx, descx, 1 )
256 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
257 IF( myrow.EQ.ivxrow )
THEN
259 work( 2 ) =
cmplx( real( j ) )
260 CALL cgebs2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2 )
262 CALL cgebr2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2,
265 j = nint( real( work( 2 ) ) )
273 DO 60 i = ioffvx, ioffvx+np-1
276 imaxrow = indxg2p( j, descx( mb_ ), myrow, descx( rsrc_ ), nprow )
277 IF( myrow.EQ.imaxrow )
THEN
278 i = indxg2l( j, descx( mb_ ), myrow, descx( rsrc_ ), nprow )
289 CALL ccopy( np, x( ioffvx ), 1, v( ioffvx ), 1 )
291 CALL pscsum1( n, est, v, iv, jv, descv, 1 )
292 IF( descv( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
293 IF( myrow.EQ.ivxrow )
THEN
294 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
296 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
305 DO 80 i = ioffvx, ioffvx+np-1
306 IF( abs( x( i ) ).GT.safmin )
THEN
307 x( i ) = x( i ) /
cmplx( abs( x( i ) ) )
321 CALL pcmax1( n, xmax, j, x, ix, jx, descx, 1 )
322 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
323 IF( myrow.EQ.ivxrow )
THEN
325 work( 2 ) =
cmplx( real( j ) )
326 CALL cgebs2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2 )
328 CALL cgebr2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2,
331 j = nint( real( work( 2 ) ) )
334 CALL pcelget(
'Columnwise',
' ', jlmax, x, jlast, jx, descx )
335 IF( ( real( jlmax ).NE.abs( real( xmax ) ) ).AND.
336 $ ( iter.LT.itmax ) )
THEN
344 DO 110 i = ioffvx, ioffvx+np-1
345 k = indxl2g( i-ioffvx+iivx, descx( mb_ ), myrow,
346 $ descx( rsrc_ ), nprow )-ix+1
347 IF( mod( k, 2 ).EQ.0 )
THEN
352 x( i ) =
cmplx( altsgn*( one+real( k-1 ) / real( n-1 ) ) )
362 CALL pscsum1( n, temp, x, ix, jx, descx, 1 )
363 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
364 IF( myrow.EQ.ivxrow )
THEN
365 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, temp, 1 )
367 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, temp, 1,
371 temp = two*( temp / real( 3*n ) )
372 IF( temp.GT.est )
THEN
373 CALL ccopy( np, x( ioffvx ), 1, v( ioffvx ), 1 )