Q:

How to use and interpret MPI-IO Error codes?

#include <stdio.h>
#include <iostream>
#include <Windows.h>
#include <C:\Program Files\Microsoft MPI\Inc\mpi.h>

using namespace std;

#define BUFSIZE 128

int main (int argc,  char *argv[])
{

    int err;
    int rank;
    int size;
    double start_time = 0.0;
    double end_time;
    MPI_Comm comm = MPI_COMM_WORLD;
    MPI_File file;

    char cbuf[BUFSIZE];

    for(int i = 0; i < BUFSIZE; i++)
    {
        cbuf[i] = 'a' + i;
    }

    if(err = MPI_Init(&argc, &argv))
    {
        printf("%s \n", "Error! MPI is halted!");
        MPI_Abort(comm, err);
    }

    MPI_Comm_size(comm, &size);
    MPI_Comm_rank(comm, &rank);

    if(rank == 0)
    {
        start_time = MPI_Wtime();
    }

    err = MPI_File_open(comm, "testfile", MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &file);

    if(err != MPI_SUCCESS)
    {
        printf("Error %d! Can't open the file!\n", err);
        MPI_Abort(comm, err);
        return EXIT_FAILURE;
    }

    err = MPI_File_set_view(file, (MPI_Offset) (rank * BUFSIZE * sizeof(char)), MPI_CHAR, MPI_CHAR, "native", MPI_INFO_NULL);

    if(err != MPI_SUCCESS)
    {
        printf("%s \n", "Error! Can't set the view!");
        MPI_Abort(comm, err);
        return EXIT_FAILURE;
    }

    err = MPI_File_write(file, cbuf, BUFSIZE, MPI_CHAR, MPI_STATUSES_IGNORE);

    if(err != MPI_SUCCESS)
    {
        printf("%s \n", "Error! Problems with writing!");
        MPI_Abort(comm, err);
        return EXIT_FAILURE;
    }

    MPI_File_close(&file);

    if(rank == 0)
    {
        end_time = MPI_Wtime();
        printf("Time elapsed : %f seconds", (end_time - start_time) * 1000);
    }

    MPI_Finalize();

    return EXIT_SUCCESS;
}

I'm trying to write some symbols to a file with MPI.  When I do that, I get an errorcode of 288 and the file can't be opened. I used command line: mpiexec -n 10 myapp.exe. I was searching for the errorcode but didn't find anything at all. 

A:

Go one step further.  Your error code doesn't mean anything by itself.  But, you can feed that code to MPI_Error_string and get something more human readable.  I have this function in every MPI-IO code I write:
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);
}

And then define this macro:
#define MPI_CHECK(fn) { int errcode; errcode = (fn);\
     if (errcode != MPI_SUCCESS) handle_error  (errcode, #fn ); }

So I can call routines like this:
CHECK(MPI_File_open(comm, "testfile", 
    MPI_MODE_CREATE | MPI_MODE_RDWR, MPI_INFO_NULL, &file) );

