fork download
  1. #include <stdio.h>
  2. #include <mpi.h>
  3.  
  4.  
  5. int main (argc, argv)
  6. int argc;
  7. char *argv[];
  8. {
  9. int rank, size;
  10.  
  11. MPI_Init (&argc, &argv); /* starts MPI */
  12. MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */
  13. MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */
  14. int i,s=0;
  15. for(i=1;i<=100;i++)
  16. s+=i;
  17. printf("%d\n",s);
  18. printf( "Hello world from process %d of %d\n", rank, size );
  19. MPI_Finalize();
  20. return 0;
  21. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:2:17: error: mpi.h: No such file or directory
prog.c: In function ‘main’:
prog.c:11: warning: implicit declaration of function ‘MPI_Init’
prog.c:12: warning: implicit declaration of function ‘MPI_Comm_rank’
prog.c:12: error: ‘MPI_COMM_WORLD’ undeclared (first use in this function)
prog.c:12: error: (Each undeclared identifier is reported only once
prog.c:12: error: for each function it appears in.)
prog.c:13: warning: implicit declaration of function ‘MPI_Comm_size’
prog.c:19: warning: implicit declaration of function ‘MPI_Finalize’
stdout
Standard output is empty