#include <stdio.h>#include <stdarg.h>#include <time.h>/* get definition of MPI constants */#include "mpi.h"#define NINT 1000000000void adder(int *, int *, double *, double *);int main (int argc, char *argv[])/* This program calculates the variance of the first 10^9 integers     *//* using MPI with multiple Macintoshes.                                 */{int n, start;clock_t start_program, end_program;double sum1, sum2, mean, mesq;int ierror, nproc, idproc, root=0;double partial[2], result[2];/* initialize the MPI environment */ierror = MPI_Init(&argc, &argv);ierror = MPI_Comm_size(MPI_COMM_WORLD,&nproc);ierror = MPI_Comm_rank(MPI_COMM_WORLD,&idproc);start_program = clock ();/* set arguments for each node, last node might have more work */n = NINT / nproc;start = n * idproc;n += start;if (idproc == (nproc-1))   n = NINT;adder (&n, &start, &sum1, &sum2);/* add up all the partial sums from each node */partial[0] = sum1;partial[1] = sum2;ierror = MPI_Reduce(partial,result,2,MPI_DOUBLE,MPI_SUM,root,                    MPI_COMM_WORLD);/* terminate MPI environment */ierror = MPI_Barrier(MPI_COMM_WORLD);ierror = MPI_Finalize();/* node 0 has the results */if (idproc == root) {   n = NINT;   mean = result[0] / n;   mesq = result[1] / n;   printf("%15d %20.3f %20.3f\n", n, mean, mesq - (mean * mean));}end_program = clock ();printf("\ntime in sec: %7.2f\n", (end_program-start_program)/60.);if (idproc == root) {   printf("hit carriage return to continue\n");   getchar();}return 0;}voidadder (int *n, int *start, double *s1, double *s2){int i;double ls1 = 0.0, ls2 = 0.0;for (i=(*start);i<(*n);i++)   {      ls1+=(double) i;      ls2+=(double) i*i;   }*s1 = ls1;*s2 = ls2;}