write coordinates hidden attribute for all variables
@@ -1009,6 +1009,13 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
var->created = NC_TRUE;
var->is_new_var = NC_FALSE;
+ /* Always write the hidden coordinates attribute, which lists the
+ * dimids of this var. When present, this speeds opens. When no
+ * present, dimscale matching is used. */
+ if (var->ndims > 1)
+ if ((retval = write_coord_dimids(var)))
+ BAIL(retval);
+
/* If this is a dimscale, mark it as such in the HDF5 file. Also
* find the dimension info and store the dataset id of the dimscale
* dataset. */
@@ -1017,12 +1024,6 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
if (H5DSset_scale(hdf5_var->hdf_datasetid, var->hdr.name) < 0)
BAIL(NC_EHDFERR);
- /* If this is a multidimensional coordinate variable, write a
- * coordinates attribute. */
- if (var->ndims > 1)
- if ((retval = write_coord_dimids(var)))
- BAIL(retval);
-
/* If desired, write the netCDF dimid. */
if (write_dimid)
if ((retval = write_netcdf4_dimid(hdf5_var->hdf_datasetid, var->dimids[0])))
