Question: I want to use MPI (MPICH2) on windows. I write this command:

```
MPI_Barrier(MPI_COMM_WORLD);  

```

And I expect it blocks all Processors until all group members have called it. But it is not happen. I add a schematic of my code:

```
int a;  
if(myrank == RootProc)  
   a = 4;  
MPI_Barrier(MPI_COMM_WORLD);  
cout << "My Rank = " << myrank << "\ta = " << a << endl;  

```

(With 2 processor:) Root processor (`0`) acts correctly, but processor with rank 1 doesn't know the `a` variable, so it display `-858993460` instead of `4`.

Can any one help me?  

Regards

Answer: 
You're only assigning `a` in process 0. MPI doesn't share memory, so if you want the `a` in process 1 to get the value of 4, you need to call `MPI_Send` from process 0 and `MPI_Recv` from process 1.
**Blocking is not enough**, you have to send data to other processes (**memory in not shared** between processes).

To share data across ALL processes **use**:

```
int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm )

```

so in your case:

```
MPI_Bcast(&a, 1, MPI_INT, 0, MPI_COMM_WORLD);

```

here you send one integer pointed by &a form process 0 to all other.
//**MPI\_Bcast is sender** for root process and **receiver** for non-root processes

You can also send some data to specyfic process by:

```
int MPI_Send( void *buf, int count, MPI_Datatype datatype, int dest, 
              int tag, MPI_Comm comm )

```

and then receive by:

```
int MPI_Recv(void* buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status)

```