#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;
	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_Allreduce((void *)&a, (void *)&b, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);

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

	MPI_Finalize();

	return EXIT_SUCCESS;
}

