HP-MPI User's Guide (11th Edition)
Example applications
io.c
Appendix A 263
for (i=0; i<nints; i++) buf[i] = 0;
MPI_File_open(MPI_COMM_SELF, filename,
MPI_MODE_CREATE | MPI_MODE_RDWR,
MPI_INFO_NULL, &fh);
MPI_File_set_view(fh, (MPI_Offset)0, MPI_INT, MPI_INT,
"native",
MPI_INFO_NULL);
MPI_File_read(fh, buf, nints, MPI_INT, &status);
MPI_File_close(&fh);
/* check if the data read is correct */
flag = 0;
for (i=0; i<nints; i++)
if (buf[i] != (rank*100000 + i)) {
printf("Process %d: error, read %d,
should be %d\n",
rank, buf[i], rank*100000+i);
flag = 1;
}
if (!flag) {
printf("Process %d: data read back is correct\n",
rank);
MPI_File_delete(filename, MPI_INFO_NULL);
}
free(buf);
free(filename);
MPI_Finalize();
exit(0);
}
io output
The output from running the io executable is shown below. The
application was run with -np = 4.
Process 0: data read back is correct
Process 1: data read back is correct
Process 2: data read back is correct
Process 3: data read back is correct