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


2.3 Get the string name of a NC error code: ncmpi_strerrno

The function ncmpi_strerrno returns a character string containing the name of the NC error code. For instance, ncmpi_strerrno(NC_EBADID) returns string "NC_EBADID".

Operational Mode

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

Usage

const char * ncmpi_strerrno(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_strerrno 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_strerrno to print the error code name of a netCDF error code returned from any PnetCDF function call.

#include <pnetcdf.h>
   ... 
void handle_error(int err) {
    if (err != NC_NOERR) {
        fprintf(stderr, "NC error code name: %s\n", ncmpi_strerrno(err));
        MPI_Abort(MPI_COMM_WORLD, -1);
    }
}

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