7 /* Test reading and writing zero bytes (set status correctly) */
\r
9 int main( int argc, char *argv[] )
\r
12 int size, rank, i, *buf, count;
\r
17 MPI_Init( &argc, &argv );
\r
19 comm = MPI_COMM_WORLD;
\r
20 MPI_File_open( comm, (char*)"/scratch/lib/libsimgrid.so.3.6.2", MPI_MODE_RDWR | MPI_MODE_CREATE | MPI_MODE_DELETE_ON_CLOSE, MPI_INFO_NULL, &fh );
\r
21 MPI_Comm_size( comm, &size );
\r
22 MPI_Comm_rank( comm, &rank );
\r
23 buf = (int *)malloc( 10+ size * sizeof(int) );
\r
27 MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET );
\r
28 MPI_File_write_all( fh, buf, 1, MPI_INT, &status );
\r
29 MPI_Get_count( &status, MPI_INT, &count );
\r
32 fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr);
\r
34 /* Write to file, overlapping */
\r
35 MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET );
\r
36 MPI_File_write_all( fh, buf, 10, MPI_INT, &status );
\r
37 MPI_Get_count( &status, MPI_INT, &count );
\r
40 fprintf( stderr, "Wrong count (%d) on write\n", count );fflush(stderr);
\r
42 /* Read nothing (check status) */
\r
43 memset( &status, 0xff, sizeof(MPI_Status) );
\r
44 MPI_File_read_all( fh, buf, 0, MPI_INT, &status );
\r
45 MPI_Get_count( &status, MPI_INT, &count );
\r
48 fprintf( stderr, "Count not zero (%d) on read\n", count );fflush(stderr);
\r
51 /* Write nothing (check status) */
\r
52 memset( &status, 0xff, sizeof(MPI_Status) );
\r
53 MPI_File_write_all( fh, buf, 0, MPI_INT, &status );
\r
56 fprintf( stderr, "Count not zero (%d) on write\n", count );fflush(stderr);
\r
59 MPI_Barrier( comm );
\r
61 MPI_File_seek( fh, sizeof(int)*rank, MPI_SEEK_SET );
\r
62 for (i=0; i<size; i++) buf[i] = -1;
\r
63 MPI_File_read_all( fh, buf, 10, MPI_INT, &status );
\r
64 // if (buf[0] != rank) {
\r
66 // fprintf( stderr, "%d: buf = %d\n", rank, buf[0] );fflush(stderr);
\r
70 MPI_File_close( &fh );
\r