#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "mpi.h"

int main(int argc, char *argv[])
{
	int num_procs, myrank;
	double a, b[128];
	int tag = 0, i;
	MPI_Status status;

	MPI_Init(&argc, &argv);

	MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
	MPI_Comm_rank(MPI_COMM_WORLD, &myrank);

	a = (double)myrank;

	MPI_Allgather((void *)&a, 1, MPI_DOUBLE, (void *)&b, 1, MPI_DOUBLE, MPI_COMM_WORLD);

	printf("Process %d: a = %e\n", myrank, a);
	for(i = 0; i < num_procs; i++)
		printf("b[%d] = %e\n", i, b[i]);

	MPI_Finalize();

	return EXIT_SUCCESS;
}

