xref: /petsc/src/sys/tests/ex74.c (revision 49abdd8a111d9c2ef7fc48ade253ef64e07f9b37)
1 static char help[] = "Check MPI error strings. Crashes with known error with MPICH.\n";
2 
3 #include <petscsys.h>
4 
5 int main(int argc, char **argv)
6 {
7   PetscFunctionBeginUser;
8   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
9 
10   for (PetscMPIInt err = 1; err <= MPI_ERR_LASTCODE; err++) {
11     PetscMPIInt len;
12     char        errorstring[MPI_MAX_ERROR_STRING];
13 
14     MPI_Error_string(err, (char *)errorstring, &len);
15     PetscCheck(len < MPI_MAX_ERROR_STRING, PETSC_COMM_WORLD, PETSC_ERR_LIB, "Error excessive string length from MPI_Error_string()");
16     // PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Error code %d length %d string %s\n", err, len, errorstring));
17   }
18 
19   PetscCall(PetscFinalize());
20   return 0;
21 }
22 
23 /*TEST
24 
25    test:
26      requires: defined(PETSC_HAVE_OPENMPI)
27 
28 TEST*/
29