Hi Nick,
> I wanted to try some compression on a dataset whilst converting to netcdf4/hd
> f5 to see if we can save some space.
>
> I have my compound type defined as such:
>
> if (nc_def_compound(grp2id, sizeof(struct elements), "sample_elements", &type
> id))
> ERR(retval);
> if (nc_insert_compound(grp2id, typeid, "elem", offsetof(struct elements, elem
> ), NC_INT64))
> ERR(retval);
> if (nc_insert_compound(grp2id, typeid, "type", offsetof(struct elements, type
> ), NC_INT))
> ERR(retval);
> if (nc_insert_compound(grp2id, typeid, "x", offsetof(struct elements, x), NC_
> INT))
> ERR(retval);
> if (nc_insert_compound(grp2id, typeid, "y", offsetof(struct elements, y), NC_
> INT))
> ERR(retval);
> if (nc_insert_compound(grp2id, typeid, "z", offsetof(struct elements, z), NC_
> INT))
> ERR(retval);
>
>
> and then I call:
> if ((retval = nc_def_var(grp2id, "data", typeid, 2, dimids, &varid2)))
> ERR(retval);
>
> which works fine. If add in the following, before my call to nc_put_var:
>
> if (retval = nc_def_var_deflate(ncid, varid2, 0, 1, 1))
> ERR(retval)
>
> I get the error:
> Error: NetCDF: Variable not found
>
> which is odd as "varid2" is a legal variable id.
The problem is the "ncid", which refers to the root group, but you've
defined "varid2" within a different group, so you need to use:
if (retval = nc_def_var_deflate(grp2id, varid2, 0, 1, 1))
--Russ