Some additional errors reared up after fixing the main frustrating one. Working towards fixing them.

This commit is contained in:
Ward Fisher 2015-12-24 01:37:42 +00:00
parent 6eec405e13
commit 925da14d2a
11 changed files with 155 additions and 134 deletions

40
gdb.txt
View File

@ -1,14 +1,34 @@
break cdf5_gh159_test.c:52
break test_nc_put_var1
commands
break util.c:960 if i == 6 && j == 0
commands
break ncio_get
continue
end
break cdf5_gh159_test.c:145
commands
break ncx_putn_uchar_double
break ncx.c:4845
commands
print ((uchar *)*xpp)[0]
print ((uchar *)*xpp)[1]
print ((uchar *)*xpp)[2]
end
continue
end
break util.c:963 if text != expect && i == 6 && j == 0
break util.c:964
###
#break test_get.c:8340 if i == -1 && j == 0
#break util.c:1035 if i == -1 && j == 0
#break util.c:1040
####
#break cdf5_gh159_test.c:52
#commands
#continue
#end
#break cdf5_gh159_test.c:145
#commands
#break ncx_putn_uchar_double
#break ncx.c:4845
#commands
#print ((uchar *)*xpp)[0]
#print ((uchar *)*xpp)[1]
#print ((uchar *)*xpp)[2]
#end
#end

View File

@ -994,10 +994,10 @@ nc_del_att(int ncid, int varid, const char *name);
EXTERNL int
nc_put_att_text(int ncid, int varid, const char *name,
size_t len, const char *op);
size_t len, const signed char *op);
EXTERNL int
nc_get_att_text(int ncid, int varid, const char *name, char *ip);
nc_get_att_text(int ncid, int varid, const char *name, signed char *ip);
EXTERNL int
nc_put_att_uchar(int ncid, int varid, const char *name, nc_type xtype,
@ -1079,10 +1079,10 @@ nc_get_att_ulonglong(int ncid, int varid, const char *name,
EXTERNL int
nc_put_att_string(int ncid, int varid, const char *name,
size_t len, const char **op);
size_t len, const signed char **op);
EXTERNL int
nc_get_att_string(int ncid, int varid, const char *name, char **ip);
nc_get_att_string(int ncid, int varid, const char *name, signed char **ip);
/* End {put,get}_att */
/* Begin _var */
@ -1131,7 +1131,7 @@ EXTERNL int
nc_put_var1_text(int ncid, int varid, const size_t *indexp, const char *op);
EXTERNL int
nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip);
nc_get_var1_text(int ncid, int varid, const size_t *indexp, signed char *ip);
EXTERNL int
nc_put_var1_uchar(int ncid, int varid, const size_t *indexp,

View File

@ -23,7 +23,7 @@ be used to get attributes of user-defined type. We recommend that they
type safe versions of this function be used where possible.
\param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid().
\param varid Variable ID of the attribute's variable, or ::NC_GLOBAL
@ -53,7 +53,7 @@ nc_get_att(int ncid, int varid, const char *name, void *value)
return ncp->dispatch->get_att(ncid, varid, name, value, xtype);
}
/*! \} */
/*! \} */
/*!
\ingroup attributes
@ -67,7 +67,7 @@ file is opened with nc_open(). Getting an attribute copies the value
from the in-memory store, and does not incure any file I/O penalties.
\param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid().
\param varid Variable ID of the attribute's variable, or ::NC_GLOBAL
@ -96,14 +96,14 @@ the length of the attributes.
\code
#include <netcdf.h>
...
int status;
int ncid;
int rh_id;
int vr_len, t_len;
double *vr_val;
char *title;
int status;
int ncid;
int rh_id;
int vr_len, t_len;
double *vr_val;
char *title;
extern char *malloc()
...
status = nc_open("foo.nc", NC_NOWRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
@ -115,21 +115,21 @@ the length of the attributes.
if (status != NC_NOERR) handle_error(status);
status = nc_inq_attlen (ncid, NC_GLOBAL, "title", &t_len);
if (status != NC_NOERR) handle_error(status);
vr_val = (double *) malloc(vr_len * sizeof(double));
title = (char *) malloc(t_len + 1);
title = (char *) malloc(t_len + 1);
status = nc_get_att_double(ncid, rh_id, "valid_range", vr_val);
if (status != NC_NOERR) handle_error(status);
status = nc_get_att_text(ncid, NC_GLOBAL, "title", title);
if (status != NC_NOERR) handle_error(status);
title[t_len] = '\0';
title[t_len] = '\0';
...
\endcode
*/
/*! \{ */
int
nc_get_att_text(int ncid, int varid, const char *name, char *value)
nc_get_att_text(int ncid, int varid, const char *name, signed char *value)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
@ -246,11 +246,11 @@ nc_get_att_ulonglong(int ncid, int varid, const char *name, unsigned long long *
}
int
nc_get_att_string(int ncid, int varid, const char *name, char **value)
nc_get_att_string(int ncid, int varid, const char *name, signed char **value)
{
NC *ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->get_att(ncid,varid,name,(void*)value, NC_STRING);
}
/*! \} */
/*! \} */

View File

@ -23,7 +23,7 @@ available in netCDF-4/HDF5 files, when ::NC_CLASSIC_MODEL has not been
used in nc_create().
\param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid().
\param varid Variable ID of the variable to which the attribute will
@ -46,12 +46,12 @@ is still in initial define mode.
*/
int
nc_put_att_string(int ncid, int varid, const char *name,
size_t len, const char** value)
size_t len, const signed char** value)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->put_att(ncid, varid, name, NC_STRING,
return ncp->dispatch->put_att(ncid, varid, name, NC_STRING,
len, (void*)value, NC_STRING);
}
@ -61,7 +61,7 @@ Write a text attribute.
Add or change a text attribute. If this attribute is new,
or if the space required to store the attribute is greater than
before, the netCDF dataset must be in define mode.
before, the netCDF dataset must be in define mode.
Although it's possible to create attributes of all types, text and
double attributes are adequate for most purposes.
@ -71,7 +71,7 @@ including user-defined types. We recommend using the type safe
versions of this function whenever possible.
\param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid().
\param varid Variable ID of the variable to which the attribute will
@ -106,16 +106,16 @@ netCDF dataset named foo.nc:
\code
#include <netcdf.h>
...
int status;
int ncid;
int rh_id;
int status;
int ncid;
int rh_id;
static double rh_range[] = {0.0, 100.0};
static char title[] = "example netCDF dataset";
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_redef(ncid);
status = nc_redef(ncid);
if (status != NC_NOERR) handle_error(status);
status = nc_inq_varid (ncid, "rh", &rh_id);
if (status != NC_NOERR) handle_error(status);
@ -127,22 +127,22 @@ netCDF dataset named foo.nc:
strlen(title), title)
if (status != NC_NOERR) handle_error(status);
...
status = nc_enddef(ncid);
status = nc_enddef(ncid);
if (status != NC_NOERR) handle_error(status);
\endcode
*/
int
nc_put_att_text(int ncid, int varid, const char *name,
size_t len, const char *value)
size_t len, const signed char *value)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->put_att(ncid, varid, name, NC_CHAR, len,
return ncp->dispatch->put_att(ncid, varid, name, NC_CHAR, len,
(void *)value, NC_CHAR);
}
/*! \} */
/*! \} */
/*!
\ingroup attributes
Write an attribute.
@ -150,7 +150,7 @@ Write an attribute.
The function nc_put_att_ type adds or changes a variable attribute or
global attribute of an open netCDF dataset. If this attribute is new,
or if the space required to store the attribute is greater than
before, the netCDF dataset must be in define mode.
before, the netCDF dataset must be in define mode.
With netCDF-4 files, nc_put_att will notice if you are writing a
_FillValue attribute, and will tell the HDF5 layer to use the
@ -163,7 +163,7 @@ Although it's possible to create attributes of all types, text and
double attributes are adequate for most purposes.
\param ncid NetCDF or group ID, from a previous call to nc_open(),
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_create(), nc_def_grp(), or associated inquiry functions such as
nc_inq_ncid().
\param varid Variable ID of the variable to which the attribute will
@ -196,16 +196,16 @@ netCDF dataset named foo.nc:
\code
#include <netcdf.h>
...
int status;
int ncid;
int rh_id;
int status;
int ncid;
int rh_id;
static double rh_range[] = {0.0, 100.0};
static char title[] = "example netCDF dataset";
...
status = nc_open("foo.nc", NC_WRITE, &ncid);
if (status != NC_NOERR) handle_error(status);
...
status = nc_redef(ncid);
status = nc_redef(ncid);
if (status != NC_NOERR) handle_error(status);
status = nc_inq_varid (ncid, "rh", &rh_id);
if (status != NC_NOERR) handle_error(status);
@ -217,7 +217,7 @@ netCDF dataset named foo.nc:
strlen(title), title)
if (status != NC_NOERR) handle_error(status);
...
status = nc_enddef(ncid);
status = nc_enddef(ncid);
if (status != NC_NOERR) handle_error(status);
\endcode
*/
@ -229,7 +229,7 @@ nc_put_att(int ncid, int varid, const char *name, nc_type xtype,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
value, xtype);
}
@ -240,7 +240,7 @@ nc_put_att_schar(int ncid, int varid, const char *name,
NC *ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_BYTE);
}
@ -262,7 +262,7 @@ nc_put_att_short(int ncid, int varid, const char *name,
NC* ncp;
int stat = NC_check_id(ncid, &ncp);
if(stat != NC_NOERR) return stat;
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_SHORT);
}
@ -345,7 +345,7 @@ nc_put_att_uint(int ncid, int varid, const char *name,
int
nc_put_att_longlong(int ncid, int varid, const char *name,
nc_type xtype, size_t len,
nc_type xtype, size_t len,
const long long *value)
{
NC* ncp;
@ -357,7 +357,7 @@ nc_put_att_longlong(int ncid, int varid, const char *name,
int
nc_put_att_ulonglong(int ncid, int varid, const char *name,
nc_type xtype, size_t len,
nc_type xtype, size_t len,
const unsigned long long *value)
{
NC* ncp;
@ -366,4 +366,3 @@ nc_put_att_ulonglong(int ncid, int varid, const char *name,
return ncp->dispatch->put_att(ncid, varid, name, xtype, len,
(void *)value, NC_UINT64);
}

View File

@ -825,7 +825,7 @@ nc_get_var1(int ncid, int varid, const size_t *indexp, void *ip)
}
int
nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip)
nc_get_var1_text(int ncid, int varid, const size_t *indexp, signed char *ip)
{
NC* ncp;
int stat = NC_check_id(ncid, &ncp);

View File

@ -16,14 +16,14 @@
*
* This started out as a general replacement for ONC XDR,
* specifically, the xdrmem family of functions.
*
*
* We eventually realized that we could write more portable
* code if we decoupled any association between the 'C' types
* and the external types. (XDR has this association between the 'C'
* types and the external representations, like xdr_int() takes
* an int argument and goes to an external int representation.)
* an int argument and goes to an external int representation.)
* So, now there is a matrix of functions.
*
*
*/
#include <config.h> /* output of 'configure' */
@ -80,7 +80,7 @@
* For now, netcdf is limited to 32 bit sizes,
* If compiled with support for "large files", then
* netcdf will use a 64 bit off_t and it can then write a file
* using 64 bit offsets.
* using 64 bit offsets.
* see also X_SIZE_MAX, X_OFF_MAX below
*/
#define X_SIZEOF_OFF_T (sizeof(off_t))
@ -112,7 +112,7 @@
#define X_DOUBLE_MAX 1.79769313486230e+308
#else
/* scalb(1. - scalb(.5 , -52), 1024) */
#define X_DOUBLE_MAX 1.7976931348623157e+308
#define X_DOUBLE_MAX 1.7976931348623157e+308
#endif
#define X_DOUBLE_MIN (-X_DOUBLE_MAX)
#define X_DBL_MAX X_DOUBLE_MAX /* alias compatible with limits.h */
@ -124,7 +124,7 @@
/* Begin ncx_len */
/*
* ncx_len_xxx() interfaces are defined as macros below,
* ncx_len_xxx() interfaces are defined as macros below,
* These give the length of an array of nelems of the type.
* N.B. The 'char' and 'short' interfaces give the X_ALIGNED length.
*/
@ -200,7 +200,7 @@ typedef signed char schar;
* uint
* float
* double
* longlong == int64
* longlong == int64
* ulonglong == uint64
*
* Not all combinations make sense.
@ -320,7 +320,7 @@ extern int ncx_put_int_int(void *xp, const int *ip);
* The `ip' argument should point to an array of `nelems' of
* internal_type.
*
* Range errors (NC_ERANGE) for a individual values in the array
* Range errors (NC_ERANGE) for a individual values in the array
* DO NOT terminate the array conversion. All elements are converted,
* with some having undefined values.
* If any range error occurs, the function returns NC_ERANGE.
@ -396,7 +396,7 @@ extern int
ncx_putn_schar_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_schar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
extern int
ncx_pad_putn_schar_schar (void **xpp, size_t nelems, const schar *ip);
extern int
@ -489,7 +489,7 @@ extern int
ncx_putn_uchar_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_uchar_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
extern int
ncx_pad_putn_uchar_schar (void **xpp, size_t nelems, const schar *ip);
extern int
@ -582,7 +582,7 @@ extern int
ncx_putn_short_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_short_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
extern int
ncx_pad_putn_short_schar (void **xpp, size_t nelems, const schar *ip);
extern int
@ -675,7 +675,7 @@ extern int
ncx_putn_ushort_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_ushort_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
extern int
ncx_pad_putn_ushort_schar (void **xpp, size_t nelems, const schar *ip);
extern int
@ -749,7 +749,7 @@ extern int
ncx_putn_int_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_int_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
/*---- uint -----------------------------------------------------------------*/
extern int
ncx_getn_uint_schar (const void **xpp, size_t nelems, schar *ip);
@ -800,7 +800,7 @@ extern int
ncx_putn_uint_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_uint_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
/*---- float ----------------------------------------------------------------*/
extern int
ncx_getn_float_schar (const void **xpp, size_t nelems, schar *ip);
@ -847,7 +847,7 @@ extern int
ncx_putn_float_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_float_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
/*---- double ---------------------------------------------------------------*/
extern int
ncx_getn_double_schar (const void **xpp, size_t nelems, schar *ip);
@ -988,7 +988,7 @@ extern int
ncx_putn_ulonglong_longlong (void **xpp, size_t nelems, const longlong *ip);
extern int
ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
/*
* Other aggregate conversion functions.
@ -998,13 +998,13 @@ ncx_putn_ulonglong_ulonglong(void **xpp, size_t nelems, const ulonglong *ip);
extern int
ncx_getn_text(const void **xpp, size_t nchars, char *cp);
extern int
ncx_pad_getn_text(const void **xpp, size_t nchars, char *cp);
ncx_pad_getn_text(const void **xpp, size_t nchars, signed char *cp);
/* write ASCII characters */
extern int
ncx_putn_text(void **xpp, size_t nchars, const char *cp);
ncx_putn_text(void **xpp, size_t nchars, const signed char *cp);
extern int
ncx_pad_putn_text(void **xpp, size_t nchars, const char *cp);
ncx_pad_putn_text(void **xpp, size_t nchars, const signed char *cp);
/* for symmetry */
#define ncx_getn_char_char(xpp, nelems, fillp) ncx_getn_text(xpp, nelems, fillp)

View File

@ -2109,7 +2109,7 @@ dnl
define(`NCX_GETN_Byte_Body',dnl
`dnl
(void) memcpy(tp, *xpp, nelems);
*xpp = (void *)((char *)(*xpp) + nelems);
*xpp = (void *)((schar *)(*xpp) + nelems);
return ENOERR;
')dnl
dnl dnl dnl

View File

@ -1165,8 +1165,12 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
case CASE(NC_CHAR,NC_CHAR):
case CASE(NC_CHAR,NC_UBYTE):
return getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
break;
#ifdef CHAR_IS_SIGNED
return getNCvx_char_char(ncp,varp,start,nelems,(char*)value);
#else
return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
#endif
break;
case CASE(NC_BYTE,NC_BYTE):
return getNCvx_schar_schar(ncp,varp,start,nelems,(signed char*)value);
break;
@ -1208,13 +1212,13 @@ readNCv(const NC3_INFO* ncp, const NC_var* varp, const size_t* start,
break;
case CASE(NC_SHORT,NC_INT):
return getNCvx_short_int(ncp,varp,start,nelems,(int*)value);
break;
break;
case CASE(NC_SHORT,NC_FLOAT):
return getNCvx_short_float(ncp,varp,start,nelems,(float*)value);
break;
case CASE(NC_SHORT,NC_DOUBLE):
return getNCvx_short_double(ncp,varp,start,nelems,(double*)value);
break;
break;
case CASE(NC_SHORT,NC_INT64):
return getNCvx_short_longlong(ncp,varp,start,nelems,(long long*)value);
break;
@ -1818,7 +1822,7 @@ NC3_get_vara(int ncid, int varid,
int ii;
size_t iocount;
size_t memtypelen;
char* value = (char*) value0; /* legally allow ptr arithmetic */
signed char* value = (signed char*) value0; /* legally allow ptr arithmetic */
const size_t* edges = edges0; /* so we can modify for special cases */
size_t modedges[NC_MAX_VAR_DIMS];
@ -1945,7 +1949,7 @@ NC3_put_vara(int ncid, int varid,
int ii;
size_t iocount;
size_t memtypelen;
char* value = (char*) value0; /* legally allow ptr arithmetic */
signed char* value = (signed char*) value0; /* legally allow ptr arithmetic */
const size_t* edges = edges0; /* so we can modify for special cases */
size_t modedges[NC_MAX_VAR_DIMS];

View File

@ -19,16 +19,16 @@ int numTypes; /* number of netCDF data types to test */
* The read-only tests read files:
* test.nc (see below)
* tests.h (used merely as an example of a non-netCDF file)
*
* The write tests
* read test.nc (see below)
*
* The write tests
* read test.nc (see below)
* write scratch.nc (deleted after each test)
*
*
* The file test.nc is created by running nc_test with the -c (create) option.
* It is described by the following global variables.
*/
/*
/*
* global variables (defined by function init_gvars) describing file test.nc
*/
char dim_name[NDIMS][3];
@ -47,13 +47,13 @@ nc_type gatt_type[NGATTS];
size_t att_len[NVARS][MAX_NATTS];
size_t gatt_len[NGATTS];
/*
/*
* command-line options
*/
int verbose; /* if 1, print details of tests */
int max_nmpt; /* max. number of messages per test */
/*
/*
* Misc. global variables
*/
int nfails; /* number of failures in specific test */
@ -96,7 +96,7 @@ main(int argc, char *argv[])
*/
(void) signal(SIGFPE, SIG_IGN);
verbose = 0;
verbose = 1;
max_nmpt = 8;
/* If you uncomment the nc_set_log_level line, you will get a lot
@ -118,7 +118,7 @@ main(int argc, char *argv[])
numVars = 136;
numTypes = 6;
switch (i)
switch (i)
{
case NC_FORMAT_CLASSIC:
nc_set_default_format(NC_FORMAT_CLASSIC, NULL);
@ -374,4 +374,3 @@ main(int argc, char *argv[])
exit(0);
return 0;
}

View File

@ -6,7 +6,7 @@
#include "tests.h"
/*
/*
* Test nc_strerror.
* Try on a bad error status.
* Test for each defined error status.
@ -72,7 +72,7 @@ test_nc_strerror(void)
}
/*
/*
* Test nc_open.
* If in read-only section of tests,
* Try to open a non-existent netCDF file, check error return.
@ -90,7 +90,7 @@ test_nc_open(void)
int err;
int ncid;
int ncid2;
/* Try to open a nonexistent file */
err = file_open("tooth-fairy.nc", NC_NOWRITE, &ncid);/* should fail */
IF (err == NC_NOERR)
@ -124,17 +124,17 @@ test_nc_open(void)
error("netCDF IDs for first and second nc_open calls should differ");
err = file_create(scratch, NC_NOCLOBBER, &ncid2);
IF (err)
IF (err)
error("nc_create: %s", nc_strerror(err));
else
else
(void) nc_close(ncid2);
err = file_open(scratch, NC_WRITE, &ncid2);
IF (err)
IF (err)
error("nc_open: %s", nc_strerror(err));
else
else
(void) nc_close(ncid2);
err = remove(scratch);
IF (err)
IF (err)
error("remove of %s failed", scratch);
err = nc_close(ncid);
@ -143,7 +143,7 @@ test_nc_open(void)
}
/*
/*
* Test nc_close.
* Try to close a netCDF file twice, check whether second close fails.
* Try on bad handle, check error return.
@ -165,7 +165,7 @@ test_nc_close(void)
err = nc_close(ncid);
IF (err != NC_EBADID)
error("nc_close of closed file should have failed");
/* Try with a bad netCDF ID */
err = nc_close(BAD_ID);/* should fail */
IF (err != NC_EBADID)
@ -180,7 +180,7 @@ test_nc_close(void)
error("nc_close in data mode failed: %s", nc_strerror(err));
err = file_create(scratch, NC_NOCLOBBER, &ncid);
IF (err)
IF (err)
error("nc_create: %s", nc_strerror(err));
err = nc_close(ncid);
IF (err)
@ -191,7 +191,7 @@ test_nc_close(void)
}
/*
/*
* Test nc_inq.
* Try on bad handle, check error return.
* Try in data mode, check returned values.
@ -213,12 +213,12 @@ test_nc_inq(void)
err = file_open(testfile, NC_NOWRITE, &ncid);
IF (err)
error("nc_open: %s", nc_strerror(err));
/* Try on bad handle */
err = nc_inq(BAD_ID, 0, 0, 0, 0);
IF (err != NC_EBADID)
error("bad ncid: status = %d", err);
err = nc_inq(ncid, &ndims, &nvars, &ngatts, &recdim);
IF (err)
error("nc_inq: %s", nc_strerror(err));
@ -230,7 +230,7 @@ test_nc_inq(void)
error("nc_inq: wrong number of global atts returned, %d", ngatts);
else IF (recdim != RECDIM)
error("nc_inq: wrong record dimension ID returned, %d", recdim);
/* Inguire for no info (useless, but should still work) */
err = nc_inq(ncid, 0, 0, 0, 0);
IF (err)
@ -493,14 +493,14 @@ test_nc_inq_dim(void)
err = nc_inq_dim(ncid, i, name, &length);
IF (err)
error("nc_inq_dim: %s", nc_strerror(err));
else IF (strcmp(dim_name[i],name))
else IF (strcmp(dim_name[i],name))
error("name expected: %s, got: %s",dim_name[i],name);
else IF (dim_len[i] != length)
error("size expected: %d, got: %d",dim_len[i],length);
err = nc_inq_dim(ncid, i, name, 0);
IF (err)
error("nc_inq_dim: %s", nc_strerror(err));
else IF (strcmp(dim_name[i],name))
else IF (strcmp(dim_name[i],name))
error("name expected: %s, got: %s",dim_name[i],name);
err = nc_inq_dim(ncid, i, 0, &length);
IF (err)
@ -565,7 +565,7 @@ test_nc_inq_dimname(void)
err = nc_inq_dimname(ncid, i, name);
IF (err)
error("nc_inq_dimname: %s", nc_strerror(err));
else IF (strcmp(dim_name[i],name))
else IF (strcmp(dim_name[i],name))
error("name expected: %s, got: %s",dim_name[i],name);
}
err = nc_close(ncid);
@ -635,7 +635,7 @@ test_nc_inq_var(void)
err = nc_inq_var(ncid, i, name, &datatype, &ndims, dimids, &natts);
IF (err)
error("nc_inq_var: %s", nc_strerror(err));
else IF (strcmp(var_name[i],name))
else IF (strcmp(var_name[i],name))
error("name expected: %s, got: %s",var_name[i],name);
else IF (var_type[i] != datatype)
error("type expected: %d, got: %d",var_type[i],datatype);
@ -648,7 +648,7 @@ test_nc_inq_var(void)
err = nc_inq_var(ncid, i, name, 0, 0, 0, 0);
IF (err)
error("nc_inq_var: %s", nc_strerror(err));
else IF (strcmp(var_name[i],name))
else IF (strcmp(var_name[i],name))
error("name expected: %s, got: %s",var_name[i],name);
err = nc_inq_var(ncid, i, 0, &datatype, 0, 0, 0);
IF (err)
@ -728,7 +728,7 @@ test_nc_inq_varname(void)
err = nc_inq_varname(ncid, i, name);
IF (err)
error("nc_inq_varname: %s", nc_strerror(err));
else IF (strcmp(var_name[i],name))
else IF (strcmp(var_name[i],name))
error("name expected: %s, got: %s",var_name[i],name);
}
err = nc_close(ncid);
@ -1347,25 +1347,25 @@ test_nc_get_att(void)
size_t k;
int err;
double buf[MAX_NELS]; /* (void *) buffer */
char *p; /* (void *) pointer */
signed char *p; /* (void *) pointer */
double expect;
double got;
int nok = 0; /* count of valid comparisons */
err = file_open(testfile, NC_NOWRITE, &ncid);
IF (err)
IF (err)
error("nc_open: %s", nc_strerror(err));
for (i = -1; i < numVars; i++) {
for (j = 0; j < NATTS(i); j++) {
err = nc_get_att(BAD_ID, i, ATT_NAME(i,j), buf);
IF (err != NC_EBADID)
IF (err != NC_EBADID)
error("bad ncid: status = %d", err);
err = nc_get_att(ncid, BAD_VARID, ATT_NAME(i,j), buf);
IF (err != NC_ENOTVAR)
IF (err != NC_ENOTVAR)
error("bad var id: status = %d", err);
err = nc_get_att(ncid, i, "noSuch", buf);
IF (err != NC_ENOTATT)
IF (err != NC_ENOTATT)
error("Bad attribute name: status = %d", err);
err = nc_get_att(ncid, i, ATT_NAME(i,j), buf);
IF (err) {
@ -1373,13 +1373,13 @@ test_nc_get_att(void)
} else {
for (k = 0; k < ATT_LEN(i,j); k++) {
expect = hash(ATT_TYPE(i,j), -1, &k );
p = (char *) buf;
p = (signed char *) buf;
p += k * nctypelen(ATT_TYPE(i,j));
err = nc2dbl( ATT_TYPE(i,j), p, &got );
IF (err)
error("error in nc2dbl");
if (inRange(expect,ATT_TYPE(i,j))) {
IF (!equal(got,expect,ATT_TYPE(i,j),NCT_DOUBLE)) {
IF (!equal(got,expect,ATT_TYPE(i,j),NCT_DOUBLE)) {
error("value read not that expected");
if (verbose) {
error("\n");
@ -1418,19 +1418,19 @@ test_nc_inq_att(void)
size_t n;
err = file_open(testfile, NC_NOWRITE, &ncid);
IF (err)
IF (err)
error("nc_open: %s", nc_strerror(err));
for (i = -1; i < numVars; i++) {
for (j = 0; j < NATTS(i); j++) {
err = nc_inq_att(BAD_ID, i, ATT_NAME(i,j), &t, &n);
IF (err != NC_EBADID)
IF (err != NC_EBADID)
error("bad ncid: status = %d", err);
err = nc_inq_att(ncid, BAD_VARID, ATT_NAME(i,j), &t, &n);
IF (err != NC_ENOTVAR)
IF (err != NC_ENOTVAR)
error("bad var id: status = %d", err);
err = nc_inq_att(ncid, i, "noSuch", &t, &n);
IF (err != NC_ENOTATT)
IF (err != NC_ENOTATT)
error("Bad attribute name: status = %d", err);
err = nc_inq_att(ncid, i, ATT_NAME(i,j), &t, &n);
IF (err) {
@ -1438,7 +1438,7 @@ test_nc_inq_att(void)
} else {
IF (t != ATT_TYPE(i,j))
error("type not that expected");
IF (n != ATT_LEN(i,j))
IF (n != ATT_LEN(i,j))
error("length not that expected");
}
}
@ -1611,4 +1611,3 @@ test_nc_inq_attid(void)
IF (err)
error("nc_close: %s", nc_strerror(err));
}

View File

@ -778,7 +778,7 @@ put_atts(int ncid)
int j; /* index of attribute */
int allInRange;
double att[MAX_NELS];
char catt[MAX_NELS];
signed char catt[MAX_NELS];
for (i = -1; i < numVars; i++) {
for (j = 0; j < NATTS(i); j++) {
@ -1012,7 +1012,7 @@ check_atts(int ncid)
nc_type datatype;
char name[NC_MAX_NAME];
size_t length;
signed char text[MAX_NELS];
signed char text[MAX_NELS];
double value[MAX_NELS];
double expect;
int nok = 0; /* count of valid comparisons */
@ -1038,9 +1038,9 @@ check_atts(int ncid)
for (k = 0; k < ATT_LEN(i,j); k++) {
IF (text[k] != hash(datatype, -1, &k)) {
error("nc_get_att_text: unexpected value");
} else {
nok++;
}
} else {
nok++;
}
}
} else {
err = nc_get_att_double(ncid, i, name, value);