mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-18 15:55:12 +08:00
Fixed bug NCF-206 (Fix strided access for NC_STRING type). Verified
fix with new test for strided access for NC_STRING type.
This commit is contained in:
parent
109460c42e
commit
592a120a55
@ -10,6 +10,13 @@ VERSION COMMENTS
|
||||
|
||||
Replaced the oc library with oc2.0
|
||||
|
||||
Fixed bug with strided access for NC_STRING type.
|
||||
[NCF-206]
|
||||
|
||||
Fixed ncdump bug in display of data values of
|
||||
variables that use multiple unlimited dimensions.
|
||||
[NCF-144]
|
||||
|
||||
Prevented adding an invalid _FillValue attribute to a
|
||||
variable (with nonmatching type or multiple values),
|
||||
to avoid later error when any record variable is
|
||||
|
@ -101,7 +101,7 @@ NCDEFAULT_get_varm(int ncid, int varid, const size_t *start,
|
||||
status = nc_inq_vartype(ncid, varid, &vartype);
|
||||
if(status != NC_NOERR) return status;
|
||||
/* Check that this is an atomic type */
|
||||
if(vartype >= NC_MAX_ATOMIC_TYPE)
|
||||
if(vartype > NC_MAX_ATOMIC_TYPE)
|
||||
return NC_EMAPTYPE;
|
||||
|
||||
status = nc_inq_varndims(ncid, varid, &varndims);
|
||||
|
@ -104,7 +104,7 @@ NCDEFAULT_put_varm(
|
||||
status = nc_inq_vartype(ncid, varid, &vartype);
|
||||
if(status != NC_NOERR) return status;
|
||||
/* Check that this is an atomic type */
|
||||
if(vartype >= NC_MAX_ATOMIC_TYPE)
|
||||
if(vartype > NC_MAX_ATOMIC_TYPE)
|
||||
return NC_EMAPTYPE;
|
||||
|
||||
status = nc_inq_varndims(ncid, varid, &varndims);
|
||||
|
@ -198,6 +198,48 @@ main(int argc, char **argv)
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("\n*** Testing netcdf-4 strided string access.\n");
|
||||
{
|
||||
#define NUM_PRES 43
|
||||
#define SOME_PRES 16
|
||||
#define NDIMS_PRES 1
|
||||
#define VAR_NAME_P "presidents"
|
||||
int ncid, varid, i, dimids[NDIMS_PRES];
|
||||
size_t start[NDIMS_PRES], count[NDIMS_PRES], stride[NDIMS_PRES];
|
||||
char *data[SOME_PRES] = {"Washington", "Adams", "Jefferson", "Madison",
|
||||
"Monroe", "Adams", "Jackson", "VanBuren",
|
||||
"Harrison", "Tyler", "Polk", "Tayor",
|
||||
"Fillmore", "Peirce", "Buchanan", "Lincoln"};
|
||||
char *data_in[NUM_PRES];
|
||||
int status;
|
||||
|
||||
/* Create a file with NUM_PRES strings, and write SOME_PRES of
|
||||
* them. */
|
||||
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
|
||||
if (nc_def_dim(ncid, DIM_NAME, NUM_PRES, dimids)) ERR;
|
||||
if (nc_def_var(ncid, VAR_NAME_P, NC_STRING, NDIMS_PRES, dimids, &varid)) ERR;
|
||||
start[0] = 0;
|
||||
count[0] = SOME_PRES;
|
||||
stride[0] = 2;
|
||||
status = nc_put_vars_string(ncid, varid, start, count, stride, (const char **)data);
|
||||
if(status != NC_NOERR)
|
||||
fprintf(stderr,"%s\n",nc_strerror(status));
|
||||
if (nc_close(ncid)) ERR;
|
||||
|
||||
/* Check it out. */
|
||||
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_get_vars_string(ncid, varid, start, count, stride, data_in)) ERR;
|
||||
for (i = 0; i < NUM_PRES; i++)
|
||||
{
|
||||
if (i < SOME_PRES && strcmp(data_in[i], data[i])) ERR;
|
||||
}
|
||||
|
||||
/* Must free your data! */
|
||||
if (nc_free_string(SOME_PRES, (char **)data_in)) ERR;
|
||||
|
||||
if (nc_close(ncid)) ERR;
|
||||
}
|
||||
SUMMARIZE_ERR;
|
||||
printf("*** testing long string variable...");
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user