14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
20 int PB_Cnnxtroc(
int N,
int I,
int INB,
int NB,
int PROC,
int SRCPROC,
27 int I, INB, N, NB, NPROCS, PROC, SRCPROC;
91 int ilocblk, mydist, nblocks;
96 if( ( SRCPROC == -1 ) || ( NPROCS == 1 ) )
105 if( ( INB -= I ) <= 0 )
111 nblocks = ( -INB ) / NB + 1;
113 SRCPROC -= ( SRCPROC / NPROCS ) * NPROCS;
120 if( N <= INB )
return( 0 );
135 nblocks = ( N - INB ) / NB + 1;
137 if( PROC == SRCPROC )
159 if( nblocks < NPROCS )
return( N - INB );
161 ilocblk = nblocks / NPROCS;
162 return( ( ( nblocks - ilocblk * NPROCS ) ? N - INB - ilocblk * NB :
163 ( nblocks - ilocblk ) * NB ) );
170 if( ( mydist = PROC - SRCPROC ) < 0 ) mydist += NPROCS;
174 if( mydist == NPROCS - 1 )
return( 0 );
184 if( nblocks < NPROCS )
185 return( ( ( mydist < nblocks ) ? N - mydist * NB - INB : 0 ) );
187 ilocblk = nblocks / NPROCS;
188 return( ( ( mydist >= ( nblocks - ilocblk * NPROCS ) ) ?
189 ( NPROCS - 1 - mydist ) * ilocblk * NB :
190 N - INB - ( ilocblk * mydist + ilocblk + mydist )*NB ) );