I'm new memeber in this weblog, and I should deliver my assignment as soon as possible, but I have a big problem that I can't solve it. Please help me. In MPI I should divide my group into two groups. But all the time when I want to run a program I got error about mpi_group_incl. This is my error: 

[ubuntu:3346] *** An error occurred in MPI_Group_incl
[ubuntu:3346] *** on communicator MPI_COMM_WORLD
[ubuntu:3346] *** MPI_ERR_RANK: invalid rank
[ubuntu:3346] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)
mpiexec has exited due to process rank 0 with PID 3345 on
node ubuntu exiting without calling "finalize". This may
have caused other processes in the application to be
terminated by signals sent by mpiexec (as reported here).

I should mention that I run this program with diffrent number of process but I got same errors. In below you can find my c program.

 #include <stdio.h>
#include "mpi.h"
#include <unistd.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
void main(int argc, char *argv[])
      int Iam, p;
      int Neven, Nodd, members[6], even_rank, odd_rank;
      MPI_Group group_world, even_group, odd_group;
/* Starts MPI processes ... */
      MPI_Init(&argc, &argv);                          /* starts MPI */
      MPI_Comm_rank(MPI_COMM_WORLD, &Iam);  /* get current process id */
      MPI_Comm_size(MPI_COMM_WORLD, &p);    /* get number of processes */
      Neven = (p + 1)/2;     /* All processes of MPI_COMM_WORLD are divided */
      Nodd = p - Neven;      /* into 2 groups, odd- and even-numbered groups */
      members[0] = 2;
      members[1] = 0;
      members[2] = 4;
      MPI_Comm_group(MPI_COMM_WORLD, &group_world);
      MPI_Group_incl(group_world, Neven, members, &even_group);
      MPI_Group_excl(group_world, Neven, members,  &odd_group);

      if(Iam == 0) {
        printf("MPI_Group_incl/excl Usage Example\n");
        printf("Number of processes is %d\n", p);
        printf("Number of odd processes is %d\n", Nodd);
        printf("Number of even processes is %d\n", Neven);
        printf("     Iam     even      odd\n");

      MPI_Group_rank(even_group, &even_rank);
      MPI_Group_rank( odd_group,  &odd_rank);
      printf("%d %d %d\n",Iam, even_rank, odd_rank);

      MPI_Finalize();                  /* let MPI finish up ...  */