Error in MPI_File_open

Rob Latham robl at mcs.anl.gov
Wed Jun 26 15:17:44 CDT 2013


On Wed, Jun 26, 2013 at 03:53:57PM -0400, Aroma Mahendru wrote:
> Actually I did compile and execute the basic mpi program given there. It
> executed without any errors.  But am I supposed to see any file created as
> well ?

That simple test program doesn't check for errors.  It ensures your
MPI library knows about MPI-IO routines.  In 2013 it would be shocking
if it did not. 

It *should* create a zero-length file called "testfile" in the current
directory.  If it did not, try again with this version with a bit more 
error checking/reporting:

static void handle_error(int errcode, const char *str)
{
        char msg[MPI_MAX_ERROR_STRING];
        int resultlen;
        MPI_Error_string(errcode, msg, &resultlen);
        fprintf(stderr, "%s: %s\n", str, msg);
        MPI_Abort(MPI_COMM_WORLD, 1);
}

#include <stdio.h>
#include <mpi.h>
int main(int argc, char **argv) {
    MPI_File fh;
    int ret;
    MPI_Init(&argc, &argv);
    ret = MPI_File_open(MPI_COMM_WORLD, "testfile", MPI_MODE_CREATE | MPI_MODE_RDWR,
                  MPI_INFO_NULL, &fh);
    if (ret != MPI_SUCCESS) handle_error(ret, "MPI_File_open");
    MPI_File_close(&fh);
    MPI_Finalize();
    return 0;
}

-- 
Rob Latham
Mathematics and Computer Science Division
Argonne National Lab, IL USA


More information about the parallel-netcdf mailing list