00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <config.h>
00010 #include <stdio.h>
00011 #include <stdarg.h>
00012 #include <stdlib.h>
00013
00014
00015 #ifdef USE_NETCDF4
00016 #include <netcdf3.h>
00017 #include <nc3convert.h>
00018 #else
00019 #include "netcdf.h"
00020 #endif
00021
00022 #ifndef NO_STRERROR
00023 #include <string.h>
00024 #else
00025
00026 static char *
00027 strerror(int errnum)
00028 {
00029 extern int sys_nerr;
00030 extern char *sys_errlist[];
00031
00032 if(errnum < 0 || errnum >= sys_nerr) return NULL;
00033
00034 return sys_errlist[errnum];
00035 }
00036 #endif
00037
00038
00039 #ifdef vms
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <errno.h>
00050 #include <descrip.h>
00051 #include <ssdef.h>
00052
00053 static const char *
00054 vms_strerror( int status )
00055 {
00056 short msglen;
00057 static char msgbuf[256];
00058 $DESCRIPTOR(message, msgbuf);
00059 register ret;
00060
00061 msgbuf[0] = 0;
00062 ret = SYS$GETMSG(status, &msglen, &message, 15, 0);
00063
00064 if(ret != SS$_BUFFEROVF && ret != SS$_NORMAL) {
00065 (void) strcpy(msgbuf, "EVMSERR");
00066 }
00067 return(msgbuf);
00068 }
00069 #endif
00070
00071
00072 static char unknown[] = "Unknown Error";
00073
00074
00075 const char *
00076 nc_strerror(int err)
00077 {
00078
00079 #ifdef vms
00080 if(err == EVMSERR)
00081 {
00082 return vms_strerror(err);
00083 }
00084
00085 #endif
00086
00087 if(NC_ISSYSERR(err))
00088 {
00089 const char *cp = (const char *) strerror(err);
00090 if(cp == NULL)
00091 return unknown;
00092
00093 return cp;
00094 }
00095
00096
00097 switch (err) {
00098 case NC_NOERR:
00099 return "No error";
00100 case NC_EBADID:
00101 return "Not a netCDF id";
00102 case NC_ENFILE:
00103 return "Too many netCDF files open";
00104 case NC_EEXIST:
00105 return "netCDF file exists && NC_NOCLOBBER";
00106 case NC_EINVAL:
00107 return "Invalid argument";
00108 case NC_EPERM:
00109 return "Write to read only";
00110 case NC_ENOTINDEFINE:
00111 return "Operation not allowed in data mode";
00112 case NC_EINDEFINE:
00113 return "Operation not allowed in define mode";
00114 case NC_EINVALCOORDS:
00115 return "Index exceeds dimension bound";
00116 case NC_EMAXDIMS:
00117 return "NC_MAX_DIMS exceeded";
00118 case NC_ENAMEINUSE:
00119 return "String match to name in use";
00120 case NC_ENOTATT:
00121 return "Attribute not found";
00122 case NC_EMAXATTS:
00123 return "NC_MAX_ATTRS exceeded";
00124 case NC_EBADTYPE:
00125 return "Not a netCDF data type or _FillValue type mismatch";
00126 case NC_EBADDIM:
00127 return "Invalid dimension id or name";
00128 case NC_EUNLIMPOS:
00129 return "NC_UNLIMITED in the wrong index";
00130 case NC_EMAXVARS:
00131 return "NC_MAX_VARS exceeded";
00132 case NC_ENOTVAR:
00133 return "Variable not found";
00134 case NC_EGLOBAL:
00135 return "Action prohibited on NC_GLOBAL varid";
00136 case NC_ENOTNC:
00137 return "Not a netCDF file";
00138 case NC_ESTS:
00139 return "In Fortran, string too short";
00140 case NC_EMAXNAME:
00141 return "NC_MAX_NAME exceeded";
00142 case NC_EUNLIMIT:
00143 return "NC_UNLIMITED size already in use";
00144 case NC_ENORECVARS:
00145 return "nc_rec op when there are no record vars";
00146 case NC_ECHAR:
00147 return "Attempt to convert between text & numbers";
00148 case NC_EEDGE:
00149 return "Start+count exceeds dimension bound";
00150 case NC_ESTRIDE:
00151 return "Illegal stride";
00152 case NC_EBADNAME:
00153 return "Attribute or variable name contains illegal characters";
00154 case NC_ERANGE:
00155 return "Numeric conversion not representable";
00156 case NC_ENOMEM:
00157 return "Memory allocation (malloc) failure";
00158 case NC_EVARSIZE:
00159 return "One or more variable sizes violate format constraints";
00160 case NC_EDIMSIZE:
00161 return "Invalid dimension size";
00162 case NC_ETRUNC:
00163 return "File likely truncated or possibly corrupted";
00164 }
00165
00166 return unknown;
00167 }