futurewind
futurewind

Reputation: 11

Unrecognizable characters in the file written by mpi file write

I was beginning to learn mpi i/o for my molecular dynamics code. First, I tried to run this code:

http://www.mcs.anl.gov/research/projects/mpi/usingmpi2/examples/starting/io3f_f90.htm

After compiling and running, I got 'testfile'. But when I 'vim testfile', I see a lot of unrecognizable character such as '^A^@^@^@^B^@^@^@^C^@^@^@^D^@^@^@^E^@^@^@^F^@^@^@^G^@^'. And I can't open it in gedit either (it said the file is of unknown type)

Any idea what happened? I did not modify the code at all.

I used Open MPI 1.7 and ifort 13 on Ubuntu, the processor is intel i7 (4 cores/8 threads) on my laptop. I am sure that the MPI works. I used -np = 4 for this test.

Thanks

Upvotes: 1

Views: 553

Answers (1)

francescalus
francescalus

Reputation: 32366

MPI I/O is to/from binary files. In particular, your view is set to native:

``native''
Data in this representation is stored in a file exactly as it is in memory.

If what you quote is the start of the file, then that corresponds to the example file writing 0 to 8 as 4-byte little-endian integers. vim is merely representing what would be non-printing ASCII characters. Or, as hexdump would have it

00000000 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 |................|

etc.

To continue the Fortran theme, you can read this output file either using MPI I/O again, or with stream access in a normal open statement in a serial program.

Upvotes: 0

Related Questions