// // "hello world" program // #include #include // has exit(), etc. #include // MPI header file int main(int argc, char *argv[]) { // initialize for MPI (should come before any other calls to // MPI routines) if (MPI_Init(&argc, &argv) != MPI_SUCCESS) { cerr << "MPI initialization error\n"; exit(EXIT_FAILURE); } // get number of processes int nprocs; MPI_Comm_size(MPI_COMM_WORLD, &nprocs); // get this process's number (ranges from 0 to nprocs - 1) int myid; MPI_Comm_rank(MPI_COMM_WORLD, &myid); // print a greeting cout << "hello from process " << myid << " of " << nprocs << endl; // clean up for MPI MPI_Finalize(); return EXIT_SUCCESS; }