MPI_FILE_OPEN(comm, filename, amode, info, fh)
int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_File *fh)
MPI_FILE_OPEN(COMM, FILENAME, AMODE, INFO, FH, IERROR)CHARACTER*(*) FILENAME
INTEGER COMM, AMODE, INFO, FH, IERROR
int MPI::File::Open(const MPI::Intracomm& comm, const char* filename, int amode, const MPI::Info& info)
static MPI::File
MPI_FILE_OPEN opens the file identified by the file name
filename on all processes in the comm communicator group.
MPI_FILE_OPEN is a collective routine:
all processes must provide the same value for amode,
and all processes must provide filenames that
reference the same file.
(Values for info may vary.)
comm must be an intracommunicator;
it is erroneous to pass an intercommunicator to MPI_FILE_OPEN.
Errors in MPI_FILE_OPEN are raised
using the default file error handler
(see Section 9.7, page ).
A process can open a file independently of other processes
by using the MPI_COMM_SELF communicator.
The file handle returned, fh,
can be subsequently used to access the file until the file is
closed using MPI_FILE_CLOSE.
Before calling MPI_FINALIZE,
the user is required to close (via MPI_FILE_CLOSE)
all files that were opened with MPI_FILE_OPEN.
Note that the communicator comm is unaffected by MPI_FILE_OPEN
and continues to be usable in all MPI-/ routines (e.g., MPI_SEND).
Furthermore, the use of comm will not interfere with I/O behavior.
The format for specifying the file name in the filename argument is implementation dependent and must be documented by the implementation.
Initially, all processes view the file as a linear byte stream, and each process views data in its own native representation (no data representation conversion is performed). (POSIX files are linear byte streams in the native representation.) The file view can be changed via the MPI_FILE_SET_VIEW routine.
The following access modes are supported (specified in amode, a bit vector OR of the following integer constants):
The modes MPI_MODE_RDONLY, MPI_MODE_RDWR, MPI_MODE_WRONLY, MPI_MODE_CREATE, and MPI_MODE_EXCL have identical semantics to their POSIX counterparts [11]. Exactly one of MPI_MODE_RDONLY, MPI_MODE_RDWR, or MPI_MODE_WRONLY, must be specified. It is erroneous to specify MPI_MODE_CREATE or MPI_MODE_EXCL in conjunction with MPI_MODE_RDONLY; it is erroneous to specify MPI_MODE_SEQUENTIAL together with MPI_MODE_RDWR.
The MPI_MODE_DELETE_ON_CLOSE mode causes the file to be deleted (equivalent to performing an MPI_FILE_DELETE) when the file is closed.
The MPI_MODE_UNIQUE_OPEN mode allows an implementation to optimize access by eliminating the overhead of file locking. It is erroneous to open a file in this mode unless the file will not be concurrently opened elsewhere.
The MPI_MODE_SEQUENTIAL mode allows an implementation to optimize access to some sequential devices (tapes and network streams). It is erroneous to attempt nonsequential access to a file that has been opened in this mode.
Specifying MPI_MODE_APPEND only guarantees that all shared and individual file pointers are positioned at the initial end of file when MPI_FILE_OPEN returns. Subsequent positioning of file pointers is application dependent. In particular, the implementation does not ensure that all writes are appended.
Errors related to the access mode are raised in the class MPI_ERR_AMODE.
The info argument is used to provide information
regarding file access patterns and file system specifics
(see Section 9.2.8, page ).
The constant MPI_INFO_NULL
can be used when no info needs to be specified.
Files are opened by default using nonatomic mode file consistency semantics
(see Section 9.6.1,
page ).
The more stringent atomic mode consistency semantics,
required for atomicity of conflicting accesses,
can be set using MPI_FILE_SET_ATOMICITY.
MPI-Standard for MARMOT