Merged latest trunk changes to my branch.

This commit is contained in:
Russ Rew 2010-07-12 16:45:43 +00:00
commit ffdd11d58f
10 changed files with 994 additions and 860 deletions

View File

@ -3,7 +3,30 @@ Entries are in reverse chronological order (most recent first).
VERSION COMMENTS
------- --------
4.1.2 2010-06-20
4.1.2-beta1 2010-07-09
Fix "ncdump -c" bug identifying coordinate variables in groups.
Fix bug in libsrc/posixio.c when providing sizehint
larger than default, which then doesn't get used
(thanks to Harald Anlauf).
Fix netCDF-4 bug caused when doing enddef/redef and
then defining coordinate variable out of order.
Fixed bug in man4 directory automake file which caused
documentation to be rebuilt after make clean.
Turned off HDF5 caching when parallel I/O is in use
because of its memory use.
Refactoring of netCDF code with dispatch layer to
decide whether to call netCDF classic, netCDF-4, or
opendap version of a function.
Refactoring of netCDF-4 memory internals to reduce
memory use and end dependance on NC_MAX_DIMS and
NC_MAX_NAME.
Modified constraint parser to be more compatible with
a java version of the parser.

View File

@ -17,7 +17,7 @@ AC_REVISION([$Id: configure.ac,v 1.450 2010/05/28 19:42:47 dmh Exp $])
AC_PREREQ([2.59])
# Initialize with name, version, and support email address.
AC_INIT([netCDF], [4.1.2], [support-netcdf@unidata.ucar.edu])
AC_INIT([netCDF], [4.1.2-beta1], [support-netcdf@unidata.ucar.edu])
# Create the VERSION file, which contains the package version from
# AC_INIT.

View File

@ -155,9 +155,11 @@ struct NC;
#define MPI_Comm int
#define MPI_Info int
#define MPI_COMM_WORLD 0
#ifndef MPI_INFO_NULL
#define MPI_INFO_NULL 0
#endif
#endif
#endif
int NC_create(const char *path, int cmode,
size_t initialsz, int basepe, size_t *chunksizehintp,

File diff suppressed because it is too large Load Diff

View File

@ -1726,8 +1726,7 @@ get_name_by_idx(NC_HDF5_FILE_INFO_T *h5, hid_t hdf_grpid, int i,
obj_name, size+1, H5P_DEFAULT) < 0)
return NC_EHDFERR;
LOG((4, "get_name_by_idx: encountered HDF5 object obj_class %d obj_name %s",
obj_class, obj_name));
LOG((4, "get_name_by_idx: encountered HDF5 object obj_name %s", obj_name));
return NC_NOERR;
}

View File

@ -1192,6 +1192,7 @@ write_netcdf4_dimid(hid_t datasetid, int dimid)
#endif
/* Does the attribute already exist? If so, don't try to create it. */
if ((num = H5Aget_num_attrs(datasetid)) < 0)
return NC_EHDFERR;
for (a = 0; a < num && !found_it; a++)
@ -1229,7 +1230,8 @@ write_netcdf4_dimid(hid_t datasetid, int dimid)
#endif
if (H5Aclose(dimid_attid) < 0)
return NC_EHDFERR;
LOG((4, "write_dim: wrote secret dimid attribute with value %d", dimid));
LOG((4, "write_netcdf4_dimid: wrote secret dimid attribute with value %d",
dimid));
return NC_NOERR;
}
@ -2237,15 +2239,6 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid)
if (H5DSset_scale(dim->hdf_dimscaleid, dimscale_wo_var) < 0)
BAIL(NC_EHDFERR);
/* If desired, write the secret dimid. This will be used
* instead of the dimid that the dimension would otherwise
* receive based on creation order. This can be necessary
* when dims and their coordinate variables were created in
* different order. */
if (write_dimid)
if ((retval = write_netcdf4_dimid(dim->hdf_dimscaleid,
dim->dimid)))
BAIL(retval);
}
dim->dirty = 0;
}
@ -2308,6 +2301,15 @@ write_dim(NC_DIM_INFO_T *dim, NC_GRP_INFO_T *grp, int write_dimid)
strcpy(dim->old_name, "");
}
/* If desired, write the secret dimid. This will be used instead of
* the dimid that the dimension would otherwise receive based on
* creation order. This can be necessary when dims and their
* coordinate variables were created in different order. */
if (write_dimid && dim->hdf_dimscaleid)
if ((retval = write_netcdf4_dimid(dim->hdf_dimscaleid,
dim->dimid)))
BAIL(retval);
return NC_NOERR;
exit:
return retval;
@ -2333,20 +2335,16 @@ nc4_rec_write_metadata(NC_GRP_INFO_T *grp)
if ((retval = write_attlist(grp->att, NC_GLOBAL, grp)))
return retval;
/* For some stupid reason, the dim list is stored backwards! Get to
* the back of the list. */
for (dim = grp->dim; dim && dim->next; dim = dim->next)
;
/* If the user writes coord vars in a different order then he
* defined their dimensions, then, when the file is reopened, the
* order of the dimids will change to match the order of the coord
* vars. Detect if this is about to happen. */
for (var = grp->var; var; var = var->next)
{
if (var->ndims)
LOG((5, "checking %s for out of order coord var", var->name));
if (var->ndims && var->dimscale)
{
if (var->dimscale && var->dimids[0] < last_dimid)
if (var->dimids[0] < last_dimid)
{
bad_coord_order++;
break;
@ -2354,7 +2352,25 @@ nc4_rec_write_metadata(NC_GRP_INFO_T *grp)
last_dimid = var->dimids[0];
}
}
/* Did the user define a dimension, end define mode, reenter define
* mode, and then define a coordinate variable for that dimension?
* If so, dimensions will be out of order. */
for (var = grp->var; var; var = var->next)
if (var->dirty && !var->created && var->ndims)
for (dim = grp->dim; dim && dim->next; dim = dim->next)
if (strcmp(dim->name, var->name) && !dim->dirty)
{
LOG((5, "coord var defined after enddef/redef"));
bad_coord_order++;
}
/* For some stupid reason, the dim list is stored backwards! Get to
* the back of the list. */
for (dim = grp->dim; dim && dim->next; dim = dim->next)
;
/* Set the pointer to the beginning of the list of vars in this
* group. */
var = grp->var;

View File

@ -403,8 +403,9 @@ nc_def_var_nc4(int ncid, const char *name, nc_type xtype,
* variables which may be contiguous. */
LOG((4, "allocating array of %d size_t to hold chunksizes for var %s",
var->ndims, var->name));
if (!(var->chunksizes = malloc(var->ndims * sizeof(size_t))))
return NC_ENOMEM;
if (var->ndims)
if (!(var->chunksizes = malloc(var->ndims * sizeof(size_t))))
return NC_ENOMEM;
if ((retval = nc4_find_default_chunksizes(var)))
return retval;

View File

@ -309,7 +309,7 @@ main(int argc, char **argv)
int dimid;
size_t count[NDIMS], index[NDIMS] = {0};
const char ttext[TEXT_LEN + 1] = "20051224.150000";
const char ttext_in[TEXT_LEN + 1];
char ttext_in[TEXT_LEN + 1];
char file_name[NC_MAX_NAME + 1];
size_t chunks[NDIMS] = {TEXT_LEN + 1};
int f;
@ -456,9 +456,6 @@ test_redef(int format)
ERR;
}
}
// if ((format != NC_FORMAT_NETCDF4 && ret != NC_ENOTINDEFINE) ||
// (format == NC_FORMAT_NETCDF4 && ret != NC_EPERM)) ERR;
/* This will fail. */
if (!nc_put_att_uchar(ncid, NC_GLOBAL, REDEF_ATT3_NAME, NC_CHAR, 1, &uchar_out)) ERR;
if (nc_close(ncid)) ERR;

View File

@ -27,8 +27,127 @@ main(int argc, char **argv)
{
printf("\n*** Testing netcdf-4 variable functions, some more.\n");
printf("**** testing endianness of compound type variable...");
printf("**** testing definition of coordinate variable after endef/redef...");
{
#define NX 6
#define NY 36
#define ZD1_NAME "zD1"
#define D2_NAME "D2"
int ncid, x_dimid, y_dimid, varid2;
char name_in[NC_MAX_NAME + 1];
/* Create file with two dims, two 1D vars. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, ZD1_NAME, NX, &x_dimid)) ERR;
if (nc_def_dim(ncid, D2_NAME, NY, &y_dimid)) ERR;
if (nc_enddef(ncid)) ERR;
/* Go back into define mode and add a coordinate variable. Now
* dimensions will be out of order. Thanks for confusing my poor
* library. Why can't you just make up your bloody mind? */
if (nc_redef(ncid)) ERR;
if (nc_def_var(ncid, ZD1_NAME, NC_DOUBLE, NDIMS1, &x_dimid, &varid2)) ERR;
if (nc_close(ncid)) ERR;
/* Reopen file and check the name of the first dimension. Even
* though you've changed the order after doing a redef, you will
* still expect to get D1_NAME. I sure hope you appreciate how
* hard you are making life for a poor C library, just trying to
* do its best in a demanding world. Next time, why don't you
* try and be a little bit more considerate? Jerk. */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
if (nc_inq_dimname(ncid, 0, name_in)) ERR;
if (strcmp(name_in, ZD1_NAME)) ERR;
if (nc_inq_dimname(ncid, 1, name_in)) ERR;
if (strcmp(name_in, D2_NAME)) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing definition of coordinate variable with some data...");
{
#define NX 6
#define NY 36
#define V1_NAME "V1"
#define D1_NAME "D1"
#define D2_NAME "D2"
int ncid, x_dimid, y_dimid, varid1, varid2;
int nvars, ndims, ngatts, unlimdimid, dimids_in[2], natts;
double data_outx[NX], data_outy[NY];
int x, y, retval;
size_t len_in;
char name_in[NC_MAX_NAME + 1];
nc_type xtype_in;
/* Create some pretend data. */
for (x = 0; x < NX; x++)
data_outx[x] = x;
for (y = 0; y < NY; y++)
data_outy[y] = y;
/* Create file with two dims, two 1D vars. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, D1_NAME, NX, &x_dimid)) ERR;
if (nc_def_dim(ncid, D2_NAME, NY, &y_dimid)) ERR;
if (nc_def_var(ncid, V1_NAME, NC_DOUBLE, NDIMS1, &y_dimid, &varid1)) ERR;
if (nc_enddef(ncid)) ERR;
if (nc_redef(ncid)) ERR;
if (nc_def_var(ncid, D1_NAME, NC_DOUBLE, NDIMS1, &x_dimid, &varid2)) ERR;
/* if (nc_put_var_double(ncid, varid1, &data_outy[0])) ERR; */
/* if (nc_put_var_double(ncid, varid2, &data_outx[0])) ERR; */
/* if (nc_sync(ncid)) ERR; */
/* Check the file. */
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != 2 || ndims != 2 || ngatts != 0 || unlimdimid != -1) ERR;
/* Check the dimensions. */
if (nc_inq_dimids(ncid, &ndims, dimids_in, 1)) ERR;
if (ndims != 2 || dimids_in[0] != x_dimid || dimids_in[1] != y_dimid) ERR;
if (nc_inq_dim(ncid, dimids_in[0], name_in, &len_in)) ERR;
if (strcmp(name_in, D1_NAME) || len_in != NX) ERR;
if (nc_inq_dim(ncid, dimids_in[1], name_in, &len_in)) ERR;
if (strcmp(name_in, D2_NAME) || len_in != NY) ERR;
/* Check the variables. */
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims, dimids_in, &natts)) ERR;
if (strcmp(name_in, V1_NAME) || xtype_in != NC_DOUBLE || ndims != 1 ||
natts != 0 || dimids_in[0] != y_dimid) ERR;
if (nc_inq_var(ncid, 1, name_in, &xtype_in, &ndims, dimids_in, &natts)) ERR;
if (strcmp(name_in, D1_NAME) || xtype_in != NC_DOUBLE || ndims != 1 ||
natts != 0 || dimids_in[0] != x_dimid) ERR;
/* Close the file. */
if (nc_close(ncid)) ERR;
/* Reopen and check the file. */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
if (nc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)) ERR;
if (nvars != 2 || ndims != 2 || ngatts != 0 || unlimdimid != -1) ERR;
/* Check the dimensions. */
if (nc_inq_dimids(ncid, &ndims, dimids_in, 1)) ERR;
if (ndims != 2 || dimids_in[0] != x_dimid || dimids_in[1] != y_dimid) ERR;
if (nc_inq_dim(ncid, dimids_in[0], name_in, &len_in)) ERR;
if (strcmp(name_in, D1_NAME) || len_in != NX) ERR;
if (nc_inq_dim(ncid, dimids_in[1], name_in, &len_in)) ERR;
if (strcmp(name_in, D2_NAME) || len_in != NY) ERR;
/* Check the variables. */
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims, dimids_in, &natts)) ERR;
if (strcmp(name_in, V1_NAME) || xtype_in != NC_DOUBLE || ndims != 1 ||
natts != 0 || dimids_in[0] != y_dimid) ERR;
if (nc_inq_var(ncid, 1, name_in, &xtype_in, &ndims, dimids_in, &natts)) ERR;
if (strcmp(name_in, D1_NAME) || xtype_in != NC_DOUBLE || ndims != 1 ||
natts != 0 || dimids_in[0] != x_dimid) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing endianness of compound type variable...");
{
#define COMPOUND_NAME "Billy-Bob"
#define BILLY "Billy"
@ -67,10 +186,8 @@ main(int argc, char **argv)
natts_in != 0) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing that fixed vars with no filter end up being contiguous...");
{
#define VAR_NAME2 "Yoman_of_the_Guard"
#define NDIMS 2
@ -159,7 +276,6 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("**** testing large number of vars with unlimited dimension...");
{
@ -189,7 +305,7 @@ main(int argc, char **argv)
if (nvars != NUM_VARS || ndims != 1 || ngatts != 0 || unlimdimid != 0) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
SUMMARIZE_ERR;
/* #ifdef USE_SZIP */
/* printf("**** testing that szip works..."); */
/* { */

View File

@ -102,7 +102,7 @@ typedef struct Diminfo {
int isconstant; /* separate constant from named dimension*/
size_t unlimitedsize; /* if unlimited */
size_t declsize; /* 0 => unlimited/unspecified*/
// size_t unlimitedsize; /* computed unlimited size */
/* size_t unlimitedsize; *//* computed unlimited size */
} Diminfo;
typedef struct Attrinfo {