fork download
  1. #include<stdio.h>
  2. #include "mpi.h"
  3. #include<string.h>
  4. main(int argc, char **argv)
  5. {
  6. int MyRank, Numprocs, tag, ierror, i;
  7. MPI_Status status;
  8. char send_message[20], recv_message[20];
  9. MPI_Init(&argc, &argv);
  10. MPI_Comm_size(MPI_COMM_WORLD, &Numprocs);
  11. MPI_Comm_rank(MPI_COMM_WORLD, &MyRank);
  12. tag=100;
  13. strcpy(send_message, "Hello-Participants");
  14. if (MyRank==0)
  15. {
  16. for(i=1;i<Numprocs;i++)
  17. {
  18. MPI_Recv(recv_message,20,MPI_CHAR,i,tag,MPI_COMM_WORLD,&status);
  19. printf("node %d : %s \n",i,recv_message);
  20. }
  21. }
  22. else
  23. MPI_Send(send_message,20,MPI_CHAR,0,tag,MPI_COMM_WORLD);
  24. MPI_Finalize();
  25. }
Success #stdin #stdout #stderr 0.23s 40668KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected symbol in "main(int argc"
Execution halted