Problem solved :) Thank you very much! <div><br></div><div>Nat</div><div><br></div><div><br><div class="gmail_quote">On 4 May 2012 17:16, Reuti <span dir="ltr"><<a href="mailto:reuti@staff.uni-marburg.de" target="_blank">reuti@staff.uni-marburg.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Am 04.05.2012 um 17:01 schrieb Mis Nat:<br>
<div class="im"><br>
> I'm trying to send random numbers in array which are generated in process 0 to process 1. I'm running in circles and I can't find out why process 1 receive only 6 of 10 numbers? Can please someone give me any advice what I'm doing wrong?<br>
<br>
</div>I wonder why the first ones are correct at all. For rank 1 you never allocate any memory AFAICS for the array. Allocating it for rank 1 too should fix it.<br>
<br>
-- Reuti<br>
<div><div class="h5"><br>
<br>
> Thank you!<br>
><br>
> Best regards,<br>
><br>
> Nat<br>
><br>
><br>
> void Test(int *Array, int ArraySize, int rank, int size)<br>
> {<br>
> int n=0;<br>
> MPI_Status status;<br>
><br>
> if (rank == 0)<br>
> {<br>
> MPI_Send(Array, ArraySize, MPI_INT, 1, 0, MPI_COMM_WORLD);<br>
> }<br>
> else if (rank == 1)<br>
> {<br>
> printf("\nReceiving:\n");<br>
> MPI_Recv(Array, ArraySize, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);<br>
><br>
> for (n=0; n<=ArraySize; n++)<br>
> printf("Proces %d array[%d]: %d \n", rank, n, Array[n]);<br>
> }<br>
> }<br>
><br>
> int main(int argc, char *argv[])<br>
> {<br>
> int ArraySize;<br>
> int *Array;<br>
> int MyRank, npes;<br>
> int n=0;<br>
><br>
> MPI_Status status;<br>
> MPI_Init(&argc,&argv);<br>
><br>
> MPI_Comm_rank(MPI_COMM_WORLD,&MyRank);<br>
> MPI_Comm_size(MPI_COMM_WORLD,&npes);<br>
><br>
> if(MyRank==0)<br>
> {<br>
> ArraySize=10;<br>
> Array=(int *)malloc(ArraySize*sizeof(int));<br>
><br>
> if(Array==0)<br>
> printf("Malloc memory error!");<br>
><br>
> srand(time(NULL));<br>
> for(n=0;n<ArraySize;n++)<br>
> {<br>
> Array[n]=(int)rand()%1000;<br>
> printf("%d ",Array[n]);<br>
> }<br>
> printf("\n");<br>
> }<br>
><br>
> MPI_Bcast(&ArraySize,1,MPI_INT,0,MPI_COMM_WORLD);<br>
> Test(Array,ArraySize, MyRank, npes);<br>
><br>
> MPI_Finalize();<br>
> return 0;<br>
> }<br>
><br>
><br>
> OUTPUT:<br>
> D:\examples\Release>mpiexec -n 2 -machinefile mf.txt -path "D:\examples\Release"<br>
> Sortiranje.exe<br>
> 4 359 104 338 565 244 132 891 450 557<br>
> ☺ 5☻ ˘ äProces 1 array[0]: 4<br>
> Proces 1 array[1]: 359<br>
> Proces 1 array[2]: 104<br>
> Proces 1 array[3]: 338<br>
> Proces 1 array[4]: 565<br>
> Proces 1 array[5]: 244<br>
> Proces 1 array[6]: 1869762692<br>
> Proces 1 array[7]: 544433507<br>
> Proces 1 array[8]: 1918967857<br>
> Proces 1 array[9]: 1534681458<br>
> Proces 1 array[10]: 540695856<br>
><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> mpich-discuss mailing list <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
> To manage subscription options or unsubscribe:<br>
> <a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
<br>
_______________________________________________<br>
mpich-discuss mailing list <a href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
To manage subscription options or unsubscribe:<br>
<a href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss" target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
</blockquote></div><br></div>