fork download
  1. #include <mpi.h>
  2. #include <stdio.h>
  3.  
  4. int main(int argc, char **argv) {
  5. int rank;
  6.  
  7. // Initialize MPI
  8. MPI_Init(&argc, &argv);
  9.  
  10. // Get my rank
  11. MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  12.  
  13. // Print the message only once (only process 0 does this)
  14. if (rank == 0) {
  15. printf("Hello from process %d of %d\n", rank, MPI_Comm_size(MPI_COMM_WORLD, &rank));
  16. }
  17.  
  18. // Rest of your MPI code here...
  19.  
  20. // Finalize MPI
  21. MPI_Finalize();
  22. return 0;
  23. }
  24.  
Success #stdin #stdout #stderr 0.31s 40356KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Error: unexpected symbol in "int main"
Execution halted