Skip to content

Commit

Permalink
test/io: clarify the purpose of MPI_File_delete
Browse files Browse the repository at this point in the history
We call MPI_File_delete in case there is a leftover testfile, which will
interfere with later MPI_File_open. Not checking error return and call
"delete" on a seemingly non-existent file is myterious. Add a comment
and error checking for maintenance.
  • Loading branch information
hzhou committed Dec 6, 2024
1 parent 25cb03c commit 26d1278
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/mpi/io/resized.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ int main(int argc, char **argv)
strcpy(filename, *argv);
}

MPI_File_delete(filename, MPI_INFO_NULL);
/* delete the file in case it exists. If it exists, it should return MPI_ERR_NO_SUCH_FILE */
mpi_errno = MPI_File_delete(filename, MPI_INFO_NULL);
if (mpi_errno != MPI_SUCCESS) {
int error_class = 0;
MPI_Error_class(mpi_errno, &error_class);
if (error_class != MPI_ERR_NO_SUCH_FILE) {
printf
("MPI_File_delete returned error code %x, error class %x, expect error class MPI_ERR_NO_SUCH_FILE\n",
mpi_errno, error_class);
errs++;
}
}

/* create a resized type comprising an integer with an lb at sizeof(int) and extent = 3*sizeof(int) */
lb = sizeof(int);
Expand Down

0 comments on commit 26d1278

Please sign in to comment.