1 SUBROUTINE pslacon( N, V, IV, JV, DESCV, X, IX, JX, DESCX, ISGN,
10 INTEGER IV, IX, JV, JX, KASE, N
14 INTEGER DESCV( * ), DESCX( * ), ISGN( * )
149 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
150 $ lld_, mb_, m_, nb_, n_, rsrc_
151 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
152 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
153 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
155 parameter( itmax = 5 )
157 parameter( zero = 0.0e+0, one = 1.0e+0, two = 2.0e+0 )
160 INTEGER I, ICTXT, IFLAG, IIVX, IMAXROW, IOFFVX, IROFF,
161 $ iter, ivxcol, ivxrow, j, jlast, jjvx, jump,
162 $ k, mycol, myrow, np, npcol, nprow
163 REAL ALTSGN, ESTOLD, JLMAX, TEMP, XMAX
169 EXTERNAL blacs_gridinfo, igsum2d,
infog2l, psamax,
174 INTEGER INDXG2L, INDXG2P, INDXL2G, NUMROC
175 EXTERNAL indxg2l, indxg2p, indxl2g, numroc
178 INTRINSIC abs, mod, nint, real, sign
187 ictxt = descx( ctxt_ )
188 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
190 CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol,
191 $ iivx, jjvx, ivxrow, ivxcol )
192 IF( mycol.NE.ivxcol )
194 iroff = mod( ix-1, descx( mb_ ) )
195 np = numroc( n+iroff, descx( mb_ ), myrow, ivxrow, nprow )
196 IF( myrow.EQ.ivxrow )
198 ioffvx = iivx + (jjvx-1)*descx( lld_ )
201 DO 10 i = ioffvx, ioffvx+np-1
202 x( i ) = one / real( n )
209 GO TO ( 20, 40, 70, 110, 140 )jump
216 IF( myrow.EQ.ivxrow )
THEN
217 v( ioffvx ) = x( ioffvx )
218 est = abs( v( ioffvx ) )
219 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
221 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
227 CALL psasum( n, est, x, ix, jx, descx, 1 )
228 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
229 IF( myrow.EQ.ivxrow )
THEN
230 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
232 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
237 DO 30 i = ioffvx, ioffvx+np-1
238 x( i ) = sign( one, x( i ) )
239 isgn( i ) = nint( x( i ) )
249 CALL psamax( n, xmax, j, x, ix, jx, descx, 1 )
250 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
251 IF( myrow.EQ.ivxrow )
THEN
253 work( 2 ) = real( j )
254 CALL sgebs2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2 )
256 CALL sgebr2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2,
259 j = nint( work( 2 ) )
267 DO 60 i = ioffvx, ioffvx+np-1
270 imaxrow = indxg2p( j, descx( mb_ ), myrow, descx( rsrc_ ), nprow )
271 IF( myrow.EQ.imaxrow )
THEN
272 i = indxg2l( j, descx( mb_ ), myrow, descx( rsrc_ ), nprow )
283 CALL scopy( np, x( ioffvx ), 1, v( ioffvx ), 1 )
285 CALL psasum( n, est, v, iv, jv, descv, 1 )
286 IF( descv( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
287 IF( myrow.EQ.ivxrow )
THEN
288 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
290 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
295 DO 80 i = ioffvx, ioffvx+np-1
296 IF( nint( sign( one, x( i ) ) ).NE.isgn( i ) )
THEN
303 CALL igsum2d( ictxt,
'C',
' ', 1, 1, iflag, 1, -1, mycol )
308 IF( iflag.EQ.0 .OR. est.LE.estold )
311 DO 100 i = ioffvx, ioffvx+np-1
312 x( i ) = sign( one, x( i ) )
313 isgn( i ) = nint( x( i ) )
324 CALL psamax( n, xmax, j, x, ix, jx, descx, 1 )
325 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
326 IF( myrow.EQ.ivxrow )
THEN
328 work( 2 ) = real( j )
329 CALL sgebs2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2 )
331 CALL sgebr2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2,
334 j = nint( work( 2 ) )
337 CALL pselget(
'Columnwise',
' ', jlmax, x, jlast, jx, descx )
338 IF( ( jlmax.NE.abs( xmax ) ).AND.( iter.LT.itmax ) )
THEN
346 DO 130 i = ioffvx, ioffvx+np-1
347 k = indxl2g( i-ioffvx+iivx, descx( mb_ ), myrow,
348 $ descx( rsrc_ ), nprow )-ix+1
349 IF( mod( k, 2 ).EQ.0 )
THEN
354 x( i ) = altsgn*( one+real( k-1 ) / real( n-1 ) )
364 CALL psasum( n, temp, x, ix, jx, descx, 1 )
365 IF( descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
366 IF( myrow.EQ.ivxrow )
THEN
367 CALL sgebs2d( ictxt,
'Columnwise',
' ', 1, 1, temp, 1 )
369 CALL sgebr2d( ictxt,
'Columnwise',
' ', 1, 1, temp, 1,
373 temp = two*( temp / real( 3*n ) )
374 IF( temp.GT.est )
THEN
375 CALL scopy( np, x( ioffvx ), 1, v( ioffvx ), 1 )