The problem is that MPI structure declared inside main() is not visible inside functions. Compiler gives following error:
my_prog.c: In function ‘void get(int)’:
my_prog.c:585:21: error: ‘MPI_GETSET’ was not declared in this scope
MPI_Send(&msg, 1, MPI_GETSET, rank, 0, MPI_COMM_WORLD);
Code sections are:
struct mpi_send{
  int job;
  int z;
  int img;
  short grp;
  short stp;
};
mpi_send msg;
int main(int argc, char** argv) {
    MPI_Init(&argc, &argv);
...
    MPI_Datatype MPI_GETSET;
    MPI_Datatype type[5] = {MPI_INT,MPI_INT,MPI_INT,MPI_SHORT,MPI_SHORT};
    int blocklen[5] = {1,1,1,1,1};
    MPI_Aint disp[5];
    disp[0]=sizeof(int); disp[1]=sizeof(int); disp[2]=sizeof(int);
    disp[3]=sizeof(short); disp[4]=sizeof(short);
    MPI_Type_create_struct(5, blocklen, disp, type, &MPI_GETSET);
    MPI_Type_commit(&MPI_GETSET);
...
    get(13);
}
void get(int z){
...
    MPI_Send(&msg, 1, MPI_GETSET, rank, 0, MPI_COMM_WORLD);
    MPI_Recv(&msg, 1, MPI_GETSET, rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
...
}
I would appreciate clarification why I can not use MPI_GETSET inside functions. Thanks in advance.
 
    