You forgot to allocate an MPI_File
object before opening the file. You may either change this line:
MPI_File *fh = NULL;
into:
MPI_File fh;
and open file by giving fh
's address to MPI_File_open(..., &fh)
. Or you may simply allocate memory from heap using malloc()
.
MPI_File *fh = malloc(sizeof(MPI_File));