#include <mpi.h>
#include <stdio.h>

int main(int argc, char ** argv)
{
    int myrank, size;

    int myval;
    int result;

    MPI_Status status;

    MPI_Init(&argc, &argv);


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

    myval=myrank;
    result=0;

    //src=0;
    //dest=1;

   MPI_Reduce(&myval, &result, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
        
    printf("I am rank %d. Result= %d \n", myrank, result);
     

    MPI_Finalize();
    return 0;
}
