diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 6a1402903..60659f1df 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -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 diff --git a/libdispatch/dvarget.c b/libdispatch/dvarget.c index 3d86f1f45..31b892e16 100644 --- a/libdispatch/dvarget.c +++ b/libdispatch/dvarget.c @@ -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); diff --git a/libdispatch/dvarput.c b/libdispatch/dvarput.c index fa5cceb44..dc1021cd7 100644 --- a/libdispatch/dvarput.c +++ b/libdispatch/dvarput.c @@ -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); diff --git a/nc_test4/tst_strings.c b/nc_test4/tst_strings.c index 66a8aeaef..d85941fe9 100644 --- a/nc_test4/tst_strings.c +++ b/nc_test4/tst_strings.c @@ -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..."); {