I am trying to run below program
#include<stdio.h>
#include<mpi.h>
main(int argc, char **argv){
int size, myrank;
MPI_init(NULL, NULL);
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD,&myrank);
printf("My rank is\n",myrank);
}
command to compile and run:
mpicc hello.c
mpirun -np 4 a.out
Expected Output:
My rank is 0
My rank is 1
My rank is 2
My rank is 3
Actual Output:
My rank is 0
My rank is 0
My rank is 0
My rank is 0
Why did I get the output with all ranks equal to zero, and what should I do to get the expected output?