#include <stdio.h>
#include "mpi.h"
int main( int argc, char* argv[] )
 {
     int numdat=100;
     int myrank, nproc;
     int i,ist,ied,isum,isum1;
     MPI_Init( &argc, &argv );
     MPI_Comm_size(MPI_COMM_WORLD, &nproc); 
     MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
     ist=((numdat-1)/nproc+1)*myrank+1;
     ied=((numdat-1)/nproc+1)*(myrank+1);
     isum1=0;
     for(i=ist;i<ied+1;i++) isum1 += i;
     MPI_Reduce(&isum1,&isum,1,MPI_INT,MPI_SUM,
                   0,MPI_COMM_WORLD);
     if(myrank==0) printf("isum=%d\n",isum);
     MPI_Finalize();
 }
