1 SUBROUTINE pcmax1( 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.0e+0, 0.0e+0 ) )
157 CHARACTER CBTOP, CCTOP, RBTOP, RCTOP
158 INTEGER ICOFF, ICTXT, IDUMM, IIX, IROFF, IXCOL, IXROW,
159 $ JJX, LCINDX, LDX, MAXPOS, MYCOL, MYROW, NP,
172 INTEGER ICMAX1, INDXL2G, NUMROC
173 EXTERNAL icmax1, indxl2g, numroc
176 INTRINSIC abs,
cmplx, mod, nint, real
182 ictxt = descx( ctxt_ )
183 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
195 CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol, iix, jjx,
198 IF( incx.EQ.1 .AND. descx( m_ ).EQ.1 .AND. n.EQ.1 )
THEN
200 amax = x( iix+(jjx-1)*ldx )
206 IF( incx.EQ.descx( m_ ) )
THEN
208 IF( myrow.EQ.ixrow )
THEN
210 icoff = mod( jx-1, descx( nb_ ) )
211 nq = numroc( n+icoff, descx( nb_ ), mycol, ixcol, npcol )
215 CALL pb_topget( ictxt,
'Broadcast',
'Rowwise', rbtop )
217 IF( lsame( rbtop,
' ' ) )
THEN
220 lcindx = jjx-1+icmax1( nq, x( iix+(jjx-1)*ldx ), ldx )
221 work( 1 ) = x( iix+(lcindx-1)*ldx )
222 work( 2 ) =
cmplx( real( indxl2g( lcindx,
223 $ descx( nb_ ), mycol, descx( csrc_ ), npcol ) ) )
229 CALL pctreecomb( ictxt,
'Row', 2, work, -1, mycol,
233 IF( amax.EQ.zero )
THEN
236 indx = nint( real( work( 2 ) ) )
241 CALL pb_topget( ictxt,
'Combine',
'Rowwise', rctop )
244 lcindx = jjx-1+icmax1( nq, x( iix+(jjx-1)*ldx ), ldx )
245 amax = x( iix + (lcindx-1)*ldx )
252 CALL cgamx2d( ictxt,
'Rowwise', rctop, 1, 1, amax, 1,
253 $ idumm, maxpos, 1, -1, myrow )
255 IF( amax.NE.zero )
THEN
259 IF( mycol.EQ.maxpos )
THEN
260 indx = indxl2g( lcindx, descx( nb_ ), mycol,
261 $ descx( csrc_ ), npcol )
262 CALL igebs2d( ictxt,
'Rowwise', rbtop, 1, 1, indx,
265 CALL igebr2d( ictxt,
'Rowwise', rbtop, 1, 1, indx,
281 IF( mycol.EQ.ixcol )
THEN
283 iroff = mod( ix-1, descx( mb_ ) )
284 np = numroc( n+iroff, descx( mb_ ), myrow, ixrow, nprow )
288 CALL pb_topget( ictxt,
'Broadcast',
'Columnwise', cbtop )
290 IF( lsame( cbtop,
' ' ) )
THEN
293 lcindx = iix-1+icmax1( np, x( iix+(jjx-1)*ldx ), 1 )
294 work( 1 ) = x( lcindx + (jjx-1)*ldx )
295 work( 2 ) =
cmplx( real( indxl2g( lcindx,
296 $ descx( mb_ ), myrow, descx( rsrc_ ), nprow ) ) )
302 CALL pctreecomb( ictxt,
'Column', 2, work, -1, mycol,
306 IF( amax.EQ.zero )
THEN
309 indx = nint( real( work( 2 ) ) )
314 CALL pb_topget( ictxt,
'Combine',
'Columnwise', cctop )
317 lcindx = iix-1+icmax1( np, x( iix+(jjx-1)*ldx ), 1 )
318 amax = x( lcindx + (jjx-1)*ldx )
325 CALL cgamx2d( ictxt,
'Columnwise', cctop, 1, 1, amax, 1,
326 $ maxpos, idumm, 1, -1, mycol )
328 IF( amax.NE.zero )
THEN
332 IF( myrow.EQ.maxpos )
THEN
333 indx = indxl2g( lcindx, descx( mb_ ), myrow,
334 $ descx( rsrc_ ), nprow )
335 CALL igebs2d( ictxt,
'Columnwise', cbtop, 1, 1,
338 CALL igebr2d( ictxt,
'Columnwise', cbtop, 1, 1,
339 $ indx, 1, maxpos, mycol )
368 COMPLEX V1( 2 ), V2( 2 )
395 IF( abs( real( v1( 1 ) ) ).LT.abs( real( v2( 1 ) ) ) )
THEN