My file called "a.txt" contains a number (47
).
If I run the program on a compiler without MPI using fscanf(a,"%f",&num)
it gives a true value nnum = 47.
If I run the program using MPI ssh it does not return the correct value. it will return num = 1104187136 instead.
Why is this?
int main(int argc, char *argv[]){
int count;
FILE *a1;
float a;
int num;
a1 = fopen("a1.txt","r");
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD,&numOfProc);
MPI_Comm_rank(MPI_COMM_WORLD,&my_rank);
if(my_rank == 0){
fscanf(a1,"%f",&num);
a = num;
printf("a = %d",a);
}
MPI_Finalize();
}