fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <mpi.h>
  4. /* Run with two processes */
  5. void main(int argc, char *argv[]) {
  6. int rank, i, count;
  7. float data[100],value[200];
  8. MPI_Status status;
  9. MPI_Init(&argc,&argv);
  10. MPI_Comm_rank(MPI_COMM_WORLD,&rank);
  11. if(rank==1) {
  12. for(i=0;i<100;++i) data[i]=i;
  13. MPI_Send(data,100,MPI_FLOAT,0,55,MPI_COMM_WORLD); }
  14. else
  15. {
  16. MPI_Recv(value,200,MPI_FLOAT,MPI_ANY_SOURCE,55,MPI_COMM_WORLD,&status);
  17. printf("P:%d Got data from processor %d \n",rank,
  18. status.MPI_SOURCE);
  19. MPI_Get_count(&status,MPI_FLOAT,&count);
  20. printf("P:%d Got %d elements \n",rank,count);
  21. printf("P:%d value[5]=%f \n",rank,value[5]);
  22. }
  23. MPI_Finalize();
  24. }
Success #stdin #stdout #stderr 0.26s 40800KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected '/' in "/"
Execution halted