Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |  

This web mail archive is frozen.

This page is part of a frozen web archive of this mailing list.

You can still navigate around this archive, but know that no new mails have been added to it since July of 2016.

Click here to be taken to the new web archives of this list; it includes all the mails that are in this frozen archive plus all new mails that have been sent to the list since it was migrated to the new archives.

Subject: Re: [OMPI users] opening a file with MPI-IO
From: Rob Latham (robl_at_[hidden])
Date: 2013-07-19 15:23:57


On Fri, May 17, 2013 at 11:00:36AM +0200, Peter van Hoof wrote:
> Dear users,
>
> I have been banging my head against the wall for some time to find a
> reliable and portable way to determine if a call to
> MPI::File::Open() was successful or not.

Sorry for the long delay in responding

In C, we do it like this:

static void handle_error(int errcode, 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);
}

errcode = MPI_File_open(MPI_COMM_SELF, filename,
                MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL,
                &fh);
if (errcode != MPI_SUCCESS) handle_error(errcode, "MPI_FILE_OPEN");

With the C++ bindings... ugh what a mess. I had to crack open the
yellow book to find out the answer. But on page 18 it's pretty
clear:

Quoting: C++ functions do not return error codes [...]

More Quoting: Advice to Users: C++ programmers that want to handle MPI
errors on their own should use th MPI::ERRORS_THROW_EXCEPTIONS error
handler, rather than MPI::ERROR_RETURN, which is used for that purpose
in C.

It's important to note that MPI-IO routines *do* use ERROR_RETURN as
the error handler, so you will have to take the additional step of
setting that.

==rob

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