[mpich-discuss] Parallel MPI read from a single file

Dorian Krause ddkrause at uni-bonn.de
Tue Dec 29 19:21:11 CST 2009


On 12/30/09 12:36 AM, Burak ISIKLI wrote:
>
> The mistake is not in your application per se. MPI I/O is not
>
> intended to read in general text files - it is intended for reading
> files written by the MPI I/O interface. It definitely doesn't do the
> string to integer conversion necessary to read in your input file.
>

The MPI I/O specifies function for *binary* input/output. The problem 
with your application is not that you read a file which wasn't written 
with an MPI application but rather that you try to read an ASCII file.

You can parse the input you read using e.g. sscanf() much like you would 
read from a file stream. The problem with ASCII files (in many 
situations I came across) however is that you don't know which part of 
the file should be read by which process as the number of bytes e.g. for 
representing a 32 bit integer depends on its value (for example the "1" 
needs only one byte whereas "10" requires two bytes). Therefore 
typically you can't say: Read the first xxx bytes on proc 0, the next 
yyy bytes on proc 1 and so forth.
If all your files have the same line length (padded by widespaces) you 
can read them easily but it is easy to mess up your input...

Regards,
Dorian



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20091230/2ed6dbef/attachment.htm>


More information about the mpich-discuss mailing list