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.
11 #include "mpitestconf.h"
20 static char MTEST_Descrip[] = "Test reading and writing zero bytes (set status correctly)";
23 int main(int argc, char *argv[])
26 int size, rank, i, *buf, count, rc;
31 MTest_Init(&argc, &argv);
33 comm = MPI_COMM_WORLD;
34 rc = MPI_File_open(comm, (char *) "/scratch/test.ord",
35 MPI_MODE_RDWR | MPI_MODE_CREATE |
36 MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh);
38 MTestPrintErrorMsg("File_open", rc);
40 /* If the open fails, there isn't anything else that we can do */
45 MPI_Comm_size(comm, &size);
46 MPI_Comm_rank(comm, &rank);
47 buf = (int *) malloc(size * sizeof(int));
50 rc = MPI_File_write_ordered(fh, buf, 1, MPI_INT, &status);
52 MTestPrintErrorMsg("File_write_ordered", rc);
56 MPI_Get_count(&status, MPI_INT, &count);
59 fprintf(stderr, "Wrong count (%d) on write-ordered\n", count);
63 /* Set the individual pointer to 0, since we want to use a read_all */
64 MPI_File_seek(fh, 0, MPI_SEEK_SET);
66 /* Read nothing (check status) */
67 memset(&status, 0xff, sizeof(MPI_Status));
68 MPI_File_read(fh, buf, 0, MPI_INT, &status);
69 MPI_Get_count(&status, MPI_INT, &count);
72 fprintf(stderr, "Count not zero (%d) on read\n", count);
75 /* Write nothing (check status) */
76 memset(&status, 0xff, sizeof(MPI_Status));
77 MPI_File_write(fh, buf, 0, MPI_INT, &status);
80 fprintf(stderr, "Count not zero (%d) on write\n", count);
83 /* Read shared nothing (check status) */
84 MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
85 /* Read nothing (check status) */
86 memset(&status, 0xff, sizeof(MPI_Status));
87 MPI_File_read_shared(fh, buf, 0, MPI_INT, &status);
88 MPI_Get_count(&status, MPI_INT, &count);
91 fprintf(stderr, "Count not zero (%d) on read shared\n", count);
94 /* Write nothing (check status) */
95 memset(&status, 0xff, sizeof(MPI_Status));
96 MPI_File_write_shared(fh, buf, 0, MPI_INT, &status);
99 fprintf(stderr, "Count not zero (%d) on write\n", count);
104 MPI_File_seek_shared(fh, 0, MPI_SEEK_SET);
105 for (i = 0; i < size; i++)
107 MPI_File_read_ordered(fh, buf, 1, MPI_INT, &status);
108 /* if (buf[0] != rank) {*/
110 /* fprintf(stderr, "%d: buf = %d\n", rank, buf[0]);*/
118 MTest_Finalize(errs);