#include #include #include /* unlink() */ #include int main(int argc, char **argv) { int err; MPI_File fh; MPI_Init(&argc, &argv); if (argc != 2) { printf("Usage: %s filename\n",argv[0]); MPI_Finalize(); return 1; } unlink(argv[1]); /* delete the file and ignore the error */ err = MPI_File_open(MPI_COMM_WORLD, argv[1], MPI_MODE_RDONLY, MPI_INFO_NULL, &fh); if (err != MPI_SUCCESS) { char err_string[MPI_MAX_ERROR_STRING+1]; int err_len, errorclass; MPI_Error_string(err, err_string, &err_len); MPI_Error_class(err, &errorclass); printf("non-exiting file \"%s\"\n",argv[1]); printf("MPI error string: %s\n",err_string); if (errorclass == MPI_ERR_NO_SUCH_FILE) printf("Error class = MPI_ERR_NO_SUCH_FILE\n"); else if (errorclass == MPI_ERR_IO) printf("Error class = MPI_ERR_IO\n"); else printf("Error class = %d\n",errorclass); } else { MPI_File_close(&fh); printf("Open non-existing file %s unexpected succeeded\n",argv[1]); } MPI_Finalize(); return 0; }