mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-21 03:13:42 +08:00
detecting conditions for mandatory rename of vars with varid > renamed var
This commit is contained in:
parent
275e116f49
commit
8e6f38b099
@ -1142,6 +1142,7 @@ NC4_rename_var(int ncid, int varid, const char *name)
|
||||
there. */
|
||||
if (var->created)
|
||||
{
|
||||
int v;
|
||||
char *hdf5_name; /* Dataset will be renamed to this. */
|
||||
hdf5_name = use_secret_name ? var->hdf5_name: (char *)name;
|
||||
|
||||
@ -1169,6 +1170,23 @@ NC4_rename_var(int ncid, int varid, const char *name)
|
||||
if (H5Lmove(hdf5_grp->hdf_grpid, var->hdr.name, hdf5_grp->hdf_grpid,
|
||||
hdf5_name, H5P_DEFAULT, H5P_DEFAULT) < 0)
|
||||
return NC_EHDFERR;
|
||||
|
||||
/* Now we must rename all the vars in this file with a varid
|
||||
* greater than this var. This is because varids are assigned
|
||||
* based on HDF5 creation time for the dataset, and we have just
|
||||
* changed that for this var. Now we have to do the same for all
|
||||
* vars with a > varid, so that the creation order will continue
|
||||
* to be correct. */
|
||||
for (v = var->hdr.id + 1; v < ncindexsize(grp->vars); v++)
|
||||
{
|
||||
NC_VAR_INFO_T *my_var;
|
||||
my_var = (NC_VAR_INFO_T *)ncindexith(grp->vars, v);
|
||||
assert(my_var);
|
||||
if (!my_var->created)
|
||||
continue; /* I'm not sure this is possible. */
|
||||
|
||||
LOG((3, "mandatory rename of %s to same name", my_var->hdr.name));
|
||||
}
|
||||
}
|
||||
|
||||
/* Now change the name in our metadata. */
|
||||
|
@ -1379,7 +1379,7 @@ attach_dimscales(NC_GRP_INFO_T *grp)
|
||||
for (v = 0; v < ncindexsize(grp->vars); v++)
|
||||
{
|
||||
/* Get pointer to var and HDF5-specific var info. */
|
||||
var = (NC_VAR_INFO_T*)ncindexith(grp->vars, v);
|
||||
var = (NC_VAR_INFO_T *)ncindexith(grp->vars, v);
|
||||
assert(var && var->format_var_info);
|
||||
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user