How to gather blocks of matrix in root process. I tried using gather with the data type blocktype declared below but it didn't work.
int sqr=sqrt(p);
modval = n % sqr;
divval = n/sqr;
//partition into rows and columns
MyNoofRows = (me/sqr< modval ? divval + 1 : divval);
MyNoofcols = (me%sqr < modval ? divval + 1 : divval);
// surrounding rows with additional values required for computation
int rows_with_halo=MyNoofRows+(2*d);
int cols_with_halo=MyNoofcols+(2*d);
int istart= (cols_with_halo*d)+d;
MPI_Type_vector(rows_with_halo,d,cols_with_halo,MPI_DOUBLE,&columntype);
MPI_Type_commit(&columntype);
MPI_Type_vector(MyNoofRows,MyNoofcols,cols_with_halo,MPI_DOUBLE,&blocktype);
MPI_Type_commit(&blocktype);
MPI_Type_vector(MyNoofRows,MyNoofcols,n,MPI_DOUBLE,&blocktype_recv);
MPI_Type_commit(&blocktype_recv);
double *chunk_array=(double *)calloc((rows_with_halo*cols_with_halo),sizeof(double));
double *result_array=(double *)calloc((n*n),sizeof(double));
// now after computation I want matrix in each process must be collected in root process