I have a question about MPI. I want to have processes read a binary file simultaneously and therefore I'm trying to use MPI_File_iread, but it is not working as I'd expect and I don't know what's wrong.
Sorry if the format of the question is not correct, I am new here.
Here is my code (NINTCI is an integer pointer, file_name is a char array that has the file name already):
#include "mpi.h"
[...]
MPI_Request request;
MPI_Status status;
MPI_File fp;
MPI_File_open(MPI_COMM_WORLD, file_name, MPI_MODE_RDONLY, MPI_INFO_NULL, &fp);
MPI_File_iread(fp, NINTCI, 1, MPI_INT, &request);
MPI_Wait(&request, &status);
printf("%d\n", *NINTCI);
MPI_Barrier(MPI_COMM_WORLD);
The correct number printed should be 0 for all processes, but instead I get random numbers like the following (8 processes):
-1475867408
1495223536
-219489040
-840278800
629550320
1309351152
-321049360
21273840
Funny thing is if I replace the MPI_File_iread with MPI_File_read and remove the MPI_Wait the result is correct.
Does anybody have an idea what I'm doing wrong? Thanks in advance!