I'm running a simple SPMD program with MPI.
Is there a way to define special variables, defined on only some of the ids. Lets say only for worker id 4.
Code:
MPI_Comm_rank (MPI_COMM_WORLD, &labindex);
/* get current process id */
.....
if (labindex==4)
{
double V_mean[Ndx+1][tspc];
int taym;
}
.....
if ((labindex==4) && (tsn>save_start) && (tsn<save_end))
{
taym=tsn%tspc;
for (i=0;i<Ndx+1;i++)
{
V_mean[i][taym]=V_mean[i][taym]+V[i]/cta;
}
}
.....
Gives error when compiling.
PPICC.c: In function ‘main’:
PPICC.c:213: warning: unused variable ‘taym’
PPICC.c:212: warning: unused variable ‘V_mean’
PPICC.c:329: error: ‘taym’ undeclared (first use in this function)
PPICC.c:329: error: (Each undeclared identifier is reported only once
PPICC.c:329: error: for each function it appears in.)
PPICC.c:332: error: ‘V_mean’ undeclared (first use in this function)
If I define the variable V_mean for all of the workers, I will use excessive memory. Is there a solution for this?
With Best Regards