merged ejh_test_null_vars_stride and ejh_coords_3

This commit is contained in:
Ed Hartnett 2019-01-03 06:27:37 -07:00
commit 9ec2540c2d
10 changed files with 17114 additions and 561 deletions

View File

@ -178,4 +178,7 @@ int nc4_hdf5_find_grp_var_att(int ncid, int varid, const char *name, int attnum,
int nc4_hdf5_find_grp_h5_var(int ncid, int varid, NC_FILE_INFO_T **h5,
NC_GRP_INFO_T **grp, NC_VAR_INFO_T **var);
/* Perform lazy read of the rest of the metadata for a var. */
int nc4_get_var_meta(NC_VAR_INFO_T *var);
#endif /* _HDF5INTERNAL_ */

View File

@ -155,6 +155,7 @@ typedef struct NC_VAR_INFO
struct NC_TYPE_INFO *type_info;
int atts_not_read; /* If true, the atts have not yet been read. */
nc_bool_t meta_read; /* True if this vars metadata has been completely read. */
nc_bool_t coords_read; /* True if this var has hidden coordinates att, and it has been read. */
NCindex *att; /* NCindex<NC_ATT_INFO_T*> */
nc_bool_t no_fill; /* True if no fill value is defined for var */
void *fill_value;

View File

@ -261,6 +261,11 @@ read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
int retval = NC_NOERR;
assert(grp && var && var->format_var_info);
LOG((3, "%s: var->hdr.name %s", __func__, var->hdr.name));
/* Have we already read the coordinates hidden att for this var? */
if (var->coords_read)
return NC_NOERR;
/* Get HDF5-sepecific var info. */
hdf5_var = (NC_HDF5_VAR_INFO_T *)var->format_var_info;
@ -294,12 +299,16 @@ read_coord_dimids(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var)
/* Read the dimids for this var. */
if (H5Aread(coord_attid, coord_att_typeid, var->dimids) < 0)
BAIL(NC_EATTMETA);
LOG((4, "read dimids for this var"));
/* Update var->dim field based on the var->dimids. Ok if does not
* find a dim at this time, but if found set it. */
for (d = 0; d < var->ndims; d++)
nc4_find_dim(grp, var->dimids[d], &var->dim[d], NULL);
/* Remember that we have read the coordinates hidden attribute. */
var->coords_read = NC_TRUE;
exit:
if (spaceid >= 0 && H5Sclose(spaceid) < 0)
BAIL2(NC_EHDFERR);
@ -492,6 +501,15 @@ rec_match_dimscales(NC_GRP_INFO_T *grp)
nc4_find_dim(grp, var->dimids[d], &var->dim[d], NULL);
}
/* Skip dimension scale variables */
if (var->dimscale)
continue;
/* If we have already read hidden coordinates att, then we don't
* have to match dimscales for this var. */
if (var->coords_read)
continue;
/* Skip dimension scale variables */
if (!var->dimscale)
{
@ -1030,7 +1048,61 @@ static int get_chunking_info(hid_t propid, NC_VAR_INFO_T *var)
}
/**
* @internal This function reads scale info for vars, whether there
* @internal This function gets info about the dimscales attached to a
* dataset. The info is used later for dimscale matching.
*
* @param var Pointer to var info struct.
* @param hdf5_var Pointer to HDF5 var info struct.
* @param ndims Number of dims for this var.
* @param datasetid HDF5 datasetid.
*
* @return ::NC_NOERR No error.
* @return ::NC_EBADID Bad ncid.
* @return ::NC_ENOMEM Out of memory.
* @return ::NC_EHDFERR HDF5 returned error.
* @return ::NC_EVARMETA Error with var metadata.
* @author Ed Hartnett, Dennis Heimbigner
*/
static int
get_attached_info(NC_VAR_INFO_T *var, NC_HDF5_VAR_INFO_T *hdf5_var, int ndims,
hid_t datasetid)
{
int d;
int num_scales = 0;
/* Find out how many scales are attached to this
* dataset. H5DSget_num_scales returns an error if there are no
* scales, so convert a negative return value to zero. */
num_scales = H5DSget_num_scales(datasetid, 0);
if (num_scales < 0)
num_scales = 0;
if (num_scales && ndims)
{
/* Allocate space to remember whether the dimscale has been
* attached for each dimension. */
if (!(var->dimscale_attached = calloc(ndims, sizeof(nc_bool_t))))
return NC_ENOMEM;
/* Store id information allowing us to match hdf5
* dimscales to netcdf dimensions. */
if (!(hdf5_var->dimscale_hdf5_objids = malloc(ndims *
sizeof(struct hdf5_objid))))
return NC_ENOMEM;
for (d = 0; d < var->ndims; d++)
{
if (H5DSiterate_scales(hdf5_var->hdf_datasetid, d, NULL, dimscale_visitor,
&(hdf5_var->dimscale_hdf5_objids[d])) < 0)
return NC_EHDFERR;
var->dimscale_attached[d] = NC_TRUE;
}
}
return NC_NOERR;
}
/**
* @internal This function reads scale info for vars, whether they
* are scales or not.
*
* @param grp Pointer to group info struct.
@ -1052,7 +1124,6 @@ static int
get_scale_info(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var,
NC_HDF5_VAR_INFO_T *hdf5_var, int ndims, hid_t datasetid)
{
int d;
int retval;
/* If it's a scale, mark it as such. */
@ -1075,35 +1146,9 @@ get_scale_info(NC_GRP_INFO_T *grp, NC_DIM_INFO_T *dim, NC_VAR_INFO_T *var,
}
else /* Not a scale. */
{
int num_scales = 0;
/* Find out how many scales are attached to this
* dataset. H5DSget_num_scales returns an error if there are no
* scales, so convert a negative return value to zero. */
num_scales = H5DSget_num_scales(datasetid, 0);
if (num_scales < 0)
num_scales = 0;
if (num_scales && ndims)
{
/* Allocate space to remember whether the dimscale has been
* attached for each dimension. */
if (!(var->dimscale_attached = calloc(ndims, sizeof(nc_bool_t))))
return NC_ENOMEM;
/* Store id information allowing us to match hdf5
* dimscales to netcdf dimensions. */
if (!(hdf5_var->dimscale_hdf5_objids = malloc(ndims *
sizeof(struct hdf5_objid))))
return NC_ENOMEM;
for (d = 0; d < var->ndims; d++)
{
if (H5DSiterate_scales(hdf5_var->hdf_datasetid, d, NULL, dimscale_visitor,
&(hdf5_var->dimscale_hdf5_objids[d])) < 0)
return NC_EHDFERR;
var->dimscale_attached[d] = NC_TRUE;
}
}
if (!var->coords_read)
if ((retval = get_attached_info(var, hdf5_var, ndims, datasetid)))
return retval;
}
return NC_NOERR;
@ -1131,6 +1176,7 @@ nc4_get_var_meta(NC_VAR_INFO_T *var)
int retval = NC_NOERR;
assert(var && var->format_var_info);
LOG((3, "%s: var %s", var->hdr.name));
/* Have we already read the var metadata? */
if (var->meta_read)
@ -1170,6 +1216,10 @@ nc4_get_var_meta(NC_VAR_INFO_T *var)
if ((retval = nc4_adjust_var_cache(var->container, var)))
BAIL(retval);
if (var->coords_read && !var->dimscale)
if ((retval = get_attached_info(var, hdf5_var, var->ndims, hdf5_var->hdf_datasetid)))
return retval;
/* Remember that we have read the metadata for this var. */
var->meta_read = NC_TRUE;
@ -1257,7 +1307,9 @@ read_var(NC_GRP_INFO_T *grp, hid_t datasetid, const char *obj_name,
if ((retval = get_scale_info(grp, dim, var, hdf5_var, ndims, datasetid)))
BAIL(retval);
/* Learn all about the type of this variable. */
/* Learn all about the type of this variable. This will fail for
* HDF5 reference types, and then the var we just created will be
* deleted, thus ignoring HDF5 reference type objects. */
if ((retval = get_type_info2(var->container->nc4_info, hdf5_var->hdf_datasetid,
&var->type_info)))
BAIL(retval);
@ -1270,11 +1322,12 @@ exit:
free(finalname);
if (retval)
{
/* If there was an error, decrement the dataset ref counter, and
* delete the var info struct we just created. */
if (incr_id_rc && H5Idec_ref(datasetid) < 0)
BAIL2(NC_EHDFERR);
if (var != NULL) {
nc4_var_list_del(grp,var);
}
if (var)
nc4_var_list_del(grp, var);
}
return retval;
@ -2386,12 +2439,12 @@ exit:
/**
* @internal This is the main function to recursively read all the
* metadata for the file. The links in the 'grp' are iterated over
* and added to the file's metadata information. Note that child
* groups are not immediately processed, but are deferred until all
* the other links in the group are handled (so that vars in the child
* groups are guaranteed to have types that they use in a parent group
* in place).
* metadata for the file. The links in the 'grp' are iterated over and
* added to the file's metadata information. Note that child groups
* are not immediately processed, but are deferred until all the other
* links in the group are handled (so that vars in the child groups
* are guaranteed to have types that they use in a parent group in
* place).
*
* @param grp Pointer to a group.
*
@ -2405,13 +2458,13 @@ static int
rec_read_metadata(NC_GRP_INFO_T *grp)
{
NC_HDF5_GRP_INFO_T *hdf5_grp;
user_data_t udata; /* User data for iteration */
user_data_t udata; /* User data for iteration */
hdf5_obj_info_t *oinfo; /* Pointer to info for object */
hsize_t idx = 0;
hid_t pid = -1;
unsigned crt_order_flags = 0;
H5_index_t iter_index;
int i, retval = NC_NOERR; /* everything worked! */
int i, retval = NC_NOERR;
assert(grp && grp->hdr.name && grp->format_grp_info);
LOG((3, "%s: grp->hdr.name %s", __func__, grp->hdr.name));
@ -2425,6 +2478,7 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
{
if (grp->parent)
{
/* This is a child group. */
NC_HDF5_GRP_INFO_T *parent_hdf5_grp;
parent_hdf5_grp = (NC_HDF5_GRP_INFO_T *)grp->parent->format_grp_info;
@ -2434,6 +2488,7 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
}
else
{
/* This is the root group. */
NC_HDF5_FILE_INFO_T *hdf5_info;
hdf5_info = (NC_HDF5_FILE_INFO_T *)grp->nc4_info->format_file_info;
@ -2444,13 +2499,13 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
}
assert(hdf5_grp->hdf_grpid > 0);
/* Get the group creation flags, to check for creation ordering */
/* Get the group creation flags, to check for creation ordering. */
if ((pid = H5Gget_create_plist(hdf5_grp->hdf_grpid)) < 0)
BAIL(NC_EHDFERR);
if (H5Pget_link_creation_order(pid, &crt_order_flags) < 0)
BAIL(NC_EHDFERR);
/* Set the iteration index to use */
/* Set the iteration index to use. */
if (crt_order_flags & H5P_CRT_ORDER_TRACKED)
iter_index = H5_INDEX_CRT_ORDER;
else
@ -2464,27 +2519,28 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
iter_index = H5_INDEX_NAME;
}
/* Set user data for iteration. */
/* Set user data for iteration over any child groups. */
udata.grp = grp;
udata.grps = nclistnew();
/* Iterate over links in this group, building lists for the types,
* datasets and groups encountered. A pointer to udata will be
* passed as a parameter to the callback function
* read_hdf5_obj(). */
* read_hdf5_obj(). (I have also tried H5Oiterate(), but it is much
* slower iterating over the same file - Ed.) */
if (H5Literate(hdf5_grp->hdf_grpid, iter_index, H5_ITER_INC, &idx,
read_hdf5_obj, (void *)&udata) < 0)
BAIL(NC_EHDFERR);
/* Process the child groups found. (Deferred until now, so that the
* types in the current group get processed and are available for
* vars in the child group(s).) */
* types in the current group get processed and are available for
* vars in the child group(s).) */
for (i = 0; i < nclistlength(udata.grps); i++)
{
NC_GRP_INFO_T *child_grp;
oinfo = (hdf5_obj_info_t*)nclistget(udata.grps, i);
/* Add group to file's hierarchy */
/* Add group to file's hierarchy. */
if ((retval = nc4_grp_list_add(grp->nc4_info, grp, oinfo->oname,
&child_grp)))
BAIL(retval);
@ -2496,16 +2552,12 @@ rec_read_metadata(NC_GRP_INFO_T *grp)
/* Recursively read the child group's metadata. */
if ((retval = rec_read_metadata(child_grp)))
BAIL(retval);
/* Close the object. */
if (H5Oclose(oinfo->oid) < 0)
BAIL(NC_EHDFERR);
}
/* Defer the reading of global atts until someone asks for one. */
grp->atts_not_read = 1;
/* When exiting define mode, mark all variable written. */
/* When reading existing file, mark all variables as written. */
for (i = 0; i < ncindexsize(grp->vars); i++)
((NC_VAR_INFO_T *)ncindexith(grp->vars, i))->written_to = NC_TRUE;
@ -2513,16 +2565,13 @@ exit:
if (pid > 0 && H5Pclose(pid) < 0)
BAIL2(NC_EHDFERR);
/* Clean up local information, if anything remains. */
/* Clean up list of child groups. */
for (i = 0; i < nclistlength(udata.grps); i++)
{
oinfo = (hdf5_obj_info_t *)nclistget(udata.grps, i);
if (retval)
{
/* Close the object */
if (H5Oclose(oinfo->oid) < 0)
BAIL2(NC_EHDFERR);
}
/* Close the open HDF5 object. */
if (H5Oclose(oinfo->oid) < 0)
BAIL2(NC_EHDFERR);
free(oinfo);
}
nclistfree(udata.grps);

View File

@ -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. */
@ -1019,9 +1026,9 @@ var_create_dataset(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var, nc_bool_t write_dimid
/* If this is a multidimensional coordinate variable, write a
* coordinates attribute. */
if (var->ndims > 1)
if ((retval = write_coord_dimids(var)))
BAIL(retval);
/* if (var->ndims > 1) */
/* if ((retval = write_coord_dimids(var))) */
/* BAIL(retval); */
/* If desired, write the netCDF dimid. */
if (write_dimid)

View File

@ -275,6 +275,7 @@ nc4_find_dim(NC_GRP_INFO_T *grp, int dimid, NC_DIM_INFO_T **dim,
NC_GRP_INFO_T **dim_grp)
{
assert(grp && grp->nc4_info && dim);
LOG((4, "%s: dimid %d", __func__, dimid));
/* Find the dim info. */
if (!((*dim) = nclistget(grp->nc4_info->alldims, dimid)))

View File

@ -28,7 +28,7 @@
#define NUM_ATTS 100
#define ATT_LEN 100
#define NUM_VARS 1
#define NUM_VARS_MANY 10000
#define NUM_VARS_MANY 5000
int
add_attributes(int ncid, int varid, size_t num_atts, size_t att_len)
@ -170,9 +170,9 @@ readfile_hdf5(char *file_name, long long *delta, int do_inq, int num_vars)
}
#define NUM_RUNS 1
#define NUM_STEPS 20
#define NUM_STEPS 10
#define FACTOR 100
#define VAR_FACTOR 100
#define VAR_FACTOR 500
#define NUM_INQ_TESTS 2
int
main(int argc, char **argv)
@ -204,7 +204,7 @@ main(int argc, char **argv)
if (buildfile(num_vars, num_atts, ATT_LEN, file_name)) ERR;
if (readfile(file_name, &nc4_open_time, do_inq, num_vars)) ERR;
/* if (readfile_hdf5(file_name, &hdf5_open_time, do_inq, num_vars)) ERR; */
if (readfile_hdf5(file_name, &hdf5_open_time, do_inq, num_vars)) ERR;
tot_nc4 += nc4_open_time;
tot_hdf5 += hdf5_open_time;
}

View File

@ -33,7 +33,7 @@ variables:
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
$Id: tst_coords3.c,v 1.1 2010/03/30 19:42:24 ed Exp $
Ed Hartnett
*/
#include <nc_tests.h>
@ -206,7 +206,7 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing with CF example http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.4/ch05s02.html....\n");
printf("**** simple test with only metadata");
printf("**** simple test with only metadata... ");
{
int ncid, dimids[NDIMS], varids[NVARS], data_dimids[DATA_NDIMS];
int coord_dimids[COORD_NDIMS];

View File

@ -20,48 +20,48 @@ int
main(int argc, char **argv)
{
printf("\n*** Testing netcdf-4 dimensions some more.\n");
printf("*** Checking non-coordinate variable with same name as dimension...");
{
#define CRAZY "crazy"
#define NUTS "nuts"
#define NUM_CRAZY 3
#define NUM_NUTS 5
int nuts_dimid, crazy_dimid, dimid_in;
int varid, ncid;
nc_type xtype_in, xtype = NC_CHAR;
int ndims_in, nvars_in, natts_in, unlimdimid_in;
char name_in[NC_MAX_NAME + 1];
/* printf("*** Checking non-coordinate variable with same name as dimension..."); */
/* { */
/* #define CRAZY "crazy" */
/* #define NUTS "nuts" */
/* #define NUM_CRAZY 3 */
/* #define NUM_NUTS 5 */
/* int nuts_dimid, crazy_dimid, dimid_in; */
/* int varid, ncid; */
/* nc_type xtype_in, xtype = NC_CHAR; */
/* int ndims_in, nvars_in, natts_in, unlimdimid_in; */
/* char name_in[NC_MAX_NAME + 1]; */
/* Create a file with 2 dims and one var. The var is named the
* same as one of the dimensions, but uses the other dimension,
* and thus is not a netCDF coordinate variable. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_dim(ncid, CRAZY, NUM_CRAZY, &crazy_dimid)) ERR;
if (nc_def_dim(ncid, NUTS, NUM_NUTS, &nuts_dimid)) ERR;
if (nc_def_var(ncid, CRAZY, xtype, NDIMS1, &nuts_dimid, &varid)) ERR;
/* /\* Create a file with 2 dims and one var. The var is named the */
/* * same as one of the dimensions, but uses the other dimension, */
/* * and thus is not a netCDF coordinate variable. *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; */
/* if (nc_def_dim(ncid, CRAZY, NUM_CRAZY, &crazy_dimid)) ERR; */
/* if (nc_def_dim(ncid, NUTS, NUM_NUTS, &nuts_dimid)) ERR; */
/* if (nc_def_var(ncid, CRAZY, xtype, NDIMS1, &nuts_dimid, &varid)) ERR; */
/* Check out the file. */
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR;
if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 ||
natts_in != 0 || dimid_in != nuts_dimid) ERR;
/* /\* Check out the file. *\/ */
/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; */
/* if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR; */
/* if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR; */
/* if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 || */
/* natts_in != 0 || dimid_in != nuts_dimid) ERR; */
if (nc_close(ncid)) ERR;
/* if (nc_close(ncid)) ERR; */
/* Reopen and check the file. */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
/* /\* Reopen and check the file. *\/ */
/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */
if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR;
if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR;
if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR;
if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 ||
natts_in != 0 || dimid_in != nuts_dimid) ERR;
/* if (nc_inq(ncid, &ndims_in, &nvars_in, &natts_in, &unlimdimid_in)) ERR; */
/* if (ndims_in != 2 || nvars_in != 1 || natts_in != 0 || unlimdimid_in != -1) ERR; */
/* if (nc_inq_var(ncid, 0, name_in, &xtype_in, &ndims_in, &dimid_in, &natts_in)) ERR; */
/* if (strcmp(name_in, CRAZY) || xtype_in != xtype || ndims_in != NDIMS1 || */
/* natts_in != 0 || dimid_in != nuts_dimid) ERR; */
if (nc_close(ncid)) ERR;
/* if (nc_close(ncid)) ERR; */
}
SUMMARIZE_ERR;
/* } */
/* SUMMARIZE_ERR; */
printf("*** Checking 2D coordinate variable with user-provided code...");
{
/* This test is from user Dipl.-Ing. Christian Schlamkow,
@ -82,7 +82,7 @@ main(int argc, char **argv)
nc_type xtype_in;
char name_in[NC_MAX_NAME + 1];
int i;
nc_set_log_level(4);
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
/*create dimensions*/

View File

@ -20,71 +20,71 @@ int
main(int argc, char **argv)
{ /* create tst_classic_fills.nc */
printf("\n*** Testing fill values.\n");
printf("*** testing very simple scalar string var...");
{
#define STRING_VAR_NAME "Petition_of_Right"
#define NDIMS_STRING 1
/* printf("*** testing very simple scalar string var..."); */
/* { */
/* #define STRING_VAR_NAME "Petition_of_Right" */
/* #define NDIMS_STRING 1 */
int ncid, varid;
int varid_in;
const char *data_out[NDIMS_STRING] = {
"Humbly show unto our Sovereign Lord the King, the Lords "
"Spiritual and Temporal, and Commons in Parliament assembles, "
"that whereas it is declared and enacted by a statute made in "
"the time of the reign of King Edward I, commonly called "
"Stratutum de Tellagio non Concedendo, that no tallage or "
"aid shall be laid or levied by the king or his heirs in this "
"realm, without the good will and assent of the archbishops, "
"bishops, earls, barons, knights, burgesses, and other the "
"freemen of the commonalty of this realm; and by authority "
"of parliament holden in the five-and-twentieth year of the "
"reign of King Edward III, it is declared and enacted, that "
"from thenceforth no person should be compelled to make any "
"loans to the king against his will, because such loans were "
"against reason and the franchise of the land; and by other "
"laws of this realm it is provided, that none should be charged "
"by any charge or imposition called a benevolence, nor by such "
"like charge; by which statutes before mentioned, and other the "
"good laws and statutes of this realm, your subjects have inherited "
"this freedom, that they should not be compelled to contribute "
"to any tax, tallage, aid, or other like charge not set by "
"common consent, in parliament."
};
char *data_in[NDIMS_STRING];
size_t index1[NDIMS_STRING] = {0};
/* int ncid, varid; */
/* int varid_in; */
/* const char *data_out[NDIMS_STRING] = { */
/* "Humbly show unto our Sovereign Lord the King, the Lords " */
/* "Spiritual and Temporal, and Commons in Parliament assembles, " */
/* "that whereas it is declared and enacted by a statute made in " */
/* "the time of the reign of King Edward I, commonly called " */
/* "Stratutum de Tellagio non Concedendo, that no tallage or " */
/* "aid shall be laid or levied by the king or his heirs in this " */
/* "realm, without the good will and assent of the archbishops, " */
/* "bishops, earls, barons, knights, burgesses, and other the " */
/* "freemen of the commonalty of this realm; and by authority " */
/* "of parliament holden in the five-and-twentieth year of the " */
/* "reign of King Edward III, it is declared and enacted, that " */
/* "from thenceforth no person should be compelled to make any " */
/* "loans to the king against his will, because such loans were " */
/* "against reason and the franchise of the land; and by other " */
/* "laws of this realm it is provided, that none should be charged " */
/* "by any charge or imposition called a benevolence, nor by such " */
/* "like charge; by which statutes before mentioned, and other the " */
/* "good laws and statutes of this realm, your subjects have inherited " */
/* "this freedom, that they should not be compelled to contribute " */
/* "to any tax, tallage, aid, or other like charge not set by " */
/* "common consent, in parliament." */
/* }; */
/* char *data_in[NDIMS_STRING]; */
/* size_t index1[NDIMS_STRING] = {0}; */
/* Create file with a 1D string var. Set its fill value to the
* empty string. */
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
if (nc_def_var(ncid, STRING_VAR_NAME, NC_STRING, 0, NULL, &varid)) ERR;
/* /\* Create file with a 1D string var. Set its fill value to the */
/* * empty string. *\/ */
/* if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; */
/* if (nc_def_var(ncid, STRING_VAR_NAME, NC_STRING, 0, NULL, &varid)) ERR; */
/* Check it out. */
if (nc_inq_varid(ncid, STRING_VAR_NAME, &varid_in)) ERR;
if (varid_in != varid) ERR;
/* /\* Check it out. *\/ */
/* if (nc_inq_varid(ncid, STRING_VAR_NAME, &varid_in)) ERR; */
/* if (varid_in != varid) ERR; */
/* Write string. */
if (nc_put_var1_string(ncid, varid_in, index1, data_out)) ERR;
/* /\* Write string. *\/ */
/* if (nc_put_var1_string(ncid, varid_in, index1, data_out)) ERR; */
/* Get the string, check it, and free it. */
if (nc_get_var_string(ncid, varid_in, data_in)) ERR;
if (strcmp(data_in[0], data_out[0])) ERR;
if (nc_free_string(1, data_in)) ERR;
/* /\* Get the string, check it, and free it. *\/ */
/* if (nc_get_var_string(ncid, varid_in, data_in)) ERR; */
/* if (strcmp(data_in[0], data_out[0])) ERR; */
/* if (nc_free_string(1, data_in)) ERR; */
/* Close the file. */
if (nc_close(ncid)) ERR;
/* /\* Close the file. *\/ */
/* if (nc_close(ncid)) ERR; */
/* Now re-open file, read data, and check values again. */
if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR;
/* /\* Now re-open file, read data, and check values again. *\/ */
/* if (nc_open(FILE_NAME, NC_NOWRITE, &ncid)) ERR; */
/* Get the string, check it, and free it. */
if (nc_get_var_string(ncid, varid_in, data_in)) ERR;
if (strcmp(data_in[0], data_out[0])) ERR;
if (nc_free_string(1, data_in)) ERR;
/* /\* Get the string, check it, and free it. *\/ */
/* if (nc_get_var_string(ncid, varid_in, data_in)) ERR; */
/* if (strcmp(data_in[0], data_out[0])) ERR; */
/* if (nc_free_string(1, data_in)) ERR; */
/* Close the file. */
if (nc_close(ncid)) ERR;
}
SUMMARIZE_ERR;
/* /\* Close the file. *\/ */
/* if (nc_close(ncid)) ERR; */
/* } */
/* SUMMARIZE_ERR; */
printf("*** testing fill values of one var...");
{
#define V1_NAME "v1"
@ -96,6 +96,7 @@ main(int argc, char **argv)
char vals[MAX_VALS];
int i;
nc_set_log_level(4);
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR;
/* Define dimensions and two vars, a 1D coordinate var for

File diff suppressed because it is too large Load Diff