title: Execute SharedMemory Executable under MPI
body: <p>I have a program, say, g09.x that enable Parallel Execution on Shared Memory Processors.</p>
  
  <p>Now I have 8 cores, and I divide it into two groups using mpi.
   For each group, I want them to execute g09.x using 4 cores respectively.</p>
  
  <p>Do anyone have some experience or idea about how to do this?</p>
  
  <p>The MPI_Group is constructing as following, but the region  /* Execute Shared Memory Program */ is still leaving blank!</p>
  
  <pre><code>#include "mpi.h"
  #include &lt;stdio.h&gt;
  
  int main (int argc, char *argv[])
  {
    int rank, group_rank, numtasks, group_size, rc,
        group1[4]={0,1,2,3},
        group2[4]={4,5,6,7};
  
    MPI_Group orig_group, new_group;
    MPI_Comm  group_comm;
  
    rc = MPI_Init(&amp;argc, &amp;argv);
    if (rc !=0){
       printf("MPI_aborted\n");
       MPI_Abort(MPI_COMM_WORLD, rc);
    }
  
    MPI_Comm_size(MPI_COMM_WORLD, &amp;numtasks);
    MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  
    /* Extract the original group handle */
    MPI_Comm_group(MPI_COMM_WORLD, &amp;orig_group);
  
   /* Divide tasks into two distinct groups based upon rank */
   if (rank &lt; 4){
       MPI_Group_incl(orig_group, 4, group1, &amp;new_group);
   }
   else {
       MPI_Group_incl(orig_group, 4, group2, &amp;new_group);
   }
  
   /* Create new communicator */
   MPI_Comm_create(MPI_COMM_WORLD, new_group, &amp;group_comm);
   MPI_Group_size(new_group, &amp;group_size);
   MPI_Group_rank(new_group, &amp;group_rank);
  
   printf("rank=%d, group_rank=%d, numtasks=%d, group_size=%d\n", rank, group_rank,      numtasks, group_size);
  
    /* Do Something */
    /* Execute Shared Memory Program */
    MPI_Finalize();
    return 0;
  }
  </code></pre>