14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
20 int PB_Cnumroc(
int N,
int I,
int INB,
int NB,
int PROC,
int SRCPROC,
27 int I, INB, N, NB, NPROCS, PROC, SRCPROC;
82 int ilocblk, mydist, nblocks;
87 if( ( SRCPROC == -1 ) || ( NPROCS == 1 ) )
96 if( ( INB -= I ) <= 0 )
102 nblocks = (-INB) / NB + 1;
104 SRCPROC -= ( SRCPROC / NPROCS ) * NPROCS;
122 if( PROC == SRCPROC )
128 if( N <= INB )
return( N );
133 nblocks = ( N - INB ) / NB + 1;
151 if( nblocks < NPROCS )
return( INB );
153 ilocblk = nblocks / NPROCS;
154 return( ( nblocks - ilocblk * NPROCS ) ? INB + ilocblk * NB :
155 N + ( ilocblk - nblocks ) * NB );
162 if( N <= INB )
return( 0 );
167 nblocks = ( N - INB ) / NB + 1;
172 if( ( mydist = PROC - SRCPROC ) < 0 ) mydist += NPROCS;
189 if( nblocks < NPROCS )
190 return( ( mydist < nblocks ) ? NB : ( ( mydist > nblocks ) ? 0 :
191 N - INB + NB * ( 1 - nblocks ) ) );
193 ilocblk = nblocks / NPROCS;
194 mydist -= nblocks - ilocblk * NPROCS;
195 return( ( mydist < 0 ) ? ( ilocblk + 1 ) * NB :
196 ( ( mydist > 0 ) ? ilocblk * NB :
197 N - INB + NB * ( ilocblk - nblocks + 1 ) ) );