Next: , Previous: , Up: Files   [Index]


2.2 Get error message corresponding to error status: ncmpi_strerror

The function ncmpi_strerror returns a static reference to an error message string corresponding to an integer netCDF error status or to a system error number, presumably returned by a previous call to some other PnetCDF function. The list of netCDF error status codes is available in the appropriate include file for each language binding.

Operational Mode

This API is not associated to any opened file and hence can be called anytime.

Usage

const char * ncmpi_strerror(int ncerr);
ncerr

An error status that might have been returned from a previous call to some PnetCDF function.

Errors

If you provide an invalid integer error status that does not correspond to any netCDF error message or or to any system error message (as understood by the system strerror function), ncmpi_strerror returns a string indicating that there is no such error status.

Example

Here is an example of a simple error handling function that uses ncmpi_strerror to print the error message corresponding to the netCDF error status returned from any PnetCDF function call and then abort the MPI program:

#include <pnetcdf.h>
   ...
void handle_error(int status) {
    if (status != NC_NOERR) {
        fprintf(stderr, "%s\n", ncmpi_strerror(status));
        MPI_Abort(MPI_COMM_WORLD, -1);
    }
}

Next: , Previous: , Up: Files   [Index]