#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"mpi.h"
/**
* all process exe blocking read/write in the context of fileview
* int MPI_File_read_all(MPI_file fh, void * buf, int count, MPI_Datatype datatype, MPI_Status * status)
* int MPI_File_write_all(MPI_file fh, void * buf, int count, MPI_Datatype datatype, MPI_Status * status)
*/
int main(int argc, char *argv[])
{
int totalTaskNum, rankID;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rankID);
MPI_Comm_size(MPI_COMM_WORLD, &totalTaskNum);
char *filename = "file.txt";
MPI_File fh;
MPI_Status status;
MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
MPI_Offset offset = rankID * 128;
//each process will has its file view which starts with offset
MPI_File_set_view(fh, offset, MPI_CHAR, MPI_CHAR, "native", MPI