1 SUBROUTINE pzmax1( N, AMAX, INDX, X, IX, JX, DESCX, INCX )
9 INTEGER INDX, INCX, IX, JX, N
148 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
149 $ LLD_, MB_, M_, NB_, N_, RSRC_
150 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
151 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
152 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
154 parameter( zero = ( 0.0d+0, 0.0d+0 ) )
157 CHARACTER CBTOP, CCTOP, RBTOP, RCTOP
158 INTEGER ICOFF, ICTXT, IDUMM, IIX, IROFF, IXCOL, IXROW,
159 $ JJX, LCINDX, LDX, MAXPOS, MYCOL, MYROW, NP,
166 EXTERNAL blacs_gridinfo, igebr2d, igebs2d,
infog2l,
171 INTEGER IZMAX1, INDXL2G, NUMROC
172 EXTERNAL izmax1, indxl2g, numroc
175 INTRINSIC abs, dble, dcmplx, mod, nint
181 ictxt = descx( ctxt_ )
182 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
194 CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol, iix, jjx,
197 IF( incx.EQ.1 .AND. descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
199 amax = x( iix+(jjx-1)*ldx )
205 IF( incx.EQ.descx( m_ ) )
THEN
207 IF( myrow.EQ.ixrow )
THEN
209 icoff = mod( jx-1, descx( nb_ ) )
210 nq = numroc( n+icoff, descx( nb_ ), mycol, ixcol, npcol )
214 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rbtop )
216 IF( lsame( rbtop,
' ' ) )
THEN
219 lcindx = jjx-1+izmax1( nq, x( iix+(jjx-1)*ldx ), ldx )
220 work( 1 ) = x( iix+(lcindx-1)*ldx )
221 work( 2 ) = dcmplx( dble( indxl2g( lcindx,
222 $ descx( nb_ ), mycol, descx( csrc_ ), npcol ) ) )
228 CALL pztreecomb( ictxt,
'Row', 2, work, -1, mycol,
232 IF( amax.EQ.zero )
THEN
235 indx = nint( dble( work( 2 ) ) )
240 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rctop )
243 lcindx = jjx-1+izmax1( nq, x( iix+(jjx-1)*ldx ), ldx )
244 amax = x( iix + (lcindx-1)*ldx )
251 CALL zgamx2d( ictxt,
'Rowwise', rctop, 1, 1, amax, 1,
252 $ idumm, maxpos, 1, -1, myrow )
254 IF( amax.NE.zero )
THEN
258 IF( mycol.EQ.maxpos )
THEN
259 indx = indxl2g( lcindx, descx( nb_ ), mycol,
260 $ descx( csrc_ ), npcol )
261 CALL igebs2d( ictxt,
'Rowwise', rbtop, 1, 1, indx,
264 CALL igebr2d( ictxt,
'Rowwise', rbtop, 1, 1, indx,
280 IF( mycol.EQ.ixcol )
THEN
282 iroff = mod( ix-1, descx( mb_ ) )
283 np = numroc( n+iroff, descx( mb_ ), myrow, ixrow, nprow )
287 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', cbtop )
289 IF( lsame( cbtop,
' ' ) )
THEN
292 lcindx = iix-1+izmax1( np, x( iix+(jjx-1)*ldx ), 1 )
293 work( 1 ) = x( lcindx + (jjx-1)*ldx )
294 work( 2 ) = dcmplx( dble( indxl2g( lcindx,
295 $ descx( mb_ ), myrow, descx( rsrc_ ), nprow ) ) )
301 CALL pztreecomb( ictxt,
'Column', 2, work, -1, mycol,
305 IF( amax.EQ.zero )
THEN
308 indx = nint( dble( work( 2 ) ) )
313 CALL pb_topget( ictxt,
'Combine',
'Columnwise', cctop )
316 lcindx = iix-1+izmax1( np, x( iix+(jjx-1)*ldx ), 1 )
317 amax = x( lcindx + (jjx-1)*ldx )
324 CALL zgamx2d( ictxt,
'Columnwise', cctop, 1, 1, amax, 1,
325 $ maxpos, idumm, 1, -1, mycol )
327 IF( amax.NE.zero )
THEN
331 IF( myrow.EQ.maxpos )
THEN
332 indx = indxl2g( lcindx, descx( mb_ ), myrow,
333 $ descx( rsrc_ ), nprow )
334 CALL igebs2d( ictxt,
'Columnwise', cbtop, 1, 1,
337 CALL igebr2d( ictxt,
'Columnwise', cbtop, 1, 1,
338 $ indx, 1, maxpos, mycol )
367 COMPLEX*16 V1( 2 ), V2( 2 )
394 IF( abs( dble( v1( 1 ) ) ).LT.abs( dble( v2( 1 ) ) ) )
THEN