alright here is the full code:

Code:

for(k=0;k<5;k++){
if (rank == root)
{
mult = a_array[k*n + k];
for (i=k;i<6;i++)
a_array[k*n + i] = a_array[k*n + i]/mult;
pivot[0] = a_array[0];
pivot[1] = a_array[1];
pivot[2] = a_array[2];
pivot[3] = a_array[3];
pivot[4] = a_array[4];
pivot[5] = a_array[5];
for(i=0;i<6;i++)
printf("%f\t",pivot[i]);
printf("\n");
}
MPI_Barrier(MPI_COMM_WORLD);
MPI_Scatter(&a_array[0],12,MPI_DOUBLE,&temp[0],12,MPI_DOUBLE,root,MPI_COMM_WORLD);
MPI_Bcast(&pivot[0],6,MPI_DOUBLE,0,MPI_COMM_WORLD);
for (i=0;i<2;i++){
if ((rank*2 + i) > k){
mult = temp[i*2 + k];
for (j=0;j<6;j++)
temp[i*2 + j] = temp[i*2 + j] - mult*pivot[j];
}
}
mpi_err = MPI_Barrier(MPI_COMM_WORLD);
MPI_Gather(&temp[0],12,MPI_DOUBLE,&a_array[0],12,MPI_DOUBLE,root,MPI_COMM_WORLD);
}
MPI_Barrier(MPI_COMM_WORLD);