Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Github issue netcdf-c 300 #301

Merged
merged 7 commits into from
Aug 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1074,14 +1074,6 @@ MARK_AS_ADVANCED(ENABLE_DAP_REMOTE_TESTS ENABLE_DAP_LONG_TESTS USE_REMOTE_CDASH)
MARK_AS_ADVANCED(ENABLE_DOXYGEN_BUILD_RELEASE_DOCS DOXYGEN_ENABLE_TASKS ENABLE_DOXYGEN_SERVER_SIDE_SEARCH)
MARK_AS_ADVANCED(ENABLE_SHARED_LIBRARY_VERSION)

# This option is temporary and should always be on except if netcdf-4 is off.
IF(ENABLE_NETCDF_4)
OPTION(ENABLE_FILEINFO "Enable FILEINFO." ON)
ELSE()
OPTION(ENABLE_FILEINFO "Enable FILEINFO." OFF)
ENDIF()
MARK_AS_ADVANCED(ENABLE_FILEINFO)

################################
# Option checks
################################
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ This file contains a high-level description of this package's evolution. Release

## 4.4.2 - TBD

* [Bug][Enhancement] Corrected a behavioral issue with the `_NCProperties` attribute taking up too much space. See [GitHub #300](https://github.com/Unidata/netcdf-c/issues/300) and [GitHub #301](https://github.com/Unidata/netcdf-c/pull/301) for more information.

* [Bug] Corrected behavior for `nc-config` so that, if `nf-config` is found in system, the proper fortran-related information will be conveyed. See [GitHub #296](https://github.com/Unidata/netcdf-c/issues/296] for more information.

## 4.4.1 - June 28, 2016
Expand Down
1 change: 0 additions & 1 deletion config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ are set when opening a binary file on Windows. */
#cmakedefine ENABLE_DAP 1
#cmakedefine ENABLE_DAP_GROUPS 1
#cmakedefine ENABLE_DAP_REMOTE_TESTS 1
#cmakedefine ENABLE_FILEINFO 1
#cmakedefine EXTRA_TESTS
#cmakedefine USE_NETCDF4 1
#cmakedefine USE_LIBDL 1
Expand Down
15 changes: 0 additions & 15 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,6 @@ enable_netcdf_4=no
fi
AC_MSG_RESULT([$enable_netcdf_4])

####
# Is Netcdf4 file info capture enabled; includes properties attribute
# We do not actually provide a direct flag for disabling this
if test "x$enable_netcdf_4" = xyes ; then
enable_fileinfo=yes
else
enable_fileinfo=no
fi
AC_MSG_CHECKING([If file info capture is enabled])
AC_MSG_RESULT([$enable_fileinfo])
if test "x$enable_fileinfo" = xyes ; then
AC_DEFINE([ENABLE_FILEINFO], [1], [file info])
fi
AM_CONDITIONAL(ENABLE_FILEINFO, [test x$enable_fileinfo = xyes])

# Does the user require dynamic loading?
# This is only for those hdf5 installs that support it.
AC_MSG_CHECKING([do we require hdf5 dynamic-loading support])
Expand Down
10 changes: 5 additions & 5 deletions docs/attribute_conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,11 @@ It is strongly recommended that applicable conventions be followed unless there

These attributes can occur in netCDF enhanced (netcdf-4) files beginning
with version 4.4.1. They all are associated with the root group as
global attributes. They are hidden in the sense that they have no
attribute number, so they can only be accessed thru the netcdf-C api
calls via the name. Additionally, these attributes will not be counted
in the number of global attributes in the root group.
global attributes, although only _NCProperties is actually stored in the
file; the others are computed. They are hidden in the sense that they
have no attribute number, so they can only be accessed thru the netcdf-C
API calls via the name. Additionally, these attributes will not be
counted in the number of global attributes in the root group.

The simplest way to view these attributes is to use the -s flag to the
ncdump command. Alternatively, one can use the following API calls to
Expand All @@ -152,7 +153,6 @@ Using the following API calls will fail.
- nc_del_att
- nc_put_att (and derivatives)


`_NCProperties`

> This attribute is persistent in the file, but hidden. It is inserted in the file at creation time and is never modified after that point. It specifies the following.
Expand Down
11 changes: 1 addition & 10 deletions include/nc4internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,8 @@ typedef enum {VAR, DIM, ATT} NC_OBJ_T;
/* Boolean type, to make the code easier to read */
typedef enum {NC_FALSE = 0, NC_TRUE = 1} nc_bool_t;

#ifdef ENABLE_FILEINFO
/*Forward*/
struct NCFILEINFO;
#endif

/* Generic doubly-linked list node */
typedef struct NC_LIST_NODE
Expand Down Expand Up @@ -322,9 +320,7 @@ typedef struct NC_HDF5_FILE_INFO
nc_bool_t hdf4; /* True for HDF4 file */
int sdid;
#endif /* USE_HDF4 */
#ifdef ENABLE_FILEINFO
struct NCFILEINFO* fileinfo;
#endif
} NC_HDF5_FILE_INFO_T;


Expand Down Expand Up @@ -452,12 +448,9 @@ For netcdf4 files, capture state information about the following:
5. Per file: _NCProperties attribute
*/

#ifdef ENABLE_FILEINFO

#define NCPROPS "_NCProperties"
#define NCPROPS_VERSION (1)
#define NCPROPSSEP '|'
#define NCPROPS_LENGTH (8192)

/* Currently used properties */
#define NCPVERSION "version" /* Of the properties format */
Expand All @@ -475,7 +468,6 @@ struct NCFILEINFO {
int version; /* 0 => not defined */
char hdf5ver[NC_MAX_NAME+1];
char netcdfver[NC_MAX_NAME+1];
char text[NCPROPS_LENGTH+1]; /* Value of the NCPROPS attribute */
} propattr;
};

Expand All @@ -484,11 +476,10 @@ extern struct NCPROPINFO globalpropinfo;
extern int NC4_fileinfo_init(void); /*libsrc4/ncinfo.c*/
extern int NC4_get_fileinfo(struct NC_HDF5_FILE_INFO* info, struct NCPROPINFO*); /*libsrc4/ncinfo.c*/
extern int NC4_put_propattr(struct NC_HDF5_FILE_INFO* info); /*libsrc4/ncinfo.c*/
extern int NC4_buildpropinfo(struct NCPROPINFO* info,char** propdatap);

/* ENABLE_FILEINFO => ENABLE_NETCDF4 */
extern int NC4_hdf5get_libversion(unsigned*,unsigned*,unsigned*);/*libsrc4/nc4hdf.c*/
extern int NC4_hdf5get_superblock(struct NC_HDF5_FILE_INFO*, int*);/*libsrc4/nc4hdf.c*/
extern int NC4_isnetcdf4(struct NC_HDF5_FILE_INFO*); /*libsrc4/nc4hdf.c*/
#endif /*ENABLE_FILEINFO*/

#endif /* _NETCDF4_ */
5 changes: 1 addition & 4 deletions liblib/nc_initialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ nc_initialize()
#endif
#ifdef USE_NETCDF4
if((stat = NC4_initialize())) goto done;
#endif /* USE_NETCDF4 */

#ifdef ENABLE_FILEINFO
stat = NC4_fileinfo_init();
#endif
#endif /* USE_NETCDF4 */

done:
return stat;
Expand Down
6 changes: 2 additions & 4 deletions libsrc4/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ endif
# This is our output. The netCDF-4 convenience library.
noinst_LTLIBRARIES = libnetcdf4.la
libnetcdf4_la_SOURCES = nc4dispatch.c nc4dispatch.h nc4attr.c nc4dim.c \
nc4file.c nc4grp.c nc4hdf.c nc4internal.c nc4type.c nc4var.c ncfunc.c error4.c
if ENABLE_FILEINFO
libnetcdf4_la_SOURCES += nc4info.c
endif
nc4file.c nc4grp.c nc4hdf.c nc4internal.c nc4type.c nc4var.c ncfunc.c error4.c \
nc4info.c

EXTRA_DIST=CMakeLists.txt

Expand Down
19 changes: 9 additions & 10 deletions libsrc4/nc4attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ conditions.
#include "nc4dispatch.h"
#include "ncdispatch.h"

#ifdef ENABLE_FILEINFO
static int nc4_get_att_special(NC_HDF5_FILE_INFO_T*, const char*,
nc_type*, nc_type, size_t*, int*, int, void*);
#endif

int nc4typelen(nc_type type);

Expand Down Expand Up @@ -62,7 +60,6 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name,
if ((retval = nc4_normalize_name(name, norm_name)))
BAIL(retval);

#ifdef ENABLE_FILEINFO
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** sp;
for(sp = NC_RESERVED_SPECIAL_LIST;*sp;sp++) {
Expand All @@ -71,7 +68,6 @@ nc4_get_att(int ncid, NC *nc, int varid, const char *name,
}
}
}
#endif

/* Find the attribute, if it exists.
<strike>If we don't find it, we are major failures.</strike>
Expand Down Expand Up @@ -251,7 +247,6 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
if ((retval = nc4_check_name(name, norm_name)))
return retval;

#ifdef ENABLE_FILEINFO
if(nc->ext_ncid == ncid && varid == NC_GLOBAL) {
const char** sp;
for(sp = NC_RESERVED_SPECIAL_LIST;*sp;sp++) {
Expand All @@ -260,7 +255,6 @@ nc4_put_att(int ncid, NC *nc, int varid, const char *name,
}
}
}
#endif

/* Find att, if it exists. */
if (varid == NC_GLOBAL)
Expand Down Expand Up @@ -877,7 +871,6 @@ nc4_put_att_tc(int ncid, int varid, const char *name, nc_type file_type,
mem_type_is_long, op);
}

#ifdef ENABLE_FILEINFO
static int
nc4_get_att_special(NC_HDF5_FILE_INFO_T* h5, const char* name,
nc_type* filetypep, nc_type mem_type, size_t* lenp,
Expand All @@ -888,14 +881,21 @@ nc4_get_att_special(NC_HDF5_FILE_INFO_T* h5, const char* name,
return NC_EATTMETA;

if(strcmp(name,NCPROPS)==0) {
char* propdata = NULL;
int stat = NC_NOERR;
int len;
if(h5->fileinfo->propattr.version == 0)
return NC_ENOTATT;
if(mem_type == NC_NAT) mem_type = NC_CHAR;
if(mem_type != NC_CHAR)
return NC_ECHAR;
if(filetypep) *filetypep = NC_CHAR;
if(lenp) *lenp = strlen(h5->fileinfo->propattr.text);
if(data) strcpy((char*)data,h5->fileinfo->propattr.text);
stat = NC4_buildpropinfo(&h5->fileinfo->propattr, &propdata);
if(stat != NC_NOERR) return stat;
len = strlen(propdata);
if(lenp) *lenp = len;
if(data) strncpy((char*)data,propdata,len+1);
free(propdata);
} else if(strcmp(name,ISNETCDF4ATT)==0
|| strcmp(name,SUPERBLOCKATT)==0) {
unsigned long long iv = 0;
Expand All @@ -922,7 +922,6 @@ nc4_get_att_special(NC_HDF5_FILE_INFO_T* h5, const char* name,
}
return NC_NOERR;
}
#endif

/* Read an attribute of any type, with type conversion. This may be
* called by any of the nc_get_att_* functions. */
Expand Down
10 changes: 0 additions & 10 deletions libsrc4/nc4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,19 @@ NULL
const char* NC_RESERVED_ATT_LIST[] = {
NC_ATT_FORMAT,
NC3_STRICT_ATT_NAME,
#ifdef ENABLE_FILEINFO
NCPROPS,
ISNETCDF4ATT,
SUPERBLOCKATT,
#endif
NULL
};

#ifdef ENABLE_FILEINFO
/* Define the subset of the reserved list that is readable by name only */
const char* NC_RESERVED_SPECIAL_LIST[] = {
ISNETCDF4ATT,
SUPERBLOCKATT,
NCPROPS,
NULL
};
#endif

/* These are the default chunk cache sizes for HDF5 files created or
* opened with netCDF-4. */
Expand Down Expand Up @@ -468,10 +464,8 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info,
/* Define mode gets turned on automatically on create. */
nc4_info->flags |= NC_INDEF;

#ifdef ENABLE_FILEINFO
NC4_get_fileinfo(nc4_info,&globalpropinfo);
NC4_put_propattr(nc4_info);
#endif

return NC_NOERR;

Expand Down Expand Up @@ -2355,9 +2349,7 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc)
num_plists--;
#endif

#ifdef ENABLE_FILEINFO
NC4_get_fileinfo(nc4_info,NULL);
#endif

return NC_NOERR;

Expand Down Expand Up @@ -3094,9 +3086,7 @@ close_netcdf4_file(NC_HDF5_FILE_INFO_T *h5, int abort)
}
#endif

#ifdef ENABLE_FILEINFO
if(h5->fileinfo) free(h5->fileinfo);
#endif

if (H5Fclose(h5->hdfid) < 0)
{
Expand Down
4 changes: 1 addition & 3 deletions libsrc4/nc4hdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4003,7 +4003,6 @@ reportopenobjects(int log, hid_t fid)
}


#ifdef ENABLE_FILEINFO
int
NC4_hdf5get_libversion(unsigned* major,unsigned* minor,unsigned* release)
{
Expand Down Expand Up @@ -4076,7 +4075,6 @@ NC4_get_strict_att(NC_HDF5_FILE_INFO_T* h5)
{
int ncstat = NC_NOERR;
size_t size;
char text[NCPROPS_LENGTH+1];
hid_t grp = -1;
hid_t attid = -1;
herr_t herr = 0;
Expand Down Expand Up @@ -4147,4 +4145,4 @@ NC4_walk(hid_t gid, int* countp)
return ncstat;
}

#endif

Loading