I'm trying to write a parallel IO program with MPI, I'm required to write the data to the file with a format as: 02 03 04
in the file instead of 2 3 4
.
fprintf(fpOut,"%.2d ",var);
Would be the serial counterpart of what I'm trying to do. I've looked around but couldn't find any answers so far. Any idea on how I might go about this?
MPI_IO
writes binary data (vs text/formatted data).
So if you really want to write in parallel, you can use an intermediate buffer, and then write it, for example
char buf[4];
sprintf(buf, "%.2d ", var);
MPI_File_write_at(buf, 3, MPI_CHAR, ...);
That being said, you might want to reconsider your workflow: