Tweaked empty test to check for limited, unlimited dimensions. Also added a gdb command file for ease of debugging.

This commit is contained in:
Ward Fisher 2016-02-18 13:59:53 -07:00
parent 791800145a
commit e2eda755e3
2 changed files with 120 additions and 6 deletions

15
gdb.txt Normal file
View File

@ -0,0 +1,15 @@
set breakpoint pending on
break nc4hdf.c:872
command
watch provide_fill
c
end
break nc4hdf.c:974
command
print fill_value_size
end
break nc4hdf.c:1126

View File

@ -18,9 +18,10 @@
#include <hdf5.h> #include <hdf5.h>
#include <nc_logging.h> #include <nc_logging.h>
#define FILE_NAME "tst_empty_vlen_unlim.nc" #define FILE_NAME_UNLIM "tst_empty_vlen_unlim.nc"
#define DIM_LEN NC_UNLIMITED #define FILE_NAME_LIM "tst_empty_vlen_lim.nc"
//#define DIM_LEN 5 #define DIM_LEN_UNLIM NC_UNLIMITED
#define DIM_LEN_LIM 5
#define DIM_NAME "x" #define DIM_NAME "x"
#define VLEN_NAME "vltest" #define VLEN_NAME "vltest"
#define VAR_NAME1 "v" #define VAR_NAME1 "v"
@ -32,7 +33,7 @@
int main() { int main() {
printf("Testing access to unset entries in VLEN variable\n"); printf("Testing access to unset entries in VLEN variable, unlimited dimension\n");
{ {
int ncid, typeid, dimid, varid, varid2; int ncid, typeid, dimid, varid, varid2;
nc_vlen_t data[ROW_COUNT]; nc_vlen_t data[ROW_COUNT];
@ -46,11 +47,15 @@ int main() {
int i = 0; int i = 0;
/* Create File */ /* Create File */
printf("\t* Creating File:\tnc_create()\n"); printf("\t* Creating File:\tnc_create()\n");
if (nc_create(FILE_NAME, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR; if (nc_create(FILE_NAME_UNLIM, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
/* Set fill mode */
//printf("\t* Setting fill mode:\tnc_set_fill()\n");
//if(nc_set_fill(ncid,NC_FILL,NULL)) ERR;
/* Create Dimension */ /* Create Dimension */
printf("\t* Defining Unlimited Dimension:\tnc_def_dim()\n"); printf("\t* Defining Unlimited Dimension:\tnc_def_dim()\n");
if (nc_def_dim(ncid, DIM_NAME, DIM_LEN, &dimid)) ERR; if (nc_def_dim(ncid, DIM_NAME, DIM_LEN_UNLIM, &dimid)) ERR;
/* Create ragged array type. */ /* Create ragged array type. */
printf("\t* Creating Ragged Array type:\tnc_def_vlen().\n"); printf("\t* Creating Ragged Array type:\tnc_def_vlen().\n");
@ -119,6 +124,100 @@ int main() {
} }
printf("Testing access to unset entries in VLEN variable, unlimit dimension\n");
{
int ncid, typeid, dimid, varid, varid2;
nc_vlen_t data[ROW_COUNT];
int stat;
float *dat0, *dat1, *dat2;
float *data2;
size_t startp[3] = {0,0,0};
size_t countp[3] = {VLEN0,VLEN1,VLEN2};
size_t startp2[1] = {0};
size_t countp2[1] = {VLEN2};
int i = 0;
/* Create File */
printf("\t* Creating File:\tnc_create()\n");
if (nc_create(FILE_NAME_LIM, NC_NETCDF4 | NC_CLOBBER, &ncid)) ERR;
/* Set fill mode */
//printf("\t* Setting fill mode:\tnc_set_fill()\n");
//if(nc_set_fill(ncid,NC_FILL,NULL)) ERR;
/* Create Dimension */
printf("\t* Defining Unlimited Dimension:\tnc_def_dim()\n");
if (nc_def_dim(ncid, DIM_NAME, DIM_LEN_LIM, &dimid)) ERR;
/* Create ragged array type. */
printf("\t* Creating Ragged Array type:\tnc_def_vlen().\n");
if (nc_def_vlen(ncid, VLEN_NAME, NC_FLOAT, &typeid)) ERR;
/* Create a variable of typeid. */
printf("\t* Creating Variable using Ragged Arrayt Type:\tnc_def_var().\n");
if (nc_def_var(ncid, VAR_NAME1, typeid, 1, &dimid, &varid)) ERR;
/* Create a variable of type float. */
printf("\t* Creating secondary Variable using NC_FLOAT:\tnc_def_var().\n");
if (nc_def_var(ncid, VAR_NAME2, NC_FLOAT, 1, &dimid, &varid2)) ERR;
/* End define mode. */
printf("\t* Ending define mode:\tnc_enddef().\n");
/* Write out data for w */
printf("\t* Creating float data for secondary variable.\n");
data2 = (float*)malloc(sizeof(float) * VLEN2);
for(i = 0; i < VLEN2; i++) {
data2[i] = (float)i;
}
printf("\t* Puting data in secondary variable:\tnc_put_vara().\n");
if (nc_put_vara(ncid,varid2,&startp2,&countp2,data2)) ERR;
/***********/
/* Actually unnecessary to recreate the issue. */
/***********/
/* Write out varying-length data for v[0] and v[1]. Leave v[2] empty. */
dat0 = (float*)malloc(VLEN0 * sizeof(float));
for(i = 0; i < VLEN0; i++) {
dat0[i] = (float)i;
}
dat1 = (float*)malloc(VLEN1 * sizeof(float));
for(i = 0; i < VLEN1; i++) {
dat1[i] = (float)i;
}
dat2 = (float*)malloc(VLEN2 * sizeof(float));
for(i = 0; i < VLEN2; i++) {
dat2[i] = (float)i;
}
data[0].p = dat0;
data[0].len = VLEN0;
data[1].p = dat1;
data[1].len = VLEN1;
data[2].p = dat2;
data[2].len = VLEN2;
//printf("\t* Puting data in VLEN variable:\tnc_put_vara().\n");
//stat = nc_put_vara(ncid,varid,&startp,&countp,data);
//stat = nc_put_var(ncid,varid,&data);
//if(stat) ERR;
/* Close File. */
printf("\t* Closing file:\tnc_close().\n");
if (stat = nc_close(ncid)) ERR;
}
SUMMARIZE_ERR; SUMMARIZE_ERR;
FINAL_RESULTS; FINAL_RESULTS;