/* Wei-keng Liao, EECS Department, Northwestern University */ #include #include #include #include #include #include #include #include #include #define NUM_INT 8 int main(int argc, char **argv) { int i, err, rank, nprocs, blocklength, stride, *buffer; MPI_File fh; MPI_Status status; MPI_Datatype fileType; MPI_Offset disp; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &nprocs); if (argc != 2) { if (rank == 0) printf("Usage: %s filename\n",argv[0]); MPI_Finalize(); return 1; } blocklength = 2 * NUM_INT; /* initialize the file contents to integers in increasing order */ if (rank == 0) { char *fname = argv[1]; if (0 == strncmp(argv[1], "ufs:", 4)) fname = argv[1]+4; int fd = open(fname, O_CREAT | O_RDWR, 0666); if (fd == -1) { printf("Error open() %s (error: %s)\n",fname,strerror(errno)); MPI_Abort(MPI_COMM_WORLD, 1); } int total_int = nprocs*3*blocklength; buffer = (int*) malloc(total_int*sizeof(int)); for (i=0; i