#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.
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:
And then define this macro:
So I can call routines like this: