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

#include "mpi.h"

int main(int argc, char *argv[])
{
	int num_procs, myrank;
	double a[128], b;
	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);

	if(myrank == 0)
		for(i = 0; i < num_procs; i++)
			a[i] = (double)i;

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

	printf("Process %d: b = %e\n", myrank, b);

	MPI_Finalize();

	return EXIT_SUCCESS;
}

