LJ Archive

Listing 4. Changes to main()

int main (int argc, char *argv[]){
  int num_threads(2);
  int my_rank;
  int nprocs;

  // initialize MPI
  MPI_Init(&argc,&argv);
  MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);

  // were we called properly?
  if (argc<3)
    usage(argv[0]);
  if (argc==4)
    num_threads=atol(argv[3]);
  long start(atol(argv[1]));
  long stop(atol(argv[2]));

  if (my_rank == 0)
    master(start,stop,nprocs);
  else
    slave(num_threads);

  MPI_Finalize();

  return EXIT_SUCCESS;
}
LJ Archive