[mpich-discuss] Problems with MPI Romio code
Rajeev Thakur
thakur at mcs.anl.gov
Thu Jul 1 08:15:59 CDT 2010
MPI-IO writes files in binary, not ASCII text. So you won't be able to
read them in an editor.
Rajeev
> -----Original Message-----
> From: mpich-discuss-bounces at mcs.anl.gov
> [mailto:mpich-discuss-bounces at mcs.anl.gov] On Behalf Of shankha
> Sent: Thursday, July 01, 2010 1:02 AM
> To: mpich-discuss at mcs.anl.gov
> Subject: [mpich-discuss] Problems with MPI Romio code
>
> Hi,
> I am trying to open a File through the MPI_File_open and
> write to the file using MPI_File_write.
> Though all the calls seem to work fine when i try to open the
> file in a editor I see junk.
> I couldn't understand the reason why the file ( testfile ) to
> which I am writing the array buf doesn't have the correct values.
>
> MPI Version : mpicc for MPICH2 version 1.2.1p1, gcc version
> 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
>
> following is piece of code :
> #include <stdio.h>
> #include <mpi.h>
> #include <stdlib.h>
> #include <string.h>
> #include <assert.h>
> #include <stdbool.h>
>
> #define BUF_SIZE 3
>
> int
> main ( int argc , char **argv )
> {
> int myrank , size , i = 0;
> MPI_File thefile;
> int buf [ BUF_SIZE ];
> MPI_Init(&argc, &argv);
> MPI_Comm_rank ( MPI_COMM_WORLD, &myrank );
> MPI_Comm_size ( MPI_COMM_WORLD, &size );
>
> for ( i = 0 ; i < BUF_SIZE ; i++ )
> buf [ i ] = 9;
>
> for ( i = 0 ; i < BUF_SIZE; i++ )
> buf [ i ] = myrank * BUF_SIZE + i;
> MPI_File_open ( MPI_COMM_WORLD, "testfile", MPI_MODE_CREATE
> | MPI_MODE_WRONLY,
> MPI_INFO_NULL, &thefile );
> MPI_File_set_view ( thefile, myrank * BUF_SIZE * sizeof (
> int ), MPI_INT,
> MPI_INT, "native", MPI_INFO_NULL );
> MPI_File_write ( thefile, buf, BUF_SIZE, MPI_INT,
> MPI_STATUS_IGNORE );
> MPI_File_close ( &thefile );
> MPI_Finalize ();
> return 0;
>
> }
>
> Thanks for your help.
> Thanks
> Shankha
> _______________________________________________
> mpich-discuss mailing list
> mpich-discuss at mcs.anl.gov
> https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss
>
More information about the mpich-discuss
mailing list