#include #include #include double f(double x){ return sin(x); } int main(int argc, char** argv) { double a, b, delx, x, y, tot; int n, i; // MPI MPI_Init(&argc, &argv); int myid; MPI_Comm_rank(MPI_COMM_WORLD, &myid); int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); // MPI a = 0.0; b=3.141592653589793; n = atoi(argv[1]); delx = (b-a)/n; // MPI int rest = n%world_size; int nloc = n/world_size; if(myid < rest) { nloc++; } int start_index = nloc*myid; if(myid >= rest) { start_index += rest; } int end_index = start_index + nloc; // MPI x = a; tot = 0.0; // for(i=1;i