14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
20 int PB_Cnpreroc(
int N,
int I,
int INB,
int NB,
int PROC,
int SRCPROC,
27 int I, INB, N, NB, NPROCS, PROC, SRCPROC;
86 int ilocblk, mydist, nblocks;
91 if( ( SRCPROC == -1 ) || ( NPROCS == 1 ) )
100 if( ( INB -= I ) <= 0 )
106 nblocks = ( -INB ) / NB + 1;
108 SRCPROC -= ( SRCPROC / NPROCS ) * NPROCS;
115 if( PROC == SRCPROC )
return( 0 );
120 if( N <= INB )
return( N );
125 nblocks = ( N - INB ) / NB + 1;
130 if( ( mydist = PROC - SRCPROC ) < 0 ) mydist += NPROCS;
144 if( nblocks < NPROCS )
145 return( ( ( mydist <= nblocks ) ? INB + NB * ( mydist - 1 ) : N ) );
147 ilocblk = nblocks / NPROCS;
148 return( ( ( mydist <= ( nblocks - ilocblk * NPROCS ) ) ?
149 INB - NB + ( ilocblk + 1 ) * NB * mydist :
150 N + NB * ilocblk * ( mydist - NPROCS ) ) );