Skip to content

Commit 982b258

Browse files
committed
Merge branch 'dimscale_attachement_optional' of https://github.com/gsjaardema/netcdf-c into gh2161.wif
2 parents 24835e0 + c746c11 commit 982b258

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

include/nc4internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ typedef struct NC_FILE_INFO
300300
nc_bool_t parallel; /**< True if file is open for parallel access */
301301
nc_bool_t redef; /**< True if redefining an existing file */
302302
nc_bool_t no_attr_create_order; /**< True if the creation order tracking of attributes is disabled (netcdf-4 only) */
303-
int fill_mode; /**< Fill mode for vars */
303+
nc_bool_t no_dimscale_attach; /**< True if attaching dimscales to variables is disabled (netcdf-4 only) */
304+
int fill_mode; /**< Fill mode for vars - Unused internally currently */
304305
nc_bool_t no_write; /**< true if nc_open has mode NC_NOWRITE. */
305306
NC_GRP_INFO_T *root_grp; /**< Pointer to root group. */
306307
short next_nc_grpid; /**< Next available group ID. */

include/netcdf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Use this in mode flags for both nc_create() and nc_open(). */
164164

165165
/* Upper 16 bits */
166166
#define NC_NOATTCREORD 0x20000 /**< Disable the netcdf-4 (hdf5) attribute creation order tracking */
167+
#define NC_NODIMSCALE_ATTACH 0x40000 /**< Disable the netcdf-4 (hdf5) attaching of dimscales to variables (#2128) */
167168

168169
#define NC_MAX_MAGIC_NUMBER_LEN 8 /**< Max len of user-defined format magic number. */
169170

libhdf5/hdf5create.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,11 @@ nc4_create_file(const char *path, int cmode, size_t initialsz,
208208
BAIL(NC_EHDFERR);
209209
#endif
210210

211+
if (cmode & NC_NODIMSCALE_ATTACH) {
212+
/* See https://github.com/Unidata/netcdf-c/issues/2128 */
213+
nc4_info->no_dimscale_attach = NC_TRUE;
214+
}
215+
211216
if(nc4_info->mem.inmemory) {
212217
retval = NC4_create_image_file(nc4_info,initialsz);
213218
if(retval)
@@ -337,7 +342,7 @@ nc4_H5Fcreate(const char *filename0, unsigned flags, hid_t fcpl_id, hid_t fapl_i
337342

338343
#ifdef HDF5_UTF8_PATHS
339344
NCpath2utf8(filename0,&filename);
340-
#else
345+
#else
341346
filename = strdup(filename0);
342347
#endif
343348
/* Canonicalize it since we are not opening the file ourselves */

libhdf5/nc4hdf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,9 +1957,11 @@ nc4_rec_write_metadata(NC_GRP_INFO_T *grp, nc_bool_t bad_coord_order)
19571957
}
19581958
} /* end while */
19591959

1960-
/* Attach dimscales to vars in this group. */
1961-
if ((retval = attach_dimscales(grp)))
1962-
return retval;
1960+
/* Attach dimscales to vars in this group. Unless directed not to. */
1961+
if (!grp->nc4_info->no_dimscale_attach) {
1962+
if ((retval = attach_dimscales(grp)))
1963+
return retval;
1964+
}
19631965

19641966
/* If there are any child groups, write their metadata. */
19651967
for (i = 0; i < ncindexsize(grp->children); i++)

0 commit comments

Comments
 (0)