title: How Scatter and Gather works in MP J Express
body: <p>I am to create a new cluster api for my project. So I started learning MP J Express these days.I  just wrote program using Scatter and Gather in this way. But I am getting Null point exception.No idea where when wrong ? </p>
  
  <p>Here is my code </p>
  
  <pre><code>    import mpi.MPI;
  
      public class ScatterGather {
          public static void main(String args[]){
          MPI.Init(args);
          int rank = MPI.COMM_WORLD.Rank();
          int size = MPI.COMM_WORLD.Size();
          int unitSize=4,root=0;
          int sendbuf[]=null;
          if(rank==root){
            sendbuf= new int[unitSize*size];
          }
          int recvbuf[] = new int[unitSize];
        MPI.COMM_WORLD.Scatter(sendbuf,0,unitSize,MPI.INT,recvbuf,0,unitSize,MPI.INT,root);
          if(rank!=root){
              for(int i=0;i&lt;unitSize;i++){
                 recvbuf[i]=rank;
              }
          }
        MPI.COMM_WORLD.Gather(recvbuf,0,unitSize,MPI.INT,sendbuf,0,unitSize,MPI.INT,root);
          if(rank==root){
             for(int i=0;i&lt;unitSize;i++){
                  System.out.println(sendbuf[i]+ " ");
             }
          }
          MPI.Finalize();
       }
  }
  </code></pre>
  
  <p>Here is the error log </p>
  
  <pre><code>MPJ Express (0.43) is started in the multicore configuration
  mpi.MPIException: java.lang.NullPointerException
  at mpi.SimplePackerInt.unpack(SimplePackerInt.java:112)
  at mpi.Comm.recv(Comm.java:1499)
  at mpi.PureIntracomm.MST_Scatter(PureIntracomm.java:1102)
  at mpi.PureIntracomm.Scatter(PureIntracomm.java:1066)
  at mpi.Intracomm.Scatter(Intracomm.java:420)
  at ScatterGather.main(ScatterGather.java:14)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)... 
  </code></pre>