MPI_File_read - Uses individual file pointer to read a
       file


SYNOPSIS

       C:

            #include "mpi.h"

            int MPI_File_read(MPI_File fh, void *buf, int count,
            MPI_Datatype datatype, MPI_Status status)

       Fortran:

            INCLUDE "mpif.h" (or USE MPI)

            <type> BUF(*)
            INTEGER fh, count, datatype, status(MPI_STATUS_SIZE),
            ierror

            CALL MPI_FILE_READ(fh, buf, count, datatype,
            status, ierror)


DESCRIPTION

       MPI_File_read reads a file using the individual file
       pointer.  This routine accepts the following arguments:

       fh        Specifies the file handle (handle)

       buf       Returns the initial address of the buffer
                 (choice)

       count     Specifies the number of elements in the buffer
                 (nonnegative integer)

       datatype  Specifies the data type of each buffer element
                 (handle)

       status    Returns the status object (status)

       ierror    Specifies the return code value for successful
                 completion, which is in MPI_SUCCESS.
                 MPI_SUCCESS is defined in the mpif.h file.

   Notes for Fortran
       All MPI objects (for example, MPI_Datatype, MPI_Comm,
       MPI_File) are of type INTEGER.


EXAMPLES

       The following Fortran code fragment is an example of
       reading a file until the end of file is reached:

       !   Call routine "process_input" if all requested data is read.
       !   The Fortran 90 "exit" statement exits the loop.

       integer   bufsize, numread, totprocessed, status(MPI_STATUS_SIZE)
             parameter (bufsize=100)
             real      localbuffer(bufsize)

       call MPI_FILE_OPEN( MPI_COMM_WORLD, 'myoldfile', &
                                 MPI_MODE_RDONLY, MPI_INFO_NULL, myfh, ierr )
             call MPI_FILE_SET_VIEW( myfh, 0, MPI_REAL, MPI_REAL, 'native', &
                                 MPI_INFO_NULL, ierr )
             totprocessed = 0
             do
                call MPI_FILE_READ( myfh, localbuffer, bufsize, MPI_REAL, &
                                    status, ierr )
                call MPI_GET_COUNT( status, MPI_REAL, numread, ierr )
                call process_input( localbuffer, numread )
                totprocessed = totprocessed + numread
                if ( numread < bufsize ) exit
             enddo

       write(6,1001) numread, bufsize, totprocessed
       1001  format( "No more data:  read", I3, "and expected", I3, &
                     "Processed total of", I6, "before terminating job." )

       call MPI_FILE_CLOSE( myfh, ierr )


SEE ALSO

       MPI_File_open(3), MPI_IO(3)


Man(1) output converted with man2html