// // "hello world" program, plus command-line arguments // #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) MPI::Init(argc, argv); // get number of processes int nprocs = MPI::COMM_WORLD.Get_size(); // get this process's number (ranges from 0 to nprocs - 1) int myid = MPI::COMM_WORLD.Get_rank(); // print a greeting cout << "hello from process " << myid << " of " << nprocs << endl; // show command-line arguments, if any for (int i = 0; i < argc; ++i) cout << "in process " << myid << ", argument " << i << " is " << argv[i] << endl; // clean up for MPI MPI::Finalize(); return EXIT_SUCCESS; }