From 4c27730ae346b2b1666938a19df0f4c753f2b2b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=B6lling?= Date: Wed, 2 Sep 2020 16:13:23 +0200 Subject: [PATCH] hdf5: added unknown storage specification In case HDF5 adds more storage specifications, netcdf4 should be able to cope with them by default. Further specializations could be added nonetheless. --- include/netcdf.h | 10 ++++++---- libhdf5/hdf5open.c | 4 ++++ libsrc4/nc4internal.c | 4 +++- ncdump/ncdump.c | 5 ++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/netcdf.h b/include/netcdf.h index 4395b30e8..630d1d21b 100644 --- a/include/netcdf.h +++ b/include/netcdf.h @@ -293,11 +293,13 @@ NOTE: The NC_MAX_DIMS, NC_MAX_ATTRS, and NC_MAX_VARS limits /** In HDF5 files you can set storage for each variable to be either * contiguous or chunked, with nc_def_var_chunking(). This define is - * used there. */ + * used there. Unknown storage is used for further extensions of HDF5 + * storage models, which should be handled transparently by netcdf */ /**@{*/ -#define NC_CHUNKED 0 -#define NC_CONTIGUOUS 1 -#define NC_COMPACT 2 +#define NC_CHUNKED 0 +#define NC_CONTIGUOUS 1 +#define NC_COMPACT 2 +#define NC_UNKNOWN_STORAGE 3 /**@}*/ /** In HDF5 files you can set check-summing for each variable. diff --git a/libhdf5/hdf5open.c b/libhdf5/hdf5open.c index 06b5adbae..fd496a33c 100644 --- a/libhdf5/hdf5open.c +++ b/libhdf5/hdf5open.c @@ -1140,6 +1140,10 @@ get_chunking_info(hid_t propid, NC_VAR_INFO_T *var) { var->storage = NC_COMPACT; } + else + { + var->storage = NC_UNKNOWN_STORAGE; + } return NC_NOERR; } diff --git a/libsrc4/nc4internal.c b/libsrc4/nc4internal.c index 9c9d7ec95..bc2346cc6 100644 --- a/libsrc4/nc4internal.c +++ b/libsrc4/nc4internal.c @@ -1709,8 +1709,10 @@ rec_print_metadata(NC_GRP_INFO_T *grp, int tab_count) strcat(storage_str, "contiguous"); else if (var->storage == NC_COMPACT) strcat(storage_str, "compact"); - else + else if (var->storage == NC_CHUNKED) strcat(storage_str, "chunked"); + else + strcat(storage_str, "unknown"); LOG((2, "%s VARIABLE - varid: %d name: %s ndims: %d " "dimids:%s storage: %s", tabs, var->hdr.id, var->hdr.name, var->ndims, diff --git a/ncdump/ncdump.c b/ncdump/ncdump.c index e7ac9acf8..b61dac26c 100644 --- a/ncdump/ncdump.c +++ b/ncdump/ncdump.c @@ -988,7 +988,7 @@ pr_att_specials( } else if(contig == NC_COMPACT) { pr_att_name(ncid, varp->name, NC_ATT_STORAGE); printf(" = \"compact\" ;\n"); - } else { + } else if(contig == NC_CHUNKED) { size_t *chunkp; int i; pr_att_name(ncid, varp->name, NC_ATT_STORAGE); @@ -1002,6 +1002,9 @@ pr_att_specials( printf("%lu%s", (unsigned long)chunkp[i], i+1 < varp->ndims ? ", " : " ;\n"); } free(chunkp); + } else { + pr_att_name(ncid, varp->name, NC_ATT_STORAGE); + printf(" = \"unknown\" ;\n"); } /* _Filter (including deflate and shuffle) */