mpi4py.MPI.File

class mpi4py.MPI.File

Bases: object

File I/O context.

static __new__(cls, file=None)
Parameters:

file (File | None)

Return type:

Self

Methods Summary

Call_errhandler(errorcode)

Call the error handler installed on a file.

Close()

Close a file.

Create_errhandler(errhandler_fn)

Create a new error handler for files.

Delete(filename[, info])

Delete a file.

Get_amode()

Return the file access mode.

Get_atomicity()

Return the atomicity mode.

Get_byte_offset(offset)

Return the absolute byte position in the file.

Get_errhandler()

Get the error handler for a file.

Get_group()

Access the group of processes that opened the file.

Get_info()

Return the current hints for a file.

Get_position()

Return the current position of the individual file pointer.

Get_position_shared()

Return the current position of the shared file pointer.

Get_size()

Return the file size.

Get_type_extent(datatype)

Return the extent of datatype in the file.

Get_view()

Return the file view.

Iread(buf)

Nonblocking read using individual file pointer.

Iread_all(buf)

Nonblocking collective read using individual file pointer.

Iread_at(offset, buf)

Nonblocking read using explicit offset.

Iread_at_all(offset, buf)

Nonblocking collective read using explicit offset.

Iread_shared(buf)

Nonblocking read using shared file pointer.

Iwrite(buf)

Nonblocking write using individual file pointer.

Iwrite_all(buf)

Nonblocking collective write using individual file pointer.

Iwrite_at(offset, buf)

Nonblocking write using explicit offset.

Iwrite_at_all(offset, buf)

Nonblocking collective write using explicit offset.

Iwrite_shared(buf)

Nonblocking write using shared file pointer.

Open(comm, filename[, amode, info])

Open a file.

Preallocate(size)

Preallocate storage space for a file.

Read(buf[, status])

Read using individual file pointer.

Read_all(buf[, status])

Collective read using individual file pointer.

Read_all_begin(buf)

Start a split collective read using individual file pointer.

Read_all_end(buf[, status])

Complete a split collective read using individual file pointer.

Read_at(offset, buf[, status])

Read using explicit offset.

Read_at_all(offset, buf[, status])

Collective read using explicit offset.

Read_at_all_begin(offset, buf)

Start a split collective read using explicit offset.

Read_at_all_end(buf[, status])

Complete a split collective read using explicit offset.

Read_ordered(buf[, status])

Collective read using shared file pointer.

Read_ordered_begin(buf)

Start a split collective read using shared file pointer.

Read_ordered_end(buf[, status])

Complete a split collective read using shared file pointer.

Read_shared(buf[, status])

Read using shared file pointer.

Seek(offset[, whence])

Update the individual file pointer.

Seek_shared(offset[, whence])

Update the shared file pointer.

Set_atomicity(flag)

Set the atomicity mode.

Set_errhandler(errhandler)

Set the error handler for a file.

Set_info(info)

Set new values for the hints associated with a file.

Set_size(size)

Set the file size.

Set_view([disp, etype, filetype, datarep, info])

Set the file view.

Sync()

Causes all previous writes to be transferred to the storage device.

Write(buf[, status])

Write using individual file pointer.

Write_all(buf[, status])

Collective write using individual file pointer.

Write_all_begin(buf)

Start a split collective write using individual file pointer.

Write_all_end(buf[, status])

Complete a split collective write using individual file pointer.

Write_at(offset, buf[, status])

Write using explicit offset.

Write_at_all(offset, buf[, status])

Collective write using explicit offset.

Write_at_all_begin(offset, buf)

Start a split collective write using explicit offset.

Write_at_all_end(buf[, status])

Complete a split collective write using explicit offset.

Write_ordered(buf[, status])

Collective write using shared file pointer.

Write_ordered_begin(buf)

Start a split collective write using shared file pointer.

Write_ordered_end(buf[, status])

Complete a split collective write using shared file pointer.

Write_shared(buf[, status])

Write using shared file pointer.

f2py(arg)

free()

Call Close if not null.

fromhandle(handle)

Create object from MPI handle.

py2f()

Attributes Summary

amode

Access mode.

atomicity

Atomicity mode.

group

Group.

group_rank

Group rank.

group_size

Group size.

handle

MPI handle.

info

Info hints.

size

Size (in bytes).

Methods Documentation

Call_errhandler(errorcode)

Call the error handler installed on a file.

Parameters:

errorcode (int)

Return type:

None

Close()

Close a file.

Return type:

None

classmethod Create_errhandler(errhandler_fn)

Create a new error handler for files.

Parameters:

errhandler_fn (Callable[[File, int], None])

Return type:

Errhandler

classmethod Delete(filename, info=INFO_NULL)

Delete a file.

Parameters:
Return type:

None

Get_amode()

Return the file access mode.

Return type:

int

Get_atomicity()

Return the atomicity mode.

Return type:

bool

Get_byte_offset(offset)

Return the absolute byte position in the file.

Note

Input offset is measured in etype units relative to the current file view.

Parameters:

offset (int)

Return type:

int

Get_errhandler()

Get the error handler for a file.

Return type:

Errhandler

Get_group()

Access the group of processes that opened the file.

Return type:

Group

Get_info()

Return the current hints for a file.

Return type:

Info

Get_position()

Return the current position of the individual file pointer.

Note

Position is measured in etype units relative to the current file view.

Return type:

int

Get_position_shared()

Return the current position of the shared file pointer.

Note

Position is measured in etype units relative to the current view.

Return type:

int

Get_size()

Return the file size.

Return type:

int

Get_type_extent(datatype)

Return the extent of datatype in the file.

Parameters:

datatype (Datatype)

Return type:

int

Get_view()

Return the file view.

Return type:

tuple[int, Datatype, Datatype, str]

Iread(buf)

Nonblocking read using individual file pointer.

Parameters:

buf (BufSpec)

Return type:

Request

Iread_all(buf)

Nonblocking collective read using individual file pointer.

Parameters:

buf (BufSpec)

Return type:

Request

Iread_at(offset, buf)

Nonblocking read using explicit offset.

Parameters:
Return type:

Request

Iread_at_all(offset, buf)

Nonblocking collective read using explicit offset.

Parameters:
Return type:

Request

Iread_shared(buf)

Nonblocking read using shared file pointer.

Parameters:

buf (BufSpec)

Return type:

Request

Iwrite(buf)

Nonblocking write using individual file pointer.

Parameters:

buf (BufSpec)

Return type:

Request

Iwrite_all(buf)

Nonblocking collective write using individual file pointer.

Parameters:

buf (BufSpec)

Return type:

Request

Iwrite_at(offset, buf)

Nonblocking write using explicit offset.

Parameters:
Return type:

Request

Iwrite_at_all(offset, buf)

Nonblocking collective write using explicit offset.

Parameters:
Return type:

Request

Iwrite_shared(buf)

Nonblocking write using shared file pointer.

Parameters:

buf (BufSpec)

Return type:

Request

classmethod Open(comm, filename, amode=MODE_RDONLY, info=INFO_NULL)

Open a file.

Parameters:
Return type:

Self

Preallocate(size)

Preallocate storage space for a file.

Parameters:

size (int)

Return type:

None

Read(buf, status=None)

Read using individual file pointer.

Parameters:
Return type:

None

Read_all(buf, status=None)

Collective read using individual file pointer.

Parameters:
Return type:

None

Read_all_begin(buf)

Start a split collective read using individual file pointer.

Parameters:

buf (BufSpec)

Return type:

None

Read_all_end(buf, status=None)

Complete a split collective read using individual file pointer.

Parameters:
Return type:

None

Read_at(offset, buf, status=None)

Read using explicit offset.

Parameters:
Return type:

None

Read_at_all(offset, buf, status=None)

Collective read using explicit offset.

Parameters:
Return type:

None

Read_at_all_begin(offset, buf)

Start a split collective read using explicit offset.

Parameters:
Return type:

None

Read_at_all_end(buf, status=None)

Complete a split collective read using explicit offset.

Parameters:
Return type:

None

Read_ordered(buf, status=None)

Collective read using shared file pointer.

Parameters:
Return type:

None

Read_ordered_begin(buf)

Start a split collective read using shared file pointer.

Parameters:

buf (BufSpec)

Return type:

None

Read_ordered_end(buf, status=None)

Complete a split collective read using shared file pointer.

Parameters:
Return type:

None

Read_shared(buf, status=None)

Read using shared file pointer.

Parameters:
Return type:

None

Seek(offset, whence=SEEK_SET)

Update the individual file pointer.

Parameters:
Return type:

None

Seek_shared(offset, whence=SEEK_SET)

Update the shared file pointer.

Parameters:
Return type:

None

Set_atomicity(flag)

Set the atomicity mode.

Parameters:

flag (bool)

Return type:

None

Set_errhandler(errhandler)

Set the error handler for a file.

Parameters:

errhandler (Errhandler)

Return type:

None

Set_info(info)

Set new values for the hints associated with a file.

Parameters:

info (Info)

Return type:

None

Set_size(size)

Set the file size.

Parameters:

size (int)

Return type:

None

Set_view(disp=0, etype=BYTE, filetype=None, datarep='native', info=INFO_NULL)

Set the file view.

Parameters:
Return type:

None

Sync()

Causes all previous writes to be transferred to the storage device.

Return type:

None

Write(buf, status=None)

Write using individual file pointer.

Parameters:
Return type:

None

Write_all(buf, status=None)

Collective write using individual file pointer.

Parameters:
Return type:

None

Write_all_begin(buf)

Start a split collective write using individual file pointer.

Parameters:

buf (BufSpec)

Return type:

None

Write_all_end(buf, status=None)

Complete a split collective write using individual file pointer.

Parameters:
Return type:

None

Write_at(offset, buf, status=None)

Write using explicit offset.

Parameters:
Return type:

None

Write_at_all(offset, buf, status=None)

Collective write using explicit offset.

Parameters:
Return type:

None

Write_at_all_begin(offset, buf)

Start a split collective write using explicit offset.

Parameters:
Return type:

None

Write_at_all_end(buf, status=None)

Complete a split collective write using explicit offset.

Parameters:
Return type:

None

Write_ordered(buf, status=None)

Collective write using shared file pointer.

Parameters:
Return type:

None

Write_ordered_begin(buf)

Start a split collective write using shared file pointer.

Parameters:

buf (BufSpec)

Return type:

None

Write_ordered_end(buf, status=None)

Complete a split collective write using shared file pointer.

Parameters:
Return type:

None

Write_shared(buf, status=None)

Write using shared file pointer.

Parameters:
Return type:

None

classmethod f2py(arg)
Parameters:

arg (int)

Return type:

File

free()

Call Close if not null.

Return type:

None

classmethod fromhandle(handle)

Create object from MPI handle.

Parameters:

handle (int)

Return type:

File

py2f()
Return type:

int

Attributes Documentation

amode

Access mode.

atomicity

Atomicity mode.

group

Group.

group_rank

Group rank.

group_size

Group size.

handle

MPI handle.

info

Info hints.

size

Size (in bytes).