[mpich-discuss] MPI_File_open(...) - overwrite existing file
Florian.Willich at dlr.de
Florian.Willich at dlr.de
Thu Feb 4 10:37:58 CST 2016
Dear MPI Group,
I'm wondering if the files created with the modes
MPI_MODE_CREATE | MPI_MODE_WRONLY
will be truncated to 0 if the file already exists calling MPI_File_open(...).
As far as I tested it and also which is written in the standard:
MPI_MODE_CREATE — create the file if it does not exist
MPI_MODE_WRONLY — write only
The existing file will be overwritten, but leaving the bytes that have not been explicitly overwritten. Thus, an existing file with the size of 8 Bytes and data to be written to of 4 Bytes will still be 8 Bytes after writing: With the 4 Bytes of the new data and 4 Bytes of the old data.
As I read it, there is nothing defined what happens with the data of the file if it already exists [p 494, 1].
The POSIX / GNU lib c standard states that the file will be truncated to 0 if opened with 'w' and the file does already exists calling fopen(...) [p. 249, 2]:
‘w’ - Open the file for writing only. If the file already exists, it is truncated to zero length. Otherwise a new file is created.
I really would appreciate some input if I'm wrong or not and what to do if the file needs to be truncated before writing (other then deleting the file before).
Kind regards
Florian Willich
[1]: Message Passing Interface Forum. 2015. MPI: A Message-Passing Interface Standard Version 3.1. http://mpi-forum.org/docs/mpi-3.1/mpi31-report.pdf. [Online. Accessed 2nd December 2015].
[2]: Loosemore, Sandra, Stallman, Richard M., McGrath, Roland, Oram, Andrew, & Drepper, Ulrich. 2015. The GNU C Library Reference Manual. http://www.gnu.org/software/libc/manual/pdf/libc.pdf. [Online. Accessed 24th January 2016].
Deutsches Zentrum für Luft- und Raumfahrt e. V. (DLR)
German Aerospace Center
Institute of Planetary Research | Planetary Physics | Rutherfordstraße 2 | 12489 Berlin
Florian Willich| Candidate for Bachelor of Science
Software Developer (Parallel Applications)
florian.willlich at dlr.de<mailto:florian.willlich at dlr.de>
DLR.de<http://www.dlr.de/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mpich.org/pipermail/discuss/attachments/20160204/1b3631e1/attachment.html>
-------------- next part --------------
_______________________________________________
discuss mailing list discuss at mpich.org
To manage subscription options or unsubscribe:
https://lists.mpich.org/mailman/listinfo/discuss
More information about the discuss
mailing list