Hi,

What you are trying to do should work fine. MPI_File_open() only requires the amode and file name to match if there are multiple processes using the same communicator to collectively open the file. In your case you are using MPI_COMM_SELF, so there is no such requirement.

Have you tried printing the fname string just before MPI_File_open() to make sure it looks correct on each process? I don't see anything wrong with your logic, but it would be good to double check the arguments to MPI_File_open().

-Phil

bin dong wrote:
hi everyone,
I want each process on different servers to write to different files, so i written following code:
      open-test.c
---------------------------------------------------------------------------- ... ... MPI_Comm_rank(MPI_COMM_WORLD, &mynod);
       ... ...
      sprinft(fname, "pvfs2:/mnt/pvfs2/test-%d", mynode)
      ret = MPI_File_open(MPI_COMM_SELF,
                                    fname,
                                    MPI_MODE_RDWR|MPI_MODE_CREATE,
                                    MPI_INFO_NULL,
                                    &fh);
       ret = MPI_File_write(
                                    fh,
                                    f_buf,
                                    F_BUF_SIZE,
                                    MPI_BYTE,
MPI_STATUS_IGNORE); ... ... ----------------------------------------------------------------------------
      compile: mpicc open-test.c -o open-test
      run with:  mpirun -n 10 ./open-test
when the program is running , i find all ten processes open the same file(for example, pvfs2:/mnt/pvfs2/test-1), and write all data to pvfs2:/mnt/pvfs2/test-1.

     Then i check the mpi doc of mpi_file_open, it says that:
.....all processes must provide the same value for _amode,_ and all processes must provide filenames that reference the same file and which are textually identical. * So i think even though i pass different names to MPI_File_open in different processes, it will open the same file, * * and then the following MPI_File_write will write the all data to the same file.*
*
*
Can someone tell me whether what i think is right or not? If i am right, how can I open different files in different process?

Thanks in advance!

Din Dong

------------------------------------------------------------------------

_______________________________________________
Pvfs2-users mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-users

_______________________________________________
Pvfs2-users mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-users

Reply via email to