This commit is contained in:
dmh 2013-12-10 11:23:10 -07:00
commit 564a9d56a4
34 changed files with 1152 additions and 1725 deletions

2
.gitignore vendored
View File

@ -4,3 +4,5 @@ doxygen*.tmp
\#*.*\#
autom4te.cache
myhtml
CMakeLists.txt.user
scan-build

View File

@ -16,7 +16,7 @@ set(PACKAGE "netCDF" CACHE STRING "")
SET(netCDF_VERSION_MAJOR 4)
SET(netCDF_VERSION_MINOR 3)
SET(netCDF_VERSION_PATCH 1)
SET(netCDF_VERSION_NOTE "-rc4")
SET(netCDF_VERSION_NOTE "-rc5")
SET(netCDF_VERSION ${netCDF_VERSION_MAJOR}.${netCDF_VERSION_MINOR}.${netCDF_VERSION_PATCH}${netCDF_VERSION_NOTE})
SET(VERSION ${netCDF_VERSION})
SET(netCDF_SO_VERSION 7.2.0)
@ -454,22 +454,50 @@ IF (ENABLE_HDF4)
FIND_LIBRARY(HDF4_DF_LIB NAMES df libdf)
IF(NOT HDF4_DF_LIB)
MESSAGE(FATAL_ERROR "HDF4 Support enabled, but cannot find df lib.")
MESSAGE(FATAL_ERROR "Can't find or link to the hdf4 df library.")
ENDIF()
FIND_LIBRARY(HDF4_MFHDF_LIB NAMES mfhdf libmfhdf)
IF(NOT HDF4_MFHDF_LIB)
MESSAGE(FATAL_ERROR "HDF4 Support enabled, but cannot find mfhdf lib.")
MESSAGE(FATAL_ERROR "Can't find or link to the hdf4 mfhdf library.")
ENDIF()
SET(HDF4_LIBRARIES ${HDF4_MFHDF_LIB} ${HDF4_DF_LIB})
# End include files, libraries.
MESSAGE(STATUS "HDF4 Libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}")
OPTION(ENABLE_HDF4_FILE_TESTS "Run HDF4 File Tests." OFF)
IF(ENABLE_HDF4_FILE_TESTS)
SET(USE_HDF4_FILE_TESTS ON)
MESSAGE(STATUS "HDF4 libraries: ${HDF4_DF_LIB}, ${HDF4_MFHDF_LIB}")
MESSAGE(STATUS "Seeking HDF4 jpeg dependency.")
# Look for the jpeglib.h header file.
FIND_PATH(JPEGLIB_H_INCLUDE_DIR jpeglib.h)
IF(NOT JPEGLIB_H_INCLUDE_DIR)
MESSAGE(FATAL_ERROR "HDF4 Support enabled but cannot find jpeglib.h")
ELSE()
SET(HAVE_JPEGLIB_H ON CACHE BOOL "")
INCLUDE_DIRECTORIES(${JPEGLIB_H_INCLUDE_DIR})
ENDIF()
ENDIF ()
FIND_LIBRARY(JPEG_LIB NAMES jpeg libjpeg)
IF(NOT JPEG_LIB)
MESSAGE(FATAL_ERROR "HDF4 Support enabled but cannot find libjpeg")
ENDIF()
SET(HDF4_LIBRARIES ${JPEG_LIB} ${HDF4_LIBRARIES})
MESSAGE(STATUS "Found JPEG libraries: ${JPEG_LIB}")
# Option to enable HDF4 file tests.
OPTION(ENABLE_HDF4_FILE_TESTS "Run HDF4 file tests. This fetches sample HDF4 files from the Unidata ftp site to test with (requires wget)." ON)
IF(ENABLE_HDF4_FILE_TESTS)
FIND_PROGRAM(PROG_WGET NAMES wget)
IF(PROG_WGET)
SET(USE_HDF4_FILE_TESTS ON)
ELSE()
MESSAGE(STATUS "Unable to locate 'wget'. Disabling hdf4 file tests.")
SET(USE_HDF4_FILE_TESTS OFF)
ENDIF()
ENDIF()
ENDIF ()
# Option to Build DLL
IF(WIN32)

View File

@ -32,7 +32,7 @@ PROJECT_NAME = netCDF-C
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 4.3.1-RC3
PROJECT_NUMBER = 4.3.1-RC5
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer

View File

@ -8,6 +8,18 @@ information, where '[NCF-XXX]' refers to https://www.unidata.ucar.edu/jira/brows
## 4.3.1 Released TBD
### 4.3.1-rc5 Released 2013-12-06
* When opening a netCDF-4 file, streamline the iteration over objects in
the underlying HDF5 file.
* Fixed netCDF-4 failure when renaming a dimension and renaming a
variable using that dimension, in either order. [NCF-177]
[NCF-177]:https://bugtracking.unidata.ucar.edu/browse/NCF-177
* When compiling with `hdf4` support, both autotools and cmake-based builds now properly look for the `libjpeg` dependency and will link against it when found (or complain if it's not). Also added `ENABLE_HDF4_FILE_TESTS` option to CMake-based builds.
* Fixed bug in ncgen; it was not properly filling empty string constants
("") to be the proper length. [NCF-279]

View File

@ -15,7 +15,7 @@ AC_REVISION([$Id: configure.ac,v 1.450 2010/05/28 19:42:47 dmh Exp $])
AC_PREREQ([2.59])
# Initialize with name, version, and support email address.
AC_INIT([netCDF], [4.3.1-rc4], [support-netcdf@unidata.ucar.edu])
AC_INIT([netCDF], [4.3.1-rc5], [support-netcdf@unidata.ucar.edu])
# Create the VERSION file, which contains the package version from
# AC_INIT.
@ -732,8 +732,9 @@ if test "x$enable_netcdf_4" = xyes; then
fi
AC_CHECK_LIB([df], [Hclose], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])])
AC_CHECK_LIB([mfhdf], [SDcreate], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])])
#AC_SEARCH_LIBS([Hclose],[df], [], [AC_MSG_ERROR([Can't find or link to the hdf4 df library. See config.log for errors.])])
#AC_SEARCH_LIBS([SDcreate],[mfhdf], [], [AC_MSG_ERROR([Can't find or link to the hdf4 mfhdf library. See config.log for errors.])])
AC_CHECK_LIB([jpeg], [jpeg_set_quality], [], [AC_MSG_ERROR([Can't find or link to the jpeg library (required by hdf4). See config.log for errors.])])
AC_DEFINE([USE_HDF4], [1], [if true, use HDF4 too])
fi
fi

View File

@ -20,11 +20,6 @@
#define DIMSCALE_LABEL "dimscale_label"
#define STR_LEN 255
/* typedef struct { */
/* unsigned long fileno; /\*file number *\/ */
/* haddr_t objno; /\*object number *\/ */
/* } HDF5_OBJID_T; */
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
void *visitor_data)
{
@ -37,34 +32,21 @@ herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
if (strcmp(&name1[1], VAR1_NAME)) ERR;
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
did, dim, dsid, name1);*/
/* Get more info on the dimscale object.*/
if (H5Gget_objinfo(dsid, ".", 1, &statbuf) < 0) ERR;
objid->fileno[0] = statbuf.fileno[0];
objid->objno[0] = statbuf.objno[0];
objid->fileno[1] = statbuf.fileno[1];
objid->objno[1] = statbuf.objno[1];
/*printf("for dsid: statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
if (H5Gget_objinfo(did, ".", 1, &statbuf) < 0) ERR;
/*printf("for did: statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
return 0;
}
herr_t alien_visitor2(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
{
char name1[STR_LEN];
H5G_stat_t statbuf;
HDF5_OBJID_T *objid = visitor_data;
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
did, dim, dsid, name1); */
/* Get obj id of the dimscale object. THis will be used later to
* match dimensions to dimscales. */
if (H5Gget_objinfo(dsid, ".", 1, &statbuf) < 0) ERR;
@ -145,9 +127,6 @@ main()
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
obj_class, obj_name);*/
/* Deal with object based on its obj_class. */
switch(obj_class)
{
@ -179,9 +158,6 @@ main()
dimscale_obj.objno[0] = statbuf.objno[0];
dimscale_obj.fileno[1] = statbuf.fileno[1];
dimscale_obj.objno[1] = statbuf.objno[1];
/*printf("statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
}
else
{
@ -193,8 +169,6 @@ main()
/* Go through all dimscales for this var and learn about them. */
if (H5DSiterate_scales(datasetid, 0, NULL, alien_visitor,
&vars_dimscale_obj) < 0) ERR;
/*printf("vars_dimscale_obj.fileno = %d vars_dimscale_obj.objno = %d\n",
vars_dimscale_obj.fileno, vars_dimscale_obj.objno);*/
if (vars_dimscale_obj.fileno[0] != dimscale_obj.fileno[0] ||
vars_dimscale_obj.objno[0] != dimscale_obj.objno[0] ||
vars_dimscale_obj.fileno[1] != dimscale_obj.fileno[1] ||
@ -202,8 +176,6 @@ main()
/* There's also a label for dimension 0. */
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
/*printf("found non-scale dataset %s, label %s\n", obj_name, label);*/
}
if (H5Dclose(datasetid) < 0) ERR;
break;
@ -304,9 +276,6 @@ main()
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
/* printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", */
/* obj_class, obj_name); */
/* Deal with object based on its obj_class. */
switch(obj_class)
{
@ -333,9 +302,6 @@ main()
dimscale_obj[dimscale_cnt].objno[0] = statbuf.objno[0];
dimscale_obj[dimscale_cnt].fileno[1] = statbuf.fileno[1];
dimscale_obj[dimscale_cnt].objno[1] = statbuf.objno[1];
/* printf("dimscale_obj[%d].fileno = %d dimscale_obj[%d].objno = %d\n", */
/* dimscale_cnt, dimscale_obj[dimscale_cnt].fileno, dimscale_cnt, */
/* dimscale_obj[dimscale_cnt].objno); */
dimscale_cnt++;
}
else
@ -791,9 +757,6 @@ main()
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
/* printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", */
/* obj_class, obj_name); */
/* Deal with object based on its obj_class. */
switch(obj_class)
{
@ -819,9 +782,6 @@ main()
dimscale_obj[dimscale_cnt].objno[0] = statbuf.objno[0];
dimscale_obj[dimscale_cnt].fileno[1] = statbuf.fileno[1];
dimscale_obj[dimscale_cnt].objno[1] = statbuf.objno[1];
/* printf("dimscale_obj[%d].fileno = %d dimscale_obj[%d].objno = %d\n", */
/* dimscale_cnt, dimscale_obj[dimscale_cnt].fileno, dimscale_cnt, */
/* dimscale_obj[dimscale_cnt].objno); */
dimscale_cnt++;
}
else
@ -982,9 +942,6 @@ main()
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
/* printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n", */
/* obj_class, obj_name); */
/* Deal with object based on its obj_class. */
switch(obj_class)
{
@ -1010,9 +967,6 @@ main()
dimscale_obj[dimscale_cnt].objno[0] = statbuf.objno[0];
dimscale_obj[dimscale_cnt].fileno[1] = statbuf.fileno[1];
dimscale_obj[dimscale_cnt].objno[1] = statbuf.objno[1];
/* printf("dimscale_obj[%d].fileno = %d dimscale_obj[%d].objno = %d\n", */
/* dimscale_cnt, dimscale_obj[dimscale_cnt].fileno, dimscale_cnt, */
/* dimscale_obj[dimscale_cnt].objno); */
dimscale_cnt++;
}
else

View File

@ -23,11 +23,6 @@
#define DIMSCALE_LABEL "dimscale_label"
#define STR_LEN 255
/* typedef struct { */
/* unsigned long fileno; /\*file number *\/ */
/* haddr_t objno; /\*object number *\/ */
/* } HDF5_OBJID_T; */
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
void *visitor_data)
{
@ -40,34 +35,21 @@ herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
if (strcmp(&name1[1], VAR1_NAME)) ERR;
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
did, dim, dsid, name1);*/
/* Get more info on the dimscale object.*/
if (H5Gget_objinfo(dsid, ".", 1, &statbuf) < 0) ERR;
objid->fileno[0] = statbuf.fileno[0];
objid->objno[0] = statbuf.objno[0];
objid->fileno[1] = statbuf.fileno[1];
objid->objno[1] = statbuf.objno[1];
/*printf("for dsid: statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
if (H5Gget_objinfo(did, ".", 1, &statbuf) < 0) ERR;
/*printf("for did: statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
return 0;
}
herr_t alien_visitor2(hid_t did, unsigned dim, hid_t dsid, void *visitor_data)
{
char name1[STR_LEN];
H5G_stat_t statbuf;
HDF5_OBJID_T *objid = visitor_data;
if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;
/*printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
did, dim, dsid, name1); */
/* Get obj id of the dimscale object. THis will be used later to
* match dimensions to dimscales. */
if (H5Gget_objinfo(dsid, ".", 1, &statbuf) < 0) ERR;
@ -144,9 +126,6 @@ main()
if ((obj_class = H5Gget_objtype_by_idx(fileid, i)) < 0) ERR;
if (H5Gget_objname_by_idx(fileid, i, obj_name, STR_LEN) < 0) ERR;
/*printf("\nEncountered: HDF5 object obj_class %d obj_name %s\n",
obj_class, obj_name);*/
/* Deal with object based on its obj_class. */
switch(obj_class)
{
@ -178,9 +157,6 @@ main()
dimscale_obj.objno[0] = statbuf.objno[0];
dimscale_obj.fileno[1] = statbuf.fileno[1];
dimscale_obj.objno[1] = statbuf.objno[1];
/*printf("statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
}
else
{
@ -192,8 +168,6 @@ main()
/* Go through all dimscales for this var and learn about them. */
if (H5DSiterate_scales(datasetid, 0, NULL, alien_visitor,
&vars_dimscale_obj) < 0) ERR;
/*printf("vars_dimscale_obj.fileno = %d vars_dimscale_obj.objno = %d\n",
vars_dimscale_obj.fileno, vars_dimscale_obj.objno);*/
if (vars_dimscale_obj.fileno[0] != dimscale_obj.fileno[0] ||
vars_dimscale_obj.objno[0] != dimscale_obj.objno[0] ||
vars_dimscale_obj.fileno[1] != dimscale_obj.fileno[1] ||
@ -201,8 +175,6 @@ main()
/* There's also a label for dimension 0. */
if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR;
/*printf("found non-scale dataset %s, label %s\n", obj_name, label);*/
}
if (H5Dclose(datasetid) < 0) ERR;
break;

View File

@ -27,75 +27,25 @@
#define NC_EHDFERR 255
#define DIM_WITHOUT_VARIABLE "This is a netCDF dimension but not a netCDF variable."
/* typedef struct { */
/* unsigned long fileno; /\*file number *\/ */
/* haddr_t objno; /\*object number *\/ */
/* } HDF5_OBJID_T; */
struct nc_hdf5_link_info
{
char name[STR_LEN];
H5I_type_t obj_type;
};
#if 0
static herr_t
visit_link(hid_t g_id, const char *name, const H5L_info_t *info,
void *op_data)
{
/* A positive return value causes the visit iterator to immediately
* return that positive value, indicating short-circuit
* success. The iterator can be restarted at the next group
* member. */
int ret = 1;
hid_t id;
strncpy(((struct nc_hdf5_link_info *)op_data)->name, name, NC_MAX_NAME);
/* Open this critter. */
if ((id = H5Oopen_by_addr(g_id, info->u.address)) < 0)
return NC_EHDFERR;
/* Is this critter a group, type, data, attribute, or what? */
if ((((struct nc_hdf5_link_info *)op_data)->obj_type = H5Iget_type(id)) < 0)
ret = NC_EHDFERR;
/* Close the critter to release resouces. */
if (H5Oclose(id) < 0)
return NC_EHDFERR;
return ret;
}
#endif
herr_t alien_visitor(hid_t did, unsigned dim, hid_t dsid,
void *visitor_data)
{
#if 0
char name1[STR_LEN];
#endif
H5G_stat_t statbuf;
HDF5_OBJID_T *objid = visitor_data;
/* This should get "/var1", the name of the dataset that the scale
* is attached to. */
/*if (H5Iget_name(did, name1, STR_LEN) < 0) ERR;*/
/* printf("visiting did 0x%x dim %d dsid 0x%x name of did %s \n",
did, dim, dsid, name1);*/
/* Get more info on the dimscale object.*/
if (H5Gget_objinfo(dsid, ".", 1, &statbuf) < 0) ERR;
objid->fileno[0] = statbuf.fileno[0];
objid->objno[0] = statbuf.objno[0];
objid->fileno[1] = statbuf.fileno[1];
objid->objno[1] = statbuf.objno[1];
/* printf("for dsid: statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
if (H5Gget_objinfo(did, ".", 1, &statbuf) < 0) ERR;
/* printf("for did: statbuf.fileno = %d statbuf.objno = %d\n",
statbuf.fileno, statbuf.objno);*/
return 0;
}
@ -105,9 +55,6 @@ main()
printf("\n*** Checking HDF5 dimscales detach.\n");
printf("*** Creating a file with two vars with one dimension scale...");
{
#if 0
hid_t cparmsid;
#endif
hid_t fileid, grpid, spaceid, var1_id, var2_id, dimscaleid;
hid_t fcpl_id, fapl_id, create_propid, access_propid;
hsize_t dims[NDIMS] = {DIM_LEN};
@ -186,107 +133,6 @@ main()
if (H5Dclose(dimscaleid) < 0) ERR;
if (H5Gclose(grpid) < 0) ERR;
if (H5Fclose(fileid) < 0) ERR;
/* /\* Now read the file and check it. *\/ */
/* { */
/* hid_t fileid, spaceid = 0, datasetid = 0; */
/* hsize_t num_obj, i; */
/* int obj_class; */
/* char obj_name[STR_LEN + 1]; */
/* char dimscale_name[STR_LEN+1]; */
/* htri_t is_scale; */
/* char label[STR_LEN+1]; */
/* int num_scales; */
/* hsize_t dims[1], maxdims[1]; */
/* H5G_stat_t statbuf; */
/* HDF5_OBJID_T dimscale_obj, vars_dimscale_obj; */
/* struct nc_hdf5_link_info link_info; */
/* hsize_t idx = 0; */
/* /\* Open the file. *\/ */
/* if ((fileid = H5Fopen(FILE_NAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) ERR; */
/* if ((grpid = H5Gopen2(fileid, "/", H5P_DEFAULT)) < 0) ERR; */
/* /\* Loop through objects in the root group. *\/ */
/* if (H5Gget_num_objs(fileid, &num_obj) < 0) ERR; */
/* for (i = 0; i < num_obj; i++) */
/* { */
/* if (H5Literate(grpid, H5_INDEX_CRT_ORDER, H5_ITER_INC, */
/* &idx, visit_link, (void *)&link_info) < 0) ERR; */
/* printf("Encountered: HDF5 object link_info.name %s\n", link_info.name); */
/* /\* Deal with object based on its obj_class. *\/ */
/* switch(link_info.obj_type) */
/* { */
/* case H5I_GROUP: */
/* break; */
/* case H5I_DATASET: */
/* /\* Open the dataset. *\/ */
/* if ((datasetid = H5Dopen1(fileid, link_info.name)) < 0) ERR; */
/* if ((spaceid = H5Dget_space(datasetid)) < 0) ERR; */
/* if (H5Sget_simple_extent_dims(spaceid, dims, maxdims) < 0) ERR; */
/* if (maxdims[0] != DIM_LEN) ERR; */
/* if (H5Sclose(spaceid) < 0) ERR; */
/* /\* Is this a dimscale? *\/ */
/* if ((is_scale = H5DSis_scale(datasetid)) < 0) ERR; */
/* if (is_scale && strcmp(link_info.name, DIMSCALE_NAME)) ERR; */
/* if (is_scale) */
/* { */
/* /\* A dimscale comes with a NAME attribute, in */
/* * addition to its real name. *\/ */
/* if (H5DSget_scale_name(datasetid, dimscale_name, STR_LEN) < 0) ERR; */
/* if (strcmp(dimscale_name, dimscale_wo_var)) ERR; */
/* /\* fileno and objno uniquely identify an object and a */
/* * HDF5 file. *\/ */
/* if (H5Gget_objinfo(datasetid, ".", 1, &statbuf) < 0) ERR; */
/* dimscale_obj.fileno[0] = statbuf.fileno[0]; */
/* dimscale_obj.objno[0] = statbuf.objno[0]; */
/* dimscale_obj.fileno[1] = statbuf.fileno[1]; */
/* dimscale_obj.objno[1] = statbuf.objno[1]; */
/* /\*printf("scale statbuf.fileno = %d statbuf.objno = %d\n", */
/* statbuf.fileno, statbuf.objno);*\/ */
/* } */
/* else */
/* { */
/* /\* Here's how to get the number of scales attached */
/* * to the dataset's dimension 0. *\/ */
/* if ((num_scales = H5DSget_num_scales(datasetid, 0)) < 0) ERR; */
/* if (num_scales != 1) ERR; */
/* /\* Go through all dimscales for this var and learn about them. *\/ */
/* if (H5DSiterate_scales(datasetid, 0, NULL, alien_visitor, */
/* &vars_dimscale_obj) < 0) ERR; */
/* /\*printf("vars_dimscale_obj.fileno = %d vars_dimscale_obj.objno = %d\n", */
/* vars_dimscale_obj.fileno, vars_dimscale_obj.objno);*\/ */
/* /\* if (vars_dimscale_obj.fileno[0] != dimscale_obj.fileno[0] || *\/ */
/* /\* vars_dimscale_obj.objno[0] != dimscale_obj.objno[0] || *\/ */
/* /\* vars_dimscale_obj.fileno[1] != dimscale_obj.fileno[1] || *\/ */
/* /\* vars_dimscale_obj.objno[1] != dimscale_obj.objno[1]) ERR; *\/ */
/* /\* There's also a label for dimension 0. *\/ */
/* if (H5DSget_label(datasetid, 0, label, STR_LEN) < 0) ERR; */
/* /\*printf("found non-scale dataset %s, label %s\n", link_info.name, label);*\/ */
/* } */
/* if (H5Dclose(datasetid) < 0) ERR; */
/* break; */
/* case H5I_DATATYPE: */
/* break; */
/* default: */
/* printf("Unknown object!"); */
/* ERR; */
/* } */
/* } */
/* /\* Close up the shop. *\/ */
/* if (H5Fclose(fileid) < 0) ERR; */
/* }*/
}
SUMMARIZE_ERR;
FINAL_RESULTS;

View File

@ -108,11 +108,9 @@ typedef struct NC_DIM_INFO
struct NC_DIM_INFO *next;
struct NC_DIM_INFO *prev;
hid_t hdf_dimscaleid;
char *old_name; /* only used to rename dim */
int dirty;
unsigned char coord_var_in_grp;
HDF5_OBJID_T hdf5_objid;
struct NC_VAR_INFO *coord_var; /* The coord var, if it exists. */
int too_long; /* True if len it too big to fit in local size_t. */
int too_long; /* True if len is too big to fit in local size_t. */
} NC_DIM_INFO_T;
typedef struct NC_ATT_INFO
@ -145,7 +143,7 @@ typedef struct NC_VAR_INFO
struct NC_VAR_INFO *next;
struct NC_VAR_INFO *prev;
int dirty;
int created;
int created; /* Variable has already been created (_not_ that it was just created) */
int written_to;
int *dimscale_attached;
struct NC_TYPE_INFO *type_info;
@ -234,7 +232,6 @@ typedef struct NC_GRP_INFO
int natts;
struct NC_HDF5_FILE_INFO *nc4_info;
char *name;
char *old_name; /* need when renaming group */
hid_t hdf_grpid;
NC_TYPE_INFO_T *type;
} NC_GRP_INFO_T;
@ -292,6 +289,7 @@ int nc4_convert_type(const void *src, void *dest,
int dest_long);
/* These functions do HDF5 things. */
int rec_detach_scales(NC_GRP_INFO_T *grp, int dimid, hid_t dimscaleid);
int nc4_open_var_grp2(NC_GRP_INFO_T *grp, int varid, hid_t *dataset);
int pg_var(NC_PG_T pg, NC *nc, int ncid, int varid, nc_type xtype, int is_long, void *ip);
int nc4_pg_var1(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *indexp,
@ -306,7 +304,7 @@ int nc4_pg_varm(NC_PG_T pg, NC *nc, int ncid, int varid, const size_t *startp,
int nc4_rec_match_dimscales(NC_GRP_INFO_T *grp);
int nc4_rec_detect_need_to_preserve_dimids(NC_GRP_INFO_T *grp, int *bad_coord_orderp);
int nc4_rec_write_metadata(NC_GRP_INFO_T *grp, int bad_coord_order);
int nc4_rec_write_types(NC_GRP_INFO_T *grp);
int nc4_rec_write_groups_types(NC_GRP_INFO_T *grp);
int nc4_enddef_netcdf4_file(NC_HDF5_FILE_INFO_T *h5);
int nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var);
int nc4_adjust_var_cache(NC_GRP_INFO_T *grp, NC_VAR_INFO_T * var);
@ -321,6 +319,7 @@ NC_GRP_INFO_T *nc4_find_nc_grp(int ncid);
NC_GRP_INFO_T *nc4_rec_find_grp(NC_GRP_INFO_T *start_grp, int target_nc_grpid);
NC *nc4_find_nc_file(int ncid, NC_HDF5_FILE_INFO_T**);
int nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim, NC_GRP_INFO_T **dim_grp);
int nc4_find_var(NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var);
int nc4_find_dim_len(NC_GRP_INFO_T *grp, int dimid, size_t **len);
int nc4_find_type(NC_HDF5_FILE_INFO_T *h5, int typeid1, NC_TYPE_INFO_T **type);
NC_TYPE_INFO_T *nc4_rec_find_nc_type(NC_GRP_INFO_T *start_grp, hid_t target_nc_typeid);
@ -357,6 +356,10 @@ int nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp);
int nc4_enum_member_add(NC_ENUM_MEMBER_INFO_T **list, size_t size,
const char *name, const void *value);
/* Break & reform coordinate variables */
int nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T *dim);
int nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T *dim);
int NC_check_name(const char *name);
/* Check and normalize names. */

View File

@ -23,29 +23,6 @@
#define longtype ((sizeof(long) == sizeof(int) ? NC_INT : NC_INT64))
extern int nc_get_vara_ubyte(int ncid, int varid,
const size_t* start, const size_t* count,
unsigned char* value);
extern int nc_get_vara_ushort(int ncid, int varid,
const size_t* start, const size_t* count,
unsigned short* value);
extern int nc_get_vara_uint(int ncid, int varid,
const size_t* start, const size_t* count,
unsigned int* value);
extern int nc_get_vara_ulonglong(int ncid, int varid,
const size_t* start, const size_t* count,
unsigned long long* value);
extern int nc_put_vara_ushort(int ncid, int varid,
const size_t* start, const size_t* count,
const unsigned short* value);
extern int nc_put_vara_uint(int ncid, int varid,
const size_t* start, const size_t* count,
const unsigned int* value);
extern int nc_put_vara_ulonglong(int ncid, int varid,
const size_t* start, const size_t* count,
const unsigned long long* value);
#define X_INT_MAX 2147483647
/* Given a filename, check its magic number */

View File

@ -162,8 +162,10 @@ nullfree(s);
if(nclistlength(allvars) == nclistlength(vars)) flags |= NCF_PREFETCH_ALL;
ncstat = buildcachenode34(nccomm,newconstraint,vars,&cache,flags);
newconstraint = NULL; /* buildcachenode34 takes control of newconstraint */
if(ncstat) goto done;
cache->wholevariable = 1; /* All prefetches are whole variable */
if(ncstat != OC_NOERR) goto done;
else if(cache == NULL) goto done;
else
cache->wholevariable = 1; /* All prefetches are whole variable */
/* Make cache node be the prefetch node */
nccomm->cdf.cache->prefetch = cache;
if(SHOWFETCH) {
@ -190,7 +192,7 @@ ncbytesfree(buf);
done:
nclistfree(vars);
dcefree((DCEnode*)newconstraint);
if(ncstat) freenccachenode(nccomm,cache);
if(ncstat && cache != NULL) freenccachenode(nccomm,cache);
return THROW(ncstat);
}
@ -292,9 +294,10 @@ done:
if(constraint != NULL) dcefree((DCEnode*)constraint);
if(cachep) *cachep = cachenode;
if(ocstat != OC_NOERR) ncstat = ocerrtoncerr(ocstat);
if(ncstat) {
if(ncstat != OC_NOERR) {
freecdfroot34(dxdroot);
freenccachenode(nccomm,cachenode);
if(cachep) *cachep = NULL;
}
return THROW(ncstat);
}
@ -319,6 +322,7 @@ fprintf(stderr,"freecachenode: %s\n",
freecdfroot34(node->datadds);
nclistfree(node->vars);
nullfree(node);
}
void

View File

@ -151,7 +151,7 @@ defrecorddim3(NCDAPCOMMON* dapcomm)
NCerror
defseqdims(NCDAPCOMMON* dapcomm)
{
unsigned int i;
unsigned int i = 0;
NCerror ncstat = NC_NOERR;
int seqdims = 1; /* default is to compute seq dims counts */
@ -169,7 +169,7 @@ defseqdims(NCDAPCOMMON* dapcomm)
for(i=0;i<nclistlength(dapcomm->cdf.ddsroot->tree->seqnodes);i++) {
CDFnode* seq = (CDFnode*)nclistget(dapcomm->cdf.ddsroot->tree->seqnodes,i);
size_t seqsize;
size_t seqsize = 0;
CDFnode* sqdim = NULL;
CDFnode* container;
/* Does this sequence match the requirements for use ? */
@ -214,7 +214,7 @@ getseqdimsize(NCDAPCOMMON* dapcomm, CDFnode* seq, size_t* sizep)
CDFnode* dxdroot;
CDFnode* xseq;
NCbytes* seqcountconstraints = ncbytesnew();
size_t seqsize;
size_t seqsize = 0;
/* Read the minimal amount of data in order to get the count */
/* If the url is unconstrainable, then get the whole thing */
@ -524,7 +524,8 @@ computeseqcountconstraints3r(NCDAPCOMMON* dapcomm, CDFnode* node, CDFnode** cand
candidate = NULL;
compound = NULL;
if(node == NULL)
return;
for(i=0;i<nclistlength(node->subnodes);i++) {
CDFnode* subnode = (CDFnode*)nclistget(node->subnodes,i);
if(subnode->nctype == NC_Structure || subnode->nctype == NC_Grid)

View File

@ -31,7 +31,7 @@ NC4_inq_unlimdim(int ncid, int *unlimdimidp)
int found = 0;
int retval;
LOG((2, "called nc_inq_unlimdim"));
LOG((2, "%s: called", __func__));
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
return retval;
@ -74,7 +74,7 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
char norm_name[NC_MAX_NAME + 1];
int retval = NC_NOERR;
LOG((2, "nc_def_dim: ncid 0x%x name %s len %d", ncid, name,
LOG((2, "%s: ncid 0x%x name %s len %d", __func__, ncid, name,
(int)len));
/* Find our global metadata structure. */
@ -137,7 +137,6 @@ NC4_def_dim(int ncid, const char *name, size_t len, int *idp)
return NC_ENOMEM;
strcpy(grp->dim->name, norm_name);
grp->dim->len = len;
grp->dim->dirty++;
if (len == NC_UNLIMITED)
grp->dim->unlimited++;
@ -160,7 +159,7 @@ NC4_inq_dimid(int ncid, const char *name, int *idp)
int finished = 0;
int retval;
LOG((2, "nc_inq_dimid: ncid 0x%x name %s", ncid, name));
LOG((2, "%s: ncid 0x%x name %s", __func__, ncid, name));
/* Find metadata for this file. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
@ -204,7 +203,7 @@ NC4_inq_dim(int ncid, int dimid, char *name, size_t *lenp)
NC_DIM_INFO_T *dim;
int ret = NC_NOERR;
LOG((2, "nc_inq_dim: ncid 0x%x dimid %d", ncid, dimid));
LOG((2, "%s: ncid 0x%x dimid %d", __func__, ncid, dimid));
/* Find our global metadata structure. */
if ((ret = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
@ -277,7 +276,7 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
if (!name)
return NC_EINVAL;
LOG((2, "nc_rename_dim: ncid 0x%x dimid %d name %s", ncid,
LOG((2, "%s: ncid 0x%x dimid %d name %s", __func__, ncid,
dimid, name));
/* Find info for this file and group, and set pointer to each. */
@ -313,38 +312,61 @@ NC4_rename_dim(int ncid, int dimid, const char *name)
if (!dim)
return NC_EBADDIM;
/* If not in define mode, switch to it, unless the new name is
* shorter. (This is in accordance with the v3 interface.) */
/* if (!(h5->flags & NC_INDEF) && strlen(name) > strlen(dim->name)) */
/* { */
/* if (h5->cmode & NC_CLASSIC_MODEL) */
/* return NC_ENOTINDEFINE; */
/* if ((retval = NC4_redef(ncid))) */
/* return retval; */
/* } */
/* Save the old name, we'll need it to rename this object when we
* sync to HDF5 file. But if there already is an old_name saved,
* just stick with what we've got, since the user might be renaming
* the crap out of this thing, without ever syncing with the
* file. When the sync does take place, we only need the original
* name of the dim, not any of the intermediate ones. If the user
* could just make up his mind, we could all get on to writing some
* data... */
if (!dim->old_name)
/* Check for renaming dimension w/o variable */
if (dim->hdf_dimscaleid)
{
if (!(dim->old_name = malloc((strlen(dim->name) + 1) * sizeof(char))))
return NC_ENOMEM;
strcpy(dim->old_name, dim->name);
/* Sanity check */
assert(!dim->coord_var);
/* Close the HDF5 dataset */
if (H5Dclose(dim->hdf_dimscaleid) < 0)
return NC_EHDFERR;
dim->hdf_dimscaleid = 0;
/* Now delete the dataset (it will be recreated later, if necessary) */
if (H5Gunlink(grp->hdf_grpid, dim->name) < 0)
return NC_EDIMMETA;
}
/* Give the dimension its new name in metadata. UTF8 normalization
* has been done. */
free(dim->name);
if(dim->name)
free(dim->name);
if (!(dim->name = malloc((strlen(norm_name) + 1) * sizeof(char))))
return NC_ENOMEM;
strcpy(dim->name, norm_name);
/* Check if dimension was a coordinate variable, but names are different now */
if (dim->coord_var && strcmp(dim->name, dim->coord_var->name))
{
/* Break up the coordinate variable */
if ((retval = nc4_break_coord_var(grp, dim->coord_var, dim)))
return retval;
}
/* Check if dimension should become a coordinate variable */
if (!dim->coord_var)
{
NC_VAR_INFO_T *var;
/* Attempt to find a variable with the same name as the dimension in
* the current group. */
if ((retval = nc4_find_var(grp, dim->name, &var)))
return retval;
/* Check if we found a variable and the variable has the dimension in
* index 0. */
if (var && var->dim[0] == dim)
{
/* Sanity check */
assert(var->dimids[0] == dim->dimid);
/* Reform the coordinate variable */
if ((retval = nc4_reform_coord_var(grp, var, dim)))
return retval;
}
}
return NC_NOERR;
}
@ -362,7 +384,7 @@ NC4_inq_unlimdims(int ncid, int *nunlimdimsp, int *unlimdimidsp)
int num_unlim = 0;
int retval;
LOG((2, "nc_inq_unlimdims: ncid 0x%x", ncid));
LOG((2, "%s: ncid 0x%x", __func__, ncid));
/* Find info for this file and group, and set pointer to each. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))

File diff suppressed because it is too large Load Diff

View File

@ -23,7 +23,7 @@ NC4_def_grp(int parent_ncid, const char *name, int *new_ncid)
char norm_name[NC_MAX_NAME + 1];
int retval;
LOG((2, "nc_def_grp: parent_ncid 0x%x name %s", parent_ncid, name));
LOG((2, "%s: parent_ncid 0x%x name %s", __func__, parent_ncid, name));
/* Find info for this file and group, and set pointer to each. */
if ((retval = nc4_find_grp_h5(parent_ncid, &grp, &h5)))
@ -98,19 +98,25 @@ NC4_rename_grp(int grpid, const char *name)
if ((retval = NC4_redef(grpid)))
return retval;
/* Save the old name, we'll need it to rename this object when we
* sync to HDF5 file. But if there already is an old_name saved,
* just stick with what we've got, since the user might be renaming
* the crap out of this thing, without ever syncing with the
* file. When the sync does take place, we only need the original
* name of the grp, not any of the intermediate ones. If the user
* could just make up his mind, we could all get on to writing some
* data... */
if (!grp->old_name)
/* Rename the group, if it exists in the file */
if (grp->hdf_grpid)
{
if (!(grp->old_name = malloc((strlen(grp->name) + 1) * sizeof(char))))
return NC_ENOMEM;
strcpy(grp->old_name, grp->name);
/* Close the group */
if (H5Gclose(grp->hdf_grpid) < 0)
return NC_EHDFERR;
grp->hdf_grpid = 0;
/* Attempt to rename & re-open the group, if the parent group is open */
if (grp->parent->hdf_grpid)
{
/* Rename the group */
if (H5Gmove(grp->parent->hdf_grpid, grp->name, name) < 0)
return NC_EHDFERR;
/* Reopen the group, with the new name */
if ((grp->hdf_grpid = H5Gopen2(grp->parent->hdf_grpid, name, H5P_DEFAULT)) < 0)
return NC_EHDFERR;
}
}
/* Give the group its new name in metadata. UTF8 normalization

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@ conditions.
#include "nc4internal.h"
#include "nc.h" /* from libsrc */
#include "ncdispatch.h" /* from libdispatch */
#include "H5DSpublic.h"
#include <utf8proc.h>
#if 0 /*def USE_PNETCDF*/
@ -125,7 +126,7 @@ find_var_dim_max_length(NC_GRP_INFO_T *grp, int varid, int dimid, size_t *maxlen
if ((dataset_ndims = H5Sget_simple_extent_dims(spaceid,
h5dimlen, h5dimlenmax)) < 0)
BAIL(NC_EHDFERR);
LOG((5, "find_var_shape_nc: varid %d len %d max: %d",
LOG((5, "find_var_dim_max_length: varid %d len %d max: %d",
varid, (int)h5dimlen[0], (int)h5dimlenmax[0]));
for (d=0; d<dataset_ndims; d++) {
if (var->dimids[d] == dimid) {
@ -176,30 +177,10 @@ nc4_nc4f_list_add(NC *nc, const char *path, int mode)
return nc4_grp_list_add(&(h5->root_grp), h5->next_nc_grpid++,
NULL, nc, NC_GROUP_NAME, &grp);
}
/* /\* Given an ncid, find the relevant group and return a pointer to */
/* * it. *\/ */
/* NC_GRP_INFO_T * */
/* find_nc_grp(int ncid) */
/* { */
/* NC *f; */
/* for (f = nc_file; f; f = f->next) */
/* { */
/* if (f->ext_ncid == (ncid & FILE_ID_MASK)) */
/* { */
/* assert(f->nc4_info && f->nc4_info->root_grp); */
/* return nc4_rec_find_grp(f->nc4_info->root_grp, (ncid & GRP_ID_MASK)); */
/* } */
/* } */
/* return NULL; */
/* } */
/* Given an ncid, find the relevant group and return a pointer to it,
* return an error of this is not a netcdf-4 file (or if strict nc3 is
* turned on for this file.) */
int
nc4_find_nc4_grp(int ncid, NC_GRP_INFO_T **grp)
{
@ -365,6 +346,20 @@ nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim,
return NC_NOERR;
}
/* Find a var (by name) in a grp. */
int
nc4_find_var(NC_GRP_INFO_T *grp, const char *name, NC_VAR_INFO_T **var)
{
assert(grp && var && name);
/* Find the var info. */
for ((*var) = grp->var; (*var); (*var) = (*var)->next)
if (0 == strcmp(name, (*var)->name))
break;
return NC_NOERR;
}
/* Recursively hunt for a HDF type id. */
NC_TYPE_INFO_T *
nc4_rec_find_hdf_type(NC_GRP_INFO_T *start_grp, hid_t target_hdf_typeid)
@ -703,8 +698,7 @@ nc4_grp_list_add(NC_GRP_INFO_T **list, int new_nc_grpid,
{
NC_GRP_INFO_T *g;
LOG((3, "grp_list_add: new_nc_grpid %d name %s ",
new_nc_grpid, name));
LOG((3, "%s: new_nc_grpid %d name %s ", __func__, new_nc_grpid, name));
/* Get the memory to store this groups info. */
if (!(*grp = calloc(1, sizeof(NC_GRP_INFO_T))))
@ -858,9 +852,17 @@ nc4_enum_member_add(NC_ENUM_MEMBER_INFO_T **list, size_t size,
LOG((4, "nc4_enum_member_add: size %d name %s", size, name));
/* Allocate storage for this field information. */
if (!(member = calloc(1, sizeof(NC_ENUM_MEMBER_INFO_T))) ||
!(member->value = calloc(1, size)))
if (!(member = calloc(1, sizeof(NC_ENUM_MEMBER_INFO_T))))
return NC_ENOMEM;
if (!(member->value = calloc(1, size))) {
free(member);
return NC_ENOMEM;
}
if (!(member->name = malloc((strlen(name) + 1) * sizeof(char)))) {
free(member->value);
free(member);
return NC_ENOMEM;
}
/* Add this field to list. */
if (*list)
@ -877,11 +879,6 @@ nc4_enum_member_add(NC_ENUM_MEMBER_INFO_T **list, size_t size,
}
/* Store the information about this member. */
if (!(member->name = malloc((strlen(name) + 1) * sizeof(char)))) {
if(member) free(member);
return NC_ENOMEM;
}
strcpy(member->name, name);
memcpy(member->value, value, size);
@ -1086,8 +1083,6 @@ nc4_dim_list_del(NC_DIM_INFO_T **list, NC_DIM_INFO_T *dim)
/* Free memory allocated for names. */
if (dim->name)
free(dim->name);
if (dim->old_name)
free(dim->old_name);
free(dim);
return NC_NOERR;
@ -1122,7 +1117,7 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
int retval;
assert(grp);
LOG((3, "nc4_rec_grp_del: grp->name %s", grp->name));
LOG((3, "%s: grp->name %s", __func__, grp->name));
/* Recursively call this function for each child, if any, stopping
* if there is an error. */
@ -1140,7 +1135,7 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
att = grp->att;
while (att)
{
LOG((4, "nc4_rec_grp_del: deleting att %s", att->name));
LOG((4, "%s: deleting att %s", __func__, att->name));
a = att->next;
if ((retval = nc4_att_list_del(&grp->att, att)))
return retval;
@ -1151,11 +1146,10 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
var = grp->var;
while (var)
{
LOG((4, "nc4_rec_grp_del: deleting var %s", var->name));
LOG((4, "%s: deleting var %s", __func__, var->name));
/* Close HDF5 dataset associated with this var, unless it's a
* scale. */
if (var->hdf_datasetid && !var->dimscale &&
H5Dclose(var->hdf_datasetid) < 0)
if (var->hdf_datasetid && H5Dclose(var->hdf_datasetid) < 0)
return NC_EHDFERR;
v = var->next;
if ((retval = nc4_var_list_del(&grp->var, var)))
@ -1167,7 +1161,7 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
dim = grp->dim;
while (dim)
{
LOG((4, "nc4_rec_grp_del: deleting dim %s", dim->name));
LOG((4, "%s: deleting dim %s", __func__, dim->name));
/* Close HDF5 dataset associated with this dim. */
if (dim->hdf_dimscaleid && H5Dclose(dim->hdf_dimscaleid) < 0)
return NC_EHDFERR;
@ -1181,7 +1175,7 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
type = grp->type;
while (type)
{
LOG((4, "nc4_rec_grp_del: deleting type %s", type->name));
LOG((4, "%s: deleting type %s", __func__, type->name));
t = type->next;
if ((retval = type_list_del(&grp->type, type)))
return retval;
@ -1189,7 +1183,7 @@ nc4_rec_grp_del(NC_GRP_INFO_T **list, NC_GRP_INFO_T *grp)
}
/* Tell HDF5 we're closing this group. */
LOG((4, "nc4_rec_grp_del: closing group %s", grp->name));
LOG((4, "%s: closing group %s", __func__, grp->name));
if (grp->hdf_grpid && H5Gclose(grp->hdf_grpid) < 0)
return NC_EHDFERR;
@ -1259,6 +1253,113 @@ nc4_att_list_del(NC_ATT_INFO_T **list, NC_ATT_INFO_T *att)
return NC_NOERR;
}
/* Break a coordinate variable to separate the dimension and the variable */
int
nc4_break_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *coord_var, NC_DIM_INFO_T *dim)
{
int retval = NC_NOERR;
/* Sanity checks */
assert(dim->coord_var == coord_var);
assert(coord_var->dim[0] == dim);
assert(coord_var->dimids[0] == dim->dimid);
assert(0 == dim->hdf_dimscaleid);
/* If we're replacing an existing dimscale dataset, go to
* every var in the file and detach this dimension scale. */
if ((retval = rec_detach_scales(grp->nc4_info->root_grp,
dim->dimid, coord_var->hdf_datasetid)))
return retval;
/* Allow attached dimscales to be tracked on the [former] coordinate variable */
if (coord_var->ndims)
{
/* Coordinate variables shouldn't have dimscales attached */
assert(NULL == coord_var->dimscale_attached);
/* Allocate space for tracking them */
if (NULL == (coord_var->dimscale_attached = calloc(coord_var->ndims, sizeof(int))))
return NC_ENOMEM;
}
/* Detach dimension from variable */
coord_var->dimscale = 0;
coord_var->dirty++;
dim->coord_var = NULL;
return NC_NOERR;
}
/* Reform a coordinate variable from a dimension and a variable */
int
nc4_reform_coord_var(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, NC_DIM_INFO_T *dim)
{
int retval = NC_NOERR;
/* Attach variable to dimension */
var->dimscale++;
var->dirty++;
dim->coord_var = var;
/* Detach dimscales from the [new] coordinate variable */
if(var->dimscale_attached)
{
int dims_detached = 0;
int finished = 0;
int d;
/* Loop over all dimensions for variable */
for (d = 0; d < var->ndims && !finished; d++)
/* Is there a dimscale attached to this axis? */
if(var->dimscale_attached[d])
{
NC_GRP_INFO_T *g;
for (g = grp; g && !finished; g = g->parent)
{
NC_DIM_INFO_T *dim1;
for (dim1 = g->dim; dim1 && !finished; dim1 = dim1->next)
if (var->dimids[d] == dim1->dimid)
{
hid_t dim_datasetid; /* Dataset ID for dimension */
/* Find dataset ID for dimension */
if (dim1->coord_var)
dim_datasetid = dim1->coord_var->hdf_datasetid;
else
dim_datasetid = dim1->hdf_dimscaleid;
assert(dim_datasetid > 0);
if (H5DSdetach_scale(var->hdf_datasetid, dim_datasetid, d) < 0)
BAIL(NC_EHDFERR);
var->dimscale_attached[d] = 0;
if (dims_detached++ == var->ndims)
finished++;
}
}
}
/* Release & reset the array tracking attached dimscales */
free(var->dimscale_attached);
var->dimscale_attached = NULL;
}
/* Use variable's dataset ID for the dimscale ID */
if (dim->hdf_dimscaleid)
{
if (H5Dclose(dim->hdf_dimscaleid) < 0)
BAIL(NC_EHDFERR);
dim->hdf_dimscaleid = 0;
/* Now delete the dimscale's dataset (it will be recreated later, if necessary) */
if (H5Gunlink(grp->hdf_grpid, dim->name) < 0)
return NC_EDIMMETA;
}
exit:
return retval;
}
/* Normalize a UTF8 name. Put the result in norm_name, which can be
* NC_MAX_NAME + 1 in size. This function makes sure the free() gets
* called on the return from utf8proc_NFC, and also ensures that the

View File

@ -66,9 +66,6 @@ nc4_reopen_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
#ifdef EXTRA_TESTS
num_plists--;
#endif
if (var->dimscale)
var->dim[0]->hdf_dimscaleid = var->hdf_datasetid;
}
return NC_NOERR;
@ -293,8 +290,8 @@ nc4_find_default_chunksizes2(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
if (suggested_size > var->dim[d]->len)
suggested_size = var->dim[d]->len;
var->chunksizes[d] = suggested_size ? suggested_size : 1;
LOG((4, "nc_def_var_nc4: name %s dim %d DEFAULT_CHUNK_SIZE %d num_values %f type_size %d "
"chunksize %ld", var->name, d, DEFAULT_CHUNK_SIZE, num_values, type_size, var->chunksizes[d]));
LOG((4, "%s: name %s dim %d DEFAULT_CHUNK_SIZE %d num_values %f type_size %d "
"chunksize %ld", __func__, var->name, d, DEFAULT_CHUNK_SIZE, num_values, type_size, var->chunksizes[d]));
}
/* Find total chunk size. */
@ -348,9 +345,7 @@ nc_def_var_nc4(int ncid, const char *name, nc_type xtype,
NC_HDF5_FILE_INFO_T *h5;
NC_TYPE_INFO_T *type_info;
char norm_name[NC_MAX_NAME + 1];
int num_unlim = 0;
int d;
size_t num_values = 1;
int retval;
/* Find info for this file and group, and set pointer to each. */
@ -406,14 +401,10 @@ nc_def_var_nc4(int ncid, const char *name, nc_type xtype,
{
if ((retval = nc4_find_dim(grp, dimidsp[d], &dim, NULL)))
return retval;
if (dim->unlimited)
num_unlim++;
else
num_values *= dim->len;
}
/* These degrubbing messages sure are handy! */
LOG((3, "nc_def_var_nc4: name %s type %d ndims %d", norm_name, xtype, ndims));
LOG((3, "%s: name %s type %d ndims %d", __func__, norm_name, xtype, ndims));
#ifdef LOGGING
{
int dd;
@ -455,8 +446,6 @@ nc_def_var_nc4(int ncid, const char *name, nc_type xtype,
&var->type_info->size)))
return retval;
}
if (!num_unlim)
var->contiguous = 1;
/* Allocate space for dimension information. */
if (ndims)
@ -467,21 +456,49 @@ nc_def_var_nc4(int ncid, const char *name, nc_type xtype,
return NC_ENOMEM;
}
/* Assign dimensions to the variable */
/* At the same time, check to see if this is a coordinate
* variable. If so, it will have the same name as one of its
* dimensions. If it is a coordinate var, is it a coordinate var in
* the same group as the dim? */
/* Also, check whether we should use contiguous or chunked storage */
var->contiguous = 1;
for (d = 0; d < ndims; d++)
{
NC_GRP_INFO_T *dim_grp;
/* Look up each dimension */
if ((retval = nc4_find_dim(grp, dimidsp[d], &dim, &dim_grp)))
return retval;
if (strcmp(dim->name, norm_name) == 0 && dim_grp == grp && d == 0)
/* Check for dim index 0 having the same name, in the same group */
if (d == 0 && dim_grp == grp && strcmp(dim->name, norm_name) == 0)
{
var->dimscale++;
dim->coord_var = var;
dim->coord_var_in_grp++;
/* Use variable's dataset ID for the dimscale ID */
if (dim->hdf_dimscaleid)
{
/* Detach dimscale from any variables using it */
if ((retval = rec_detach_scales(grp, dimidsp[d], dim->hdf_dimscaleid)) < 0)
return retval;
if (H5Dclose(dim->hdf_dimscaleid) < 0)
return NC_EHDFERR;
dim->hdf_dimscaleid = 0;
/* Now delete the dataset (it will be recreated later, if necessary) */
if (H5Gunlink(grp->hdf_grpid, dim->name) < 0)
return NC_EDIMMETA;
}
}
/* Check for unlimited dimension and turn off contiguous storage */
if (dim->unlimited)
var->contiguous = 0;
/* Track dimensions for variable */
var->dimids[d] = dimidsp[d];
var->dim[d] = dim;
}
@ -547,8 +564,8 @@ NC4_def_var(int ncid, const char *name, nc_type xtype, int ndims,
NC *nc;
NC_HDF5_FILE_INFO_T *h5;
LOG((2, "nc_def_var: ncid 0x%x name %s xtype %d ndims %d",
ncid, name, xtype, ndims));
LOG((2, "%s: ncid 0x%x name %s xtype %d ndims %d",
__func__, ncid, name, xtype, ndims));
/* If there are dimensions, I need their ids. */
if (ndims && !dimidsp)
@ -596,7 +613,7 @@ NC4_inq_var_all(int ncid, int varid, char *name, nc_type *xtypep,
int d;
int retval;
LOG((2, "nc_inq_var_all: ncid 0x%x varid %d", ncid, varid));
LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid));
/* Find info for this file and group, and set pointer to each. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
@ -726,7 +743,7 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
int d;
int retval;
LOG((2, "nc_def_var_extra: ncid 0x%x varid %d", ncid, varid));
LOG((2, "%s: ncid 0x%x varid %d", __func__, ncid, varid));
/* Find info for this file and group, and set pointer to each. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
@ -786,7 +803,7 @@ nc_def_var_extra(int ncid, int varid, int *shuffle, int *deflate,
var->deflate = *deflate;
if (*deflate)
var->deflate_level = *deflate_level;
LOG((3, "nc_def_var_extra: *deflate_level %d", *deflate_level));
LOG((3, "%s: *deflate_level %d", __func__, *deflate_level));
}
/* Szip in use? */
@ -1070,7 +1087,7 @@ NC4_inq_varid(int ncid, const char *name, int *varidp)
if (!varidp)
return NC_NOERR;
LOG((2, "nc_inq_varid: ncid 0x%x name %s", ncid, name));
LOG((2, "%s: ncid 0x%x name %s", __func__, ncid, name));
/* Find info for this file and group, and set pointer to each. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, NULL)))
@ -1114,8 +1131,8 @@ NC4_rename_var(int ncid, int varid, const char *name)
NC_VAR_INFO_T *var;
int retval = NC_NOERR;
LOG((2, "nc_rename_var: ncid 0x%x varid %d name %s",
ncid, varid, name));
LOG((2, "%s: ncid 0x%x varid %d name %s",
__func__, ncid, varid, name));
/* Find info for this file and group, and set pointer to each. */
if ((retval = nc4_find_nc_grp_h5(ncid, &nc, &grp, &h5)))
@ -1174,6 +1191,38 @@ NC4_rename_var(int ncid, int varid, const char *name)
return NC_ENOMEM;
strcpy(var->name, name);
/* Check if this was a coordinate variable previously, but names are different now */
if (var->dimscale && strcmp(var->name, var->dim[0]->name))
{
/* Break up the coordinate variable */
if ((retval = nc4_break_coord_var(grp, var, var->dim[0])))
return retval;
}
/* Check if this should become a coordinate variable */
if (!var->dimscale)
{
/* Only variables with >0 dimensions can become coordinate variables */
if (var->ndims)
{
NC_GRP_INFO_T *dim_grp;
NC_DIM_INFO_T *dim;
/* Check to see if this is became a coordinate variable. If so, it
* will have the same name as dimension index 0. If it is a
* coordinate var, is it a coordinate var in the same group as the dim?
*/
if ((retval = nc4_find_dim(grp, var->dimids[0], &dim, &dim_grp)))
return retval;
if (strcmp(dim->name, name) == 0 && dim_grp == grp)
{
/* Reform the coordinate variable */
if ((retval = nc4_reform_coord_var(grp, var, dim)))
return retval;
}
}
}
exit:
return retval;
}
@ -1191,7 +1240,7 @@ NC4_var_par_access(int ncid, int varid, int par_access)
NC_VAR_INFO_T *var;
int retval;
LOG((1, "nc_var_par_access: ncid 0x%x varid %d par_access %d", ncid,
LOG((1, "%s: ncid 0x%x varid %d par_access %d", __func__, ncid,
varid, par_access));
if (par_access != NC_INDEPENDENT && par_access != NC_COLLECTIVE)
@ -1245,8 +1294,8 @@ nc4_put_vara_tc(int ncid, int varid, nc_type mem_type, int mem_type_is_long,
NC_HDF5_FILE_INFO_T *h5;
#endif
LOG((2, "nc4_put_vara_tc: ncid 0x%x varid %d mem_type %d mem_type_is_long %d",
ncid, varid, mem_type, mem_type_is_long));
LOG((2, "%s: ncid 0x%x varid %d mem_type %d mem_type_is_long %d",
__func__, ncid, varid, mem_type, mem_type_is_long));
if (!(nc = nc4_find_nc_file(ncid,NULL)))
return NC_EBADID;
@ -1375,8 +1424,8 @@ nc4_get_vara_tc(int ncid, int varid, nc_type mem_type, int mem_type_is_long,
NC *nc;
NC_HDF5_FILE_INFO_T* h5;
LOG((2, "nc4_get_vara_tc: ncid 0x%x varid %d mem_type %d mem_type_is_long %d",
ncid, varid, mem_type, mem_type_is_long));
LOG((2, "%s: ncid 0x%x varid %d mem_type %d mem_type_is_long %d",
__func__, ncid, varid, mem_type, mem_type_is_long));
if (!(nc = nc4_find_nc_file(ncid,&h5)))
return NC_EBADID;

View File

@ -25,14 +25,14 @@ netCDF4+DAP | [netCDF4.3.0-NC4-DAP-32.exe][r4] | [netCDF4.3.0-NC4-DAP-64.exe][r
## Latest Release Candidate (netCDF-C 4.3.1-rc4)
## Latest Release Candidate (netCDF-C 4.3.1-rc5)
Configuration | 32-bit | 64-bit |
:-------------------|:-------- |:-------|
netCDF 3 | [netCDF4.3.1-rc4-NC3-32.exe][rc1] | [netCDF4.3.1-rc4-NC3-64.exe][rc5]
netCDF3+DAP | [netCDF4.3.1-rc4-NC3-DAP-32.exe][rc2] | [netCDF4.3.1-rc4-NC3-DAP-64.exe][rc6]
netCDF4 | [netCDF4.3.1-rc4-NC4-32.exe][rc3] | [netCDF4.3.1-rc4-NC4-64.exe][rc7]
netCDF4+DAP | [netCDF4.3.1-rc4-NC4-DAP-32.exe][rc4] | [netCDF4.3.1-rc4-NC4-DAP-64.exe][rc8]
netCDF 3 | [netCDF4.3.1-rc5-NC3-32.exe][rc1] | [netCDF4.3.1-rc5-NC3-64.exe][rc5]
netCDF3+DAP | [netCDF4.3.1-rc5-NC3-DAP-32.exe][rc2] | [netCDF4.3.1-rc5-NC3-DAP-64.exe][rc6]
netCDF4 | [netCDF4.3.1-rc5-NC4-32.exe][rc3] | [netCDF4.3.1-rc5-NC4-64.exe][rc7]
netCDF4+DAP | [netCDF4.3.1-rc5-NC4-DAP-32.exe][rc4] | [netCDF4.3.1-rc5-NC4-DAP-64.exe][rc8]
# Using the netCDF-C Libraries with Visual Studio
In order to use the netcdf libraries, you must ensure that the .dll files (along with any dependencies from deps/shared/bin) are on the system path. In order to compile a program using these libraries, you must first link your program against the appropriate 'import' (.lib) libraries.
@ -62,11 +62,11 @@ When installed, the netCDF libraries are placed in the specified locations, alon
[r8]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.0-NC4-DAP-64.exe
[rc1]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC3-32.exe
[rc2]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC3-DAP-32.exe
[rc3]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC4-32.exe
[rc4]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC4-DAP-32.exe
[rc5]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC3-64.exe
[rc6]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC3-DAP-64.exe
[rc7]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC4-64.exe
[rc8]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc4-NC4-DAP-64.exe
[rc1]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC3-32.exe
[rc2]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC3-DAP-32.exe
[rc3]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC4-32.exe
[rc4]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC4-DAP-32.exe
[rc5]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC3-64.exe
[rc6]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC3-DAP-64.exe
[rc7]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC4-64.exe
[rc8]: http://www.unidata.ucar.edu/netcdf/win_netcdf/netCDF4.3.1-rc5-NC4-DAP-64.exe

View File

@ -129,7 +129,8 @@ radar_3d_chunking.txt tst_floats_1D.cdl floats_1D_3.nc floats_1D.cdl \
tst_*.nc tst_floats2_*.cdl tst_ints2_*.cdl tst_shorts2_*.cdl \
tst_elena_*.cdl tst_simple*.cdl tst_chunks.cdl pr_A1.* tauu_A1.* \
usi_01.* thetau_01.* tst_*.nc tst_*.h5 \
tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl
tst_grp_rename.cdl tst_grp_rename.nc tst_grp_rename.dmp ref_grp_rename.cdl \
foo1.nc
if USE_HDF4_FILE_TESTS
DISTCLEANFILES = AMSR_E_L2_Rain_V10_200905312326_A.hdf \

View File

@ -7,6 +7,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define LOGGING
#include "netcdf.h"

View File

@ -102,8 +102,8 @@ main(int argc, char **argv)
if (long_in != lval) ERR;
/* This should fail. */
coord[3] = 100;
if (nc_get_var1_ushort(ncid, varid, &coord[3],
coord[0] = 5;
if (nc_get_var1_ushort(ncid, varid, coord,
&ushort_in) != NC_EINVALCOORDS) ERR;
if (nc_close(ncid)) ERR;
@ -162,8 +162,8 @@ main(int argc, char **argv)
if (long_in != lval) ERR;
/* This should fail. */
coord[3] = 100;
if (nc_get_var1_ushort(ncid, varid, &coord[3],
coord[0] = 5;
if (nc_get_var1_ushort(ncid, varid, coord,
&ushort_in) != NC_EINVALCOORDS) ERR;
if (nc_close(ncid)) ERR;

View File

@ -15,7 +15,6 @@
#define LEVEL_NAME "level"
#define TIME_NAME "time"
#define DIM5_NAME "twilight_zone"
#define DIM_NAME "dim"
#define LAT_LEN 1
#define LON_LEN 2
#define LEVEL_LEN 3
@ -171,6 +170,153 @@ main(int argc, char **argv)
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("*** Testing renaming dimensions and vars...");
{
#define FILE_NAME1 "foo1.nc"
#define FILE_NAME2 "foo2.nc"
#define FILE_NAME3 "foo3.nc"
#define FILE_NAME4 "foo4.nc"
#define DIM_NAME "lat_T42"
#define VAR_NAME DIM_NAME
#define DIM_NAME2 "lat"
#define VAR_NAME2 DIM_NAME2
#define RANK_lat_T42 1
int ncid, varid, dimid;
int lat_T42_dim;
size_t lat_T42_len = 3;
int lat_T42_id;
int lat_T42_dims[RANK_lat_T42];
char name[NC_MAX_NAME + 1];
/* =========== */
/* Sub-test #1 */
/* =========== */
/* create file with dimension and associated coordinate variable */
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
lat_T42_dims[0] = lat_T42_dim;
if (nc_def_var(ncid, VAR_NAME, NC_INT, RANK_lat_T42, lat_T42_dims, &lat_T42_id)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, rename coordinate dimension and then associated variable */
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME, &dimid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME, &varid)) ERR;
if (nc_rename_dim(ncid, dimid, DIM_NAME2)) ERR;
if (nc_rename_var(ncid, varid, VAR_NAME2)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, check coordinate dimension and associated variable names */
/* Should be just like they created the file with DIM_NAME2 & VAR_NAME2 to
* begin with.
*/
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME2, &dimid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME2, &varid)) ERR;
if (nc_inq_dimname(ncid, dimid, name)) ERR;
if (strcmp(name, DIM_NAME2)) ERR;
if (nc_inq_varname(ncid, varid, name)) ERR;
if (strcmp(name, VAR_NAME2)) ERR;
if (nc_close(ncid)) ERR;
/* =========== */
/* Sub-test #2 */
/* =========== */
/* create file with dimension and associated coordinate variable */
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
lat_T42_dims[0] = lat_T42_dim;
if (nc_def_var(ncid, VAR_NAME, NC_INT, RANK_lat_T42, lat_T42_dims, &lat_T42_id)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, just rename coordinate dimension */
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME, &dimid)) ERR;
if (nc_rename_dim(ncid, dimid, DIM_NAME2)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, check coordinate dimension and associated variable names */
/* Should be just like the file was created with DIM_NAME2 to begin with */
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME2, &dimid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME, &varid)) ERR;
if (nc_inq_dimname(ncid, dimid, name)) ERR;
if (strcmp(name, DIM_NAME2)) ERR;
if (nc_inq_varname(ncid, varid, name)) ERR;
if (strcmp(name, VAR_NAME)) ERR;
if (nc_close(ncid)) ERR;
/* =========== */
/* Sub-test #3 */
/* =========== */
/* create file with dimension and associated coordinate variable */
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
lat_T42_dims[0] = lat_T42_dim;
if (nc_def_var(ncid, VAR_NAME, NC_INT, RANK_lat_T42, lat_T42_dims, &lat_T42_id)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, just rename variable */
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME, &varid)) ERR;
if (nc_rename_var(ncid, varid, VAR_NAME2)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, check coordinate dimension and associated variable names */
/* Should be just like the file was created with VAR_NAME2 to begin with */
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME, &dimid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME2, &varid)) ERR;
if (nc_inq_dimname(ncid, dimid, name)) ERR;
if (strcmp(name, DIM_NAME)) ERR;
if (nc_inq_varname(ncid, varid, name)) ERR;
if (strcmp(name, VAR_NAME2)) ERR;
if (nc_close(ncid)) ERR;
/* =========== */
/* Sub-test #4 */
/* =========== */
/* create file with dimension and associated coordinate variable */
if (nc_create(FILE_NAME1, NC_CLOBBER|NC_NETCDF4|NC_CLASSIC_MODEL, &ncid)) ERR;
if (nc_def_dim(ncid, DIM_NAME, lat_T42_len, &lat_T42_dim)) ERR;
lat_T42_dims[0] = lat_T42_dim;
if (nc_def_var(ncid, VAR_NAME, NC_INT, RANK_lat_T42, lat_T42_dims, &lat_T42_id)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, rename associated variable and then coordinate dimension */
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME, &dimid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME, &varid)) ERR;
if (nc_rename_var(ncid, varid, VAR_NAME2)) ERR;
if (nc_rename_dim(ncid, dimid, DIM_NAME2)) ERR;
if (nc_close(ncid)) ERR;
/* reopen file, check coordinate dimension and associated variable names */
/* Should be just like they created the file with DIM_NAME2 & VAR_NAME2 to
* begin with.
*/
if (nc_open(FILE_NAME1, NC_WRITE, &ncid)) ERR;
if (nc_inq_dimid(ncid, DIM_NAME2, &dimid)) ERR;
if (nc_inq_varid(ncid, VAR_NAME2, &varid)) ERR;
if (nc_inq_dimname(ncid, dimid, name)) ERR;
if (strcmp(name, DIM_NAME2)) ERR;
if (nc_inq_varname(ncid, varid, name)) ERR;
if (strcmp(name, VAR_NAME2)) ERR;
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
printf("*** Testing file with just one unlimited dimension...");
{

View File

@ -68,9 +68,6 @@ main(int argc, char **argv)
* Christian! Next time I'm in Rostock I'll come by and buy you
* a beer. ;-) */
#define TL 15
#define SHUFFLE 0
#define DEFLATE 1
#define DEFLATE_LEVEL 5
int ncid;
int time_dim;
int tl_dim;
@ -137,9 +134,6 @@ main(int argc, char **argv)
* Christian! Next time I'm in Rostock I'll come by and buy you
* a beer. ;-) */
#define TL 15
#define SHUFFLE 0
#define DEFLATE 1
#define DEFLATE_LEVEL 5
#define NDIMS2 2
#define NUM_TIMES 16
int ncid;
@ -247,7 +241,6 @@ main(int argc, char **argv)
SUMMARIZE_ERR;
printf("*** Checking multiple unlimited dimensions...");
{
#define MAX(x,y) ((x)>(y)?(x):(y))
#define NDIMS 2
#define MAX_VALUES 3

View File

@ -53,6 +53,7 @@ int test_pio(int);
int test_pio_attr(int);
int test_pio_big(int);
int test_pio_hyper(int);
int test_pio_extend(int);
char* getenv_all(MPI_Comm comm, int root, const char* name);
int facc_type;

View File

@ -31,6 +31,7 @@ define_netcdf(void)
} else { /* construct a usable output file name */
if (cdlname != NULL && strcmp(cdlname,"-") != 0) {/* cmd line name */
char* p;
strncpy(filename,cdlname,2048);
/* remove any suffix and prefix*/
p = strrchr(filename,'.');

View File

@ -49,7 +49,7 @@ nc_get_iter(Symbol* vsym,
Symbol* vartype;
size_t value_size; /* size in bytes of each variable element */
int ndims; /* number of dimensions for variable */
size_t dimsizes[NC_MAX_VAR_DIMS]; /* variable dimension sizes */
size_t dimsizes[NC_MAX_VAR_DIMS] = {0}; /* variable dimension sizes */
long long nvalues = 1;
int dim;

View File

@ -18,7 +18,6 @@ static void processtypes(void);
static void processtypesizes(void);
static void processvars(void);
static void processattributes(void);
static void processspecials(void);
static void processunlimiteddims(void);
static void processeconstrefs(void);
static void processeconstrefsR(Datalist*);
@ -54,10 +53,6 @@ processsemantics(void)
processtypesizes();
/* Process each var to fill in missing fields, etc*/
processvars();
/* If we are not allowing certain special attributes,
but they were defined, convert them back to attributes
*/
processspecials();
/* Process attributes to connect to corresponding variable*/
processattributes();
/* Fix up enum constant values*/
@ -707,118 +702,6 @@ processtypesizes(void)
}
}
#ifdef NCF213 /*Jira NCF-213*/
/* We should not create an actual
attribute for any of the
special attributes.
*/
static void
makespecial(int tag, Symbol* vsym, nc_type typ, Datalist* dlist)
{
Symbol* attr = install(specialname(tag));
attr->objectclass = NC_ATT;
attr->data = dlist;
if(vsym) {
Symbol* grp = vsym->container;
if(grp) listpush(grp->subnodes,(void*)attr);
attr->container = grp;
}
attr->att.var = vsym;
attr->typ.basetype = primsymbols[typ==NC_STRING?NC_CHAR:typ];
listpush(attdefs,(void*)attr);
}
#endif /*NCF213*/
static void
processspecial1(Symbol* vsym)
{
unsigned long flags = vsym->var.special.flags;
int i,tag;
NCConstant con;
Datalist* dlist = NULL;
if(flags == 0) return; /* no specials defined */
con = nullconstant;
if((tag=(flags & _CHUNKSIZES_FLAG))) {
dlist = builddatalist(vsym->var.special.nchunks);
for(i=0;i<vsym->var.special.nchunks;i++) {
con = nullconstant;
con.nctype = NC_INT;
con.value.int32v = (int)vsym->var.special._ChunkSizes[i];
dlappend(dlist,&con);
}
} else if((tag=(flags & _STORAGE_FLAG))) {
con.nctype = NC_STRING;
con.value.stringv.stringv
= (vsym->var.special._Storage == NC_CHUNKED? "chunked"
: "contiguous");
con.value.stringv.len = strlen(con.value.stringv.stringv);
dlist = builddatalist(1);
dlappend(dlist,&con);
}
if((tag=(flags & _FLETCHER32_FLAG))) {
con.nctype = NC_STRING;
con.value.stringv.stringv
= (vsym->var.special._Fletcher32 == 1? "true"
: "false");
con.value.stringv.len = strlen(con.value.stringv.stringv);
dlist = builddatalist(1);
dlappend(dlist,&con);
}
if((tag=(flags & _DEFLATE_FLAG))) {
con.nctype = NC_INT;
con.value.int32v = vsym->var.special._DeflateLevel;
dlist = builddatalist(1);
dlappend(dlist,&con);
}
if((tag=(flags & _SHUFFLE_FLAG))) {
con.nctype = NC_STRING;
con.value.stringv.stringv
= (vsym->var.special._Shuffle == 1? "true"
: "false");
con.value.stringv.len = strlen(con.value.stringv.stringv);
dlist = builddatalist(1);
dlappend(dlist,&con);
}
if((tag=(flags & _ENDIAN_FLAG))) {
con.nctype = NC_STRING;
con.value.stringv.stringv
= (vsym->var.special._Endianness == 1? "little"
:"big");
con.value.stringv.len = strlen(con.value.stringv.stringv);
dlist = builddatalist(1);
dlappend(dlist,&con);
}
if((tag=(flags & _NOFILL_FLAG))) {
con.nctype = NC_STRING;
/* Watch out: flags is NOFILL, but we store FILL */
if(vsym->var.special._Fill == 1) {
con.value.stringv.stringv = "false";
} else {
nofill_flag = 1;
con.value.stringv.stringv = "true";
}
con.value.stringv.len = strlen(con.value.stringv.stringv);
dlist = builddatalist(1);
dlappend(dlist,&con);
}
#ifdef NCF213 /*Jira NCF-213*/
/* We should not create an actual
attribute for any of the
special attributes.
*/
#endif /*NCF213*/
}
static void
processspecials(void)
{
int i;
for(i=0;i<listlength(vardefs);i++) {
Symbol* vsym = (Symbol*)listget(vardefs,i);
processspecial1(vsym);
}
}
static void
processattributes(void)
{

View File

@ -9,6 +9,7 @@
#define MAX_NC_ATTSIZE 20000 /* max size of attribute (for ncgen) */
#define MAXTRST 5000 /* max size of string value (for ncgen) */
#include "config.h"
#include "generic.h"
extern int ncid; /* handle for netCDF */

View File

@ -967,7 +967,7 @@ OCerror
oc_data_fieldbyname(OCobject link, OCobject datanode, const char* name, OCobject* fieldp)
{
OCerror err = OC_NOERR;
size_t count,i;
size_t i=0,count=0;
OCobject ddsnode;
OCVERIFY(OC_State,link);
OCVERIFY(OC_Data,datanode);
@ -1292,7 +1292,10 @@ oc_data_octype(OCobject link, OCobject datanode, OCtype* typep)
OCASSERT(data->template != NULL);
if(typep == NULL) ocerr = OC_EINVAL;
else *typep = data->template->octype;
else if(data->template)
*typep = data->template->octype;
else
ocerr = OC_EINVAL;
return ocerr;
}

View File

@ -439,12 +439,6 @@ extern OCerror oc_data_octype(OClink, OCdatanode data, OCtype*);
*/
extern int oc_data_indexed(OClink link, OCdatanode datanode);
/* Return 1 if the specified data has a valid index, 0 otherwise.
Valid index means it was created using
oc_data_ithelement or oc_data_ithrecord.
*/
extern int oc_data_indexed(OClink, OCdatanode);
/* Return 1 if the specified data can be indexed
Indexable means the data is pointing to
an indexed structure or to a sequence.

View File

@ -387,8 +387,9 @@ createtempfile(OCstate* state, OCtree* tree)
return stat;
fail:
if(name != NULL) free(name);
oclog(OCLOGERR,"oc_open: attempt to create tmp file failed: %s",name);
oclog(OCLOGERR,"oc_open: attempt to create tmp file failed: %s",name == NULL ? "[NULL]" : name);
if(name != NULL) {free(name);name=NULL;}
return stat;
}

View File

@ -210,8 +210,6 @@ extern int ocinternalinitialize(void);
extern OCerror ocupdatelastmodifieddata(OCstate* state);
extern int ocinternalinitialize(void);
extern OCerror ocsetuseragent(OCstate* state, const char* agent);
#endif /*COMMON_H*/

View File

@ -693,8 +693,10 @@ ocmktmp(const char* base, char** tmpnamep, int* fdp)
tmpname = (char*)malloc(tmpsize);
if(tmpname == NULL) return OC_ENOMEM;
if(!occopycat(tmpname,tmpsize,1,base))
return OC_EOVERRUN;
if(!occopycat(tmpname,tmpsize,1,base)) {
free(tmpname);
return OC_EOVERRUN;
}
#ifdef HAVE_MKSTEMP
if(!occoncat(tmpname,tmpsize,1,"XXXXXX"))
return OC_EOVERRUN;