|
20 | 20 |
|
21 | 21 | /*----< ncmpii_error_mpi2nc() -----------------------------------------------*/ |
22 | 22 | /* translate MPI error codes to PnetCDF/netCDF error codes */ |
23 | | -int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */ |
24 | | - char *err_msg) /* extra error message */ |
| 23 | +int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */ |
| 24 | + const char *err_msg) /* extra error message */ |
25 | 25 | { |
26 | 26 | int errorclass, errorStringLen; |
27 | 27 | char errorString[MPI_MAX_ERROR_STRING]; |
| 28 | + const char *dump_str = (err_msg == NULL) ? "" : err_msg; |
28 | 29 |
|
29 | 30 | /* check for specific error codes understood by PnetCDF */ |
30 | 31 |
|
@@ -65,14 +66,13 @@ int ncmpii_error_mpi2nc(int mpi_errorcode, /* returned value from MPI call */ |
65 | 66 | */ |
66 | 67 |
|
67 | 68 | MPI_Error_string(mpi_errorcode, errorString, &errorStringLen); |
68 | | - if (err_msg == NULL) err_msg = ""; |
69 | 69 | #ifdef PNETCDF_DEBUG |
70 | 70 | /* report the world rank */ |
71 | 71 | int rank; |
72 | 72 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); |
73 | | - printf("rank %d: MPI error (%s) : %s\n", rank, err_msg, errorString); |
| 73 | + printf("rank %d: MPI error (%s) : %s\n", rank, dump_str, errorString); |
74 | 74 | #else |
75 | | - printf("MPI error (%s) : %s\n", err_msg, errorString); |
| 75 | + printf("MPI error (%s) : %s\n", dump_str, errorString); |
76 | 76 | #endif |
77 | 77 |
|
78 | 78 | return NC_EFILE; /* other unknown file I/O error */ |
|
0 commit comments