1

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

francescalus
  • 30,576
  • 16
  • 61
  • 96
futurewind
  • 11
  • 2
  • 1
    It's better to post independent questions instead of two questions in a single one. – venerik Jan 26 '14 at 17:00
  • @francescalus is right - MPI IO writes output as binary files, which is generally the right thing for scientific computing data (as opposed to log files describing the status of the calculation so far, etc) – Jonathan Dursi Jan 26 '14 at 17:51

1 Answers1

0

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.

francescalus
  • 30,576
  • 16
  • 61
  • 96
  • Thanks. @francescalus, so MPI I/O can't output ASCII file at all, regardless of what view I set? Because I am debugging and want to know if the output is what I want. Or I could using MPI I/O to read the file and output the data in a readable manner? – futurewind Jan 26 '14 at 19:59
  • @futurewind Well, they're just bytes, so you _could_ encode human-readable log messages... But as Jonathan Dursi says above, MPI I/O is really for your data so if you want easy debugging other approaches may be better. Of course, you'll want to read the data eventually, so whichever data analysis setup you have can help with the checking just the same. – francescalus Jan 26 '14 at 21:24