1 SUBROUTINE pzlacon( N, V, IV, JV, DESCV, X, IX, JX, DESCX, EST,
10 INTEGER IV, IX, JV, JX, KASE, N
14 INTEGER DESCV( * ), DESCX( * )
15 COMPLEX*16 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 )
153 DOUBLE PRECISION ONE, TWO
154 parameter( one = 1.0d+0, two = 2.0d+0 )
155 COMPLEX*16 CZERO, CONE
156 parameter( czero = ( 0.0d+0, 0.0d+0 ),
157 $ cone = ( 1.0d+0, 0.0d+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 DOUBLE PRECISION ALTSGN, ESTOLD, SAFMIN, TEMP
164 COMPLEX*16 JLMAX, XMAX
170 EXTERNAL blacs_gridinfo,
infog2l, dgebr2d,
172 $
pzmax1, zcopy, zgebr2d, zgebs2d
175 INTEGER INDXG2L, INDXG2P, INDXL2G, NUMROC
176 DOUBLE PRECISION PDLAMCH
177 EXTERNAL indxg2l, indxg2p, indxl2g, numroc, pdlamch
180 INTRINSIC abs, dble, dcmplx
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 = pdlamch( ictxt,
'Safe minimum' )
204 DO 10 i = ioffvx, ioffvx+np-1
205 x( i ) = dcmplx( one / dble( 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 dgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
224 CALL dgebr2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1,
230 CALL pdzsum1( 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 dgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
235 CALL dgebr2d( 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 ) / dcmplx( abs( x( i ) ) )
255 CALL pzmax1( 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 ) = dcmplx( dble( j ) )
260 CALL zgebs2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2 )
262 CALL zgebr2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2,
265 j = nint( dble( 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 zcopy( np, x( ioffvx ), 1, v( ioffvx ), 1 )
291 CALL pdzsum1( 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 dgebs2d( ictxt,
'Columnwise',
' ', 1, 1, est, 1 )
296 CALL dgebr2d( 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 ) / dcmplx( abs( x( i ) ) )
321 CALL pzmax1( 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 ) = dcmplx( dble( j ) )
326 CALL zgebs2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2 )
328 CALL zgebr2d( ictxt,
'Columnwise',
' ', 2, 1, work, 2,
331 j = nint( dble( work( 2 ) ) )
334 CALL pzelget(
'Columnwise',
' ', jlmax, x, jlast, jx, descx )
335 IF( ( dble( jlmax ).NE.abs( dble( 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 ) = dcmplx( altsgn*( one+dble( k-1 ) / dble( n-1 ) ) )
362 CALL pdzsum1( 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 dgebs2d( ictxt,
'Columnwise',
' ', 1, 1, temp, 1 )
367 CALL dgebr2d( ictxt,
'Columnwise',
' ', 1, 1, temp, 1,
371 temp = two*( temp / dble( 3*n ) )
372 IF( temp.GT.est )
THEN
373 CALL zcopy( np, x( ioffvx ), 1, v( ioffvx ), 1 )