1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
4 * (C) 2003 by Argonne National Laboratory.
5 * See COPYRIGHT in top-level directory.
13 static char MTEST_Descrip[] = "Test reading and writing ordered output";
16 int main(int argc, char *argv[])
19 int size, rank, i, *buf, rc;
24 MTest_Init(&argc, &argv);
26 comm = MPI_COMM_WORLD;
27 MPI_File_open(comm, (char *) "/scratch/test.ord",
28 MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
30 MPI_Comm_size(comm, &size);
31 MPI_Comm_rank(comm, &rank);
32 buf = (int *) malloc(size * sizeof(int));
34 rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
36 MTestPrintErrorMsg("File_write_ordered", rc);
39 /* make sure all writes finish before we seek/read */
42 /* Set the individual pointer to 0, since we want to use a read_all */
43 MPI_File_seek(fh, 0, MPI_SEEK_SET);
44 MPI_File_read_all(fh, buf, size, MPI_INT, &status);
46 /* for (i = 0; i < size; i++) {*/
47 /* if (buf[i] != i) {*/
49 /* fprintf(stderr, "%d: buf[%d] = %d\n", rank, i, buf[i]);*/
53 MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
54 for (i = 0; i < size; i++)
56 MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
57 /*if (buf[0] != rank) {
59 fprintf(stderr, "%d: buf[0] = %d\n", rank, buf[0]);