1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
.. _mpi_file_preallocate:
MPI_File_preallocate
====================
.. include_body
:ref:`MPI_File_preallocate` |mdash| Preallocates a specified amount of storage
space at the beginning of a file (collective).
SYNTAX
------
C Syntax
^^^^^^^^
.. code-block:: c
#include <mpi.h>
int MPI_File_preallocate(MPI_File fh, MPI_Offset size)
Fortran Syntax
^^^^^^^^^^^^^^
.. code-block:: fortran
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_FILE_PREALLOCATE(FH, SIZE, IERROR)
INTEGER FH, IERROR
INTEGER(KIND=MPI_OFFSET_KIND) SIZE
Fortran 2008 Syntax
^^^^^^^^^^^^^^^^^^^
.. code-block:: fortran
USE mpi_f08
MPI_File_preallocate(fh, size, ierror)
TYPE(MPI_File), INTENT(IN) :: fh
INTEGER(KIND=MPI_OFFSET_KIND), INTENT(IN) :: size
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INPUT/OUTPUT PARAMETER
----------------------
* ``fh``: File handle (handle).
INPUT PARAMETER
---------------
* ``size``: Size to preallocate file, in bytes (integer).
OUTPUT PARAMETER
----------------
* ``ierror``: Fortran only: Error status (integer).
DESCRIPTION
-----------
:ref:`MPI_File_preallocate` ensures that storage space is allocated for the
first *size* bytes of the file associated with *fh*.
:ref:`MPI_File_preallocate` can be a very time-consuming operation.
:ref:`MPI_File_preallocate` is collective; all processes in the group must pass
identical values for *size*. Regions of the file that have previously
been written are unaffected. For newly allocated regions of the file,
:ref:`MPI_File_preallocate` has the same effect as writing undefined data. If
size is larger than the current file size, the file size increases to
*size*. If *size* is less than or equal to the current file size, the
file size is unchanged.
The treatment of file pointers, pending nonblocking accesses, and file
consistency is the same as with :ref:`MPI_File_set_size`. If
``MPI_MODE_SEQUENTIAL`` mode was specified when the file was opened, it is
erroneous to call this routine.
NOTES
-----
When using the collective routine :ref:`MPI_File_set_size` on a UNIX file, if
the size that is set is smaller than the current file size, the file is
truncated at the position defined by size. If the size is set to be
larger than the current file size, the file size becomes the set size.
When the file size is increased this way with :ref:`MPI_File_set_size`, new
regions are created in the file with displacements between the old file
size and the larger, newly set file size.
Sun MPI I/O does not necessarily allocate file space for such new
regions. You may reserve file space either by using :ref:`MPI_File_preallocate`
or by performing a read or write to certain bytes.
ERRORS
------
.. include:: ./ERRORS.rst
|