In the three previous sections we wrote and read MPI files in parallel by manipulating file pointers explicitly and by moving the pointers in terms of bytes, e.g., 800 bytes forward, or 800 bytes back. This worked, but this is a pretty low level way of doing things and therefore prone to mistakes. There was nothing in the way we accessed the files that would prevent, say, process of rank 3 overwriting data written by process of rank 4. Furthermore data itself was written and read in the simplest way possible, e.g., as a string of integers or a string of bytes.
MPI provides a mechanism for automating this whole process and structuring it in a high level way, so that processes never step on each other's toes - and yet all writes and reads occur in parallel. The same mechanism is used to access data not in terms of bytes or low level types such as integers or doubles, but in terms of whole data structures. In this process file pointers are advanced in terms of the data structures too.
This mechanism is called file views. The view that a given process has of an open file is defined in terms of two data types, the elementary data type and the file type. The elementary data type may be quite complex, it may be a whole large structure that contains some doubles, some integers, some strings and even other structures.
The way the file is then partitioned amongst the processes is defined in terms of the file type, which becomes the template for accessing the file by the processes. The file type should be constructed from multiple instances of the same elementary type. Every process is then expected to define the file type differently, which, if such definitions are consistent, guarantees that the processes will not step on each other's toes.
In order to make this concept more palatable to the reader, we have to go back to the very concept of an MPI data type and cover it in some depth. The following section is going to do just this, and then we'll go back to MPI-IO and see how the MPI data construction and manipulation utilities play there.