NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

[netcdfgroup] Error when defining variable and then dimension with same name

Hello,

I get an HDF Layer error (-101) when I define a dimension with same name as
a name of already defined variable:


int ncid, dtime, vtime;
int res = nc_create("test.nc", NC_NETCDF4, out ncid);
Handle(res);

res = nc_def_var(ncid, "time", NC_DOUBLE, new int[] {  }, out vtime);
Handle(res);
res = nc_def_dim(ncid, "time", 10, out dtime);
Handle(res);

res = nc_close(ncid);
Handle(res); // error: res == -101


In the opposite order it works; also it works in any order for different
names.


Though such use case looks weird, it is still possible for an inexperienced
user to write similar code.


Regards,
Dmitry.