On Dec 12, 2004, at 6:24 PM, math ring wrote:
> Hi :
> I got a problem of gathering dynamic arrays in MPI. I hope
> to process the array just like normal array ewi[i][j] instead of
> ewi[i*size+j], but it doesn't work.
> The code looks like:
> MPI_Comm_rank(MPI_COMM_WORLD, &rank);
> MPI_Comm_size(MPI_COMM_WORLD, &size);
> if ( rank == 0)
> {
> printf("the number of processors is %d\n",size);
> printf("please input a integer:=");
> scanf("%d",&num);
> }
> double ** ewi = new double *[size];
> double *jj = new double[num]
One thing to point out - you read in num in rank 0, but use it at all
ranks. Data is private to the process in MPI, so you have to
explicitly send the value of num to all processes after reading the
user input.
Calling new[] with an uninitialized variable might be the source of
your problems...
Brian
--
Brian Barrett
LAM/MPI developer and all around nice guy
Have a LAM/MPI day: http://www.lam-mpi.org/
|