14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
20 int PB_Cg2lrem(

int IG,

int INB,

int NB,

int MYPROC,

int SRCPROC,

int NPROCS )

26 int IG, INB, NB, NPROCS, MYPROC, SRCPROC;

76 int ilocblk, mydist, nblocks, proc;

85 if( ( SRCPROC == -1 ) || ( NPROCS == 1 ) )

return( IG );

89 if( IG < INB )

return( ( MYPROC == SRCPROC ? IG : 0 ) );

103 if( MYPROC == SRCPROC )

109 nblocks = ( IG - INB ) / NB + 1;

110 if( nblocks < NPROCS )

return( INB );

115 proc = SRCPROC + nblocks;

116 proc -= ( proc / NPROCS ) * NPROCS;

135 ilocblk = nblocks / NPROCS;

136 if( ilocblk * NPROCS >= nblocks )

137 return( ( ( MYPROC == proc ) ? IG + ( ilocblk - nblocks ) * NB :

138 INB + ( ilocblk - 1 ) * NB ) );

140 return( INB + ilocblk * NB );

148 nblocks = ( IG -= INB ) / NB + 1;

149 proc = SRCPROC + nblocks;

150 proc -= ( proc / NPROCS ) * NPROCS;

155 if( ( mydist = MYPROC - SRCPROC ) < 0 ) mydist += NPROCS;

164 if( nblocks < NPROCS )

167 return( ( ( mydist < 0 ) ? NB :

168 ( ( MYPROC == proc ) ? IG + ( 1 - nblocks ) * NB : 0 ) ) );

172 ilocblk = nblocks / NPROCS;

173 mydist -= nblocks - ilocblk * NPROCS;

174 return( ( ( mydist < 0 ) ? ( ilocblk + 1 ) * NB :

175 ( ( MYPROC == proc ) ?

176 ( ilocblk - nblocks + 1 ) * NB + IG : ilocblk * NB ) ) );