LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: Bill Wendling (wendling_at_[hidden])
Date: 2003-08-04 15:06:52


Hi,

I'm sorry if this is a repeat question but I didn't find it in a cursory
look at the archives.

I was wondering if there's anything wrong with this sample program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "mpi.h"

int main(int argc, char **argv)
{
    char *filename = "/tmp/zzz.h5";
    int mpi_size, mpi_rank;
    MPI_File fh;

    MPI_Init(&argc, &argv);
    MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
    MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);

    MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_CREATE | MPI_MODE_WRONLY,
                  MPI_INFO_NULL, &fh);
    MPI_File_set_size(fh, 976);

    if (mpi_rank == 1)
        MPI_File_write_at(fh, 0, "hello world", 12, MPI_BYTE, MPI_STATUS_IGNORE);
    else
        MPI_File_write_at(fh, 12, "NOT", 4, MPI_BYTE, MPI_STATUS_IGNORE);

    MPI_Barrier(MPI_COMM_WORLD);
    system("cp /tmp/zzz.h5 zzz.h5");
    MPI_File_close(&fh);
    MPI_Finalize();
    return 0;
}

It outputs only "NOT" at offset 12 in the file and not the "hello world"
before it. I'm not sure what's wrong with the code. Does anyone have any
ideas?

I'm not subscribed to this mailing list, so could you please CC me in all
responses? Thank you!

-- 
|| Bill Wendling            "Real Programmers have a Snoopy Calendar
|| wendling_at_[hidden]    of '69 hanging on their wall"
|| Coding Simian                       -- Toon Moene