C example: PI


Up: Sending and Receiving messages Next: C example (cont.) Previous: Fortran example (cont.)


#include "mpi.h" 
#include <math.h> 

int main(argc,argv) int argc; char *argv[]; { int done = 0, n, myid, numprocs, i, rc; double PI25DT = 3.141592653589793238462643; double mypi, pi, h, sum, x, a;

MPI_Init(&argc,&argv); MPI_Comm_size(MPI_COMM_WORLD,&numprocs); MPI_Comm_rank(MPI_COMM_WORLD,&myid);



Up: Sending and Receiving messages Next: C example (cont.) Previous: Fortran example (cont.)