| 1 | 
#include "mpi.h" | 
| 2 | 
#include <stdio.h> | 
| 3 | 
#include <stdlib.h> | 
| 4 | 
#include <unistd.h> | 
| 5 | 
#include <dirent.h> | 
| 6 | 
 | 
| 7 | 
 | 
| 8 | 
 | 
| 9 | 
 | 
| 10 | 
int main(int argc, char *argv[]){ | 
| 11 | 
 | 
| 12 | 
  int myid,numprocs,i,rank; | 
| 13 | 
  extern char **environ; | 
| 14 | 
  char *newargv[] ={ | 
| 15 | 
    "/bin/echo", | 
| 16 | 
    "Hey this now spews on multiple machines", | 
| 17 | 
    NULL | 
| 18 | 
  }; | 
| 19 | 
  MPI_Init(&argc,&argv); | 
| 20 | 
  MPI_Comm_size(MPI_COMM_WORLD,&numprocs); | 
| 21 | 
  MPI_Comm_rank(MPI_COMM_WORLD,&myid); | 
| 22 | 
 | 
| 23 | 
  for (rank = 0;rank<numprocs;rank++){ | 
| 24 | 
    if (rank == myid){ | 
| 25 | 
      execve(argv[0],newargv,environ); | 
| 26 | 
    } | 
| 27 | 
  } | 
| 28 | 
 | 
| 29 | 
  MPI_Finalize(); | 
| 30 | 
 | 
| 31 | 
 | 
| 32 | 
} |