mirror of
https://github.com/Unidata/netcdf-c.git
synced 2025-01-30 16:10:44 +08:00
Merge branch 'ejh_ncdump' of https://github.com/NetCDF-World-Domination-Council/netcdf-c into merge_small_pulls
This commit is contained in:
commit
fb38f81243
@ -38,7 +38,7 @@ check(int status)
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int i,stat;
|
||||
int stat;
|
||||
int ncid, grpid;
|
||||
char* filename;
|
||||
char* oldname;
|
||||
|
@ -109,8 +109,8 @@ nc_set_log_level(0);
|
||||
printf("*** testing defining dimensions and coord variables in different orders in root group...");
|
||||
{
|
||||
int ncid, grpid, grp2id;
|
||||
int time_dimid, lev_dimid, vrt_dimid, g2lev_dimid, g2vrt_dimid;
|
||||
int time_dimid_in, lev_dimid_in, vrt_dimid_in, g2lev_dimid_in, g2vrt_dimid_in;
|
||||
int time_dimid, lev_dimid, g2lev_dimid, g2vrt_dimid;
|
||||
int time_dimid_in, lev_dimid_in, g2lev_dimid_in, g2vrt_dimid_in;
|
||||
int time_varid, lev_varid, gvar2_varid, g2lev_varid, g2vrt_varid;
|
||||
int var2_dims[VAR2_RANK];
|
||||
/* Create test for fix of bug that resulted in two dimensions
|
||||
@ -156,8 +156,8 @@ nc_set_log_level(0);
|
||||
printf("*** testing defining dimensions and coord variables in different orders in subgroup...");
|
||||
{
|
||||
int ncid, grpid, grp2id;
|
||||
int time_dimid, lev_dimid, vrt_dimid, g2lev_dimid, g2vrt_dimid;
|
||||
int time_dimid_in, lev_dimid_in, vrt_dimid_in, g2lev_dimid_in, g2vrt_dimid_in;
|
||||
int time_dimid, lev_dimid, g2lev_dimid, g2vrt_dimid;
|
||||
int time_dimid_in, lev_dimid_in, g2lev_dimid_in, g2vrt_dimid_in;
|
||||
int time_varid, lev_varid, gvar2_varid, g2lev_varid, g2vrt_varid;
|
||||
int var2_dims[VAR2_RANK];
|
||||
/* Create test for fix of bug inside a subgroup that results in two dimensions
|
||||
|
@ -34,20 +34,11 @@
|
||||
int main()
|
||||
{
|
||||
int ncid, dimids[RANK_P], time_id, p_id, test_id, status;
|
||||
int ndims, dimids_in[RANK_P];
|
||||
|
||||
int test_data[1] = {1};
|
||||
size_t test_start[1] = {0}, test_count[1] = {1};
|
||||
int test_fill_val[] = {5};
|
||||
|
||||
|
||||
double data[1] = {3.14159};
|
||||
size_t start[1] = {0}, count[1] = {1};
|
||||
float ddata[1][4][3];
|
||||
static float P_data[LEN];
|
||||
size_t cor[RANK_P] = {0, 1, 0};
|
||||
size_t edg[RANK_P] = {1, 1, LEN};
|
||||
float pfills[] = {3};
|
||||
|
||||
printf("\n*** Testing for a netCDF-4 fill-value bug.\n");
|
||||
printf("*** Creating a file with no _FillValue defined. ***\n");
|
||||
|
@ -38,7 +38,7 @@ int main() {
|
||||
int be_dbl_varid;
|
||||
int ed;
|
||||
int failures = 0;
|
||||
int retval = 0;
|
||||
int retval;
|
||||
|
||||
printf("* Checking that endianness is properly read from file.\n");
|
||||
printf("** Generating test files.\n");
|
||||
@ -48,36 +48,51 @@ int main() {
|
||||
{
|
||||
|
||||
printf("*** Creating a file via netcdf API: %s.\n",FILE_NAME_NC);
|
||||
retval = nc_create(FILE_NAME_NC, NC_NETCDF4 | NC_CLOBBER, &ncid);
|
||||
if ((retval = nc_create(FILE_NAME_NC, NC_NETCDF4 | NC_CLOBBER, &ncid)))
|
||||
return retval;
|
||||
|
||||
retval = nc_def_dim(ncid, DIM_NAME, NDIM, &dimid);
|
||||
if ((retval = nc_def_dim(ncid, DIM_NAME, NDIM, &dimid)))
|
||||
return retval;
|
||||
|
||||
/* Little-Endian Float */
|
||||
retval = nc_def_var(ncid, LE_FLOAT_VARNAME, NC_FLOAT, 1, &dimid, &le_float_varid);
|
||||
retval = nc_def_var_endian(ncid, le_float_varid, NC_ENDIAN_LITTLE);
|
||||
if ((retval = nc_def_var(ncid, LE_FLOAT_VARNAME, NC_FLOAT, 1, &dimid, &le_float_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_def_var_endian(ncid, le_float_varid, NC_ENDIAN_LITTLE)))
|
||||
return retval;
|
||||
|
||||
/* Big-Endian Float */
|
||||
retval = nc_def_var(ncid, BE_FLOAT_VARNAME, NC_FLOAT, 1, &dimid, &be_float_varid);
|
||||
retval = nc_def_var_endian(ncid, be_float_varid, NC_ENDIAN_BIG);
|
||||
if ((retval = nc_def_var(ncid, BE_FLOAT_VARNAME, NC_FLOAT, 1, &dimid, &be_float_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_def_var_endian(ncid, be_float_varid, NC_ENDIAN_BIG)))
|
||||
return retval;
|
||||
|
||||
/* Little-Endian Int */
|
||||
retval = nc_def_var(ncid, LE_INT_VARNAME, NC_INT, 1, &dimid, &le_int_varid);
|
||||
retval = nc_def_var_endian(ncid, le_int_varid, NC_ENDIAN_LITTLE);
|
||||
if ((retval = nc_def_var(ncid, LE_INT_VARNAME, NC_INT, 1, &dimid, &le_int_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_def_var_endian(ncid, le_int_varid, NC_ENDIAN_LITTLE)))
|
||||
return retval;
|
||||
|
||||
/* Big-Endian Int */
|
||||
retval = nc_def_var(ncid, BE_INT_VARNAME, NC_INT, 1, &dimid, &be_int_varid);
|
||||
retval = nc_def_var_endian(ncid, be_int_varid, NC_ENDIAN_BIG);
|
||||
if ((retval = nc_def_var(ncid, BE_INT_VARNAME, NC_INT, 1, &dimid, &be_int_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_def_var_endian(ncid, be_int_varid, NC_ENDIAN_BIG)))
|
||||
return retval;
|
||||
|
||||
/* Little-Endian Double */
|
||||
retval = nc_def_var(ncid, LE_DBL_VARNAME, NC_DOUBLE, 1, &dimid, &le_dbl_varid);
|
||||
retval = nc_def_var_endian(ncid, le_dbl_varid, NC_ENDIAN_LITTLE);
|
||||
if ((retval = nc_def_var(ncid, LE_DBL_VARNAME, NC_DOUBLE, 1, &dimid, &le_dbl_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_def_var_endian(ncid, le_dbl_varid, NC_ENDIAN_LITTLE)))
|
||||
return retval;
|
||||
|
||||
/* Big-Endian Double */
|
||||
retval = nc_def_var(ncid, BE_DBL_VARNAME, NC_DOUBLE, 1, &dimid, &be_dbl_varid);
|
||||
retval = nc_def_var_endian(ncid, be_dbl_varid, NC_ENDIAN_BIG);
|
||||
if ((retval = nc_def_var(ncid, BE_DBL_VARNAME, NC_DOUBLE, 1, &dimid, &be_dbl_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_def_var_endian(ncid, be_dbl_varid, NC_ENDIAN_BIG)))
|
||||
return retval;
|
||||
|
||||
|
||||
retval = nc_close(ncid);
|
||||
if ((retval = nc_close(ncid)))
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -95,40 +110,54 @@ int main() {
|
||||
be_dbl_varid = 0;
|
||||
|
||||
printf("*** %s\n",FILE_NAME_NC);
|
||||
retval = nc_open(FILE_NAME_NC, NC_NETCDF4 | NC_NOWRITE, &ncid);
|
||||
if ((retval = nc_open(FILE_NAME_NC, NC_NETCDF4 | NC_NOWRITE, &ncid)))
|
||||
return retval;
|
||||
|
||||
retval = nc_inq_varid(ncid,LE_FLOAT_VARNAME,&le_float_varid);
|
||||
retval = nc_inq_varid(ncid,BE_FLOAT_VARNAME,&be_float_varid);
|
||||
retval = nc_inq_varid(ncid,LE_INT_VARNAME,&le_int_varid);
|
||||
retval = nc_inq_varid(ncid,BE_INT_VARNAME,&be_int_varid);
|
||||
retval = nc_inq_varid(ncid,LE_DBL_VARNAME,&le_dbl_varid);
|
||||
retval = nc_inq_varid(ncid,BE_DBL_VARNAME,&be_dbl_varid);
|
||||
if ((retval = nc_inq_varid(ncid,LE_FLOAT_VARNAME,&le_float_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_inq_varid(ncid,BE_FLOAT_VARNAME,&be_float_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_inq_varid(ncid,LE_INT_VARNAME,&le_int_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_inq_varid(ncid,BE_INT_VARNAME,&be_int_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_inq_varid(ncid,LE_DBL_VARNAME,&le_dbl_varid)))
|
||||
return retval;
|
||||
if ((retval = nc_inq_varid(ncid,BE_DBL_VARNAME,&be_dbl_varid)))
|
||||
return retval;
|
||||
|
||||
printf("\tLittle-Endian Float...\t");
|
||||
retval = nc_inq_var_endian(ncid,le_float_varid,&ed);
|
||||
if ((retval = nc_inq_var_endian(ncid,le_float_varid,&ed)))
|
||||
return retval;
|
||||
if(ed == NC_ENDIAN_LITTLE) printf("passed\n"); else {printf("failed\n"); failures++;}
|
||||
|
||||
printf("\tBig-Endian Float...\t");
|
||||
retval = nc_inq_var_endian(ncid,be_float_varid,&ed);
|
||||
if ((retval = nc_inq_var_endian(ncid,be_float_varid,&ed)))
|
||||
return retval;
|
||||
if(ed == NC_ENDIAN_BIG) printf("passed\n"); else {printf("failed\n"); failures++;}
|
||||
|
||||
printf("\tLittle-Endian Int...\t");
|
||||
retval = nc_inq_var_endian(ncid,le_int_varid,&ed);
|
||||
if ((retval = nc_inq_var_endian(ncid,le_int_varid,&ed)))
|
||||
return retval;
|
||||
if(ed == NC_ENDIAN_LITTLE) printf("passed\n"); else {printf("failed\n"); failures++;}
|
||||
|
||||
printf("\tBig-Endian Int...\t");
|
||||
retval = nc_inq_var_endian(ncid,be_int_varid,&ed);
|
||||
if ((retval = nc_inq_var_endian(ncid,be_int_varid,&ed)))
|
||||
return retval;
|
||||
if(ed == NC_ENDIAN_BIG) printf("passed\n"); else {printf("failed\n"); failures++;}
|
||||
|
||||
printf("\tLittle-Endian Double...\t");
|
||||
retval = nc_inq_var_endian(ncid,le_dbl_varid,&ed);
|
||||
if ((retval = nc_inq_var_endian(ncid,le_dbl_varid,&ed)))
|
||||
return retval;
|
||||
if(ed == NC_ENDIAN_LITTLE) printf("passed\n"); else {printf("failed\n"); failures++;}
|
||||
|
||||
printf("\tBig-Endian Double...\t");
|
||||
retval = nc_inq_var_endian(ncid,be_dbl_varid,&ed);
|
||||
if ((retval = nc_inq_var_endian(ncid,be_dbl_varid,&ed)))
|
||||
return retval;
|
||||
if(ed == NC_ENDIAN_BIG) printf("passed\n"); else {printf("failed\n"); failures++;}
|
||||
|
||||
retval = nc_close(ncid);
|
||||
if ((retval = nc_close(ncid)))
|
||||
return retval;
|
||||
}
|
||||
|
||||
printf("** Failures Returned: [%d]\n",failures);
|
||||
|
@ -185,7 +185,6 @@ main()
|
||||
hid_t dcplid;
|
||||
hid_t scalar_spaceid;
|
||||
hid_t vlstr_typeid, fixstr_typeid;
|
||||
hid_t attid;
|
||||
|
||||
/* Create scalar dataspace */
|
||||
if ((scalar_spaceid = H5Screate(H5S_SCALAR)) < 0) ERR;
|
||||
@ -265,7 +264,6 @@ main()
|
||||
printf("*** Checking accessing file through netCDF-4 API...");
|
||||
{
|
||||
int ncid, varid;
|
||||
size_t len;
|
||||
nc_type type;
|
||||
int ndims;
|
||||
char *vlstr;
|
||||
|
@ -32,14 +32,12 @@ main()
|
||||
char fsdata[] = "fixed-length string";
|
||||
char *v1ddata[DIM1] = {"strings","of","variable","length"};
|
||||
int i;
|
||||
char ch;
|
||||
|
||||
printf("\n*** Creating file for checking fix to bugs in accessing strings from HDF5 non-netcdf-4 file.\n");
|
||||
{
|
||||
hid_t fileid, scalar_spaceid, vstypeid, fstypeid, vsattid, fsattid, vsdsetid, fsdsetid;
|
||||
hid_t class;
|
||||
size_t type_size = FSTR_LEN;
|
||||
hid_t v1dattid, v1ddsetid;
|
||||
hid_t v1ddsetid;
|
||||
hid_t v1dspaceid;
|
||||
hsize_t dims[1] = {DIM1};
|
||||
|
||||
@ -128,7 +126,7 @@ main()
|
||||
|
||||
printf("*** Checking reading variable-length HDF5 string att through netCDF-4 API...");
|
||||
{
|
||||
int ncid, varid, ndims;
|
||||
int ncid;
|
||||
nc_type type;
|
||||
size_t len;
|
||||
char *data_in;
|
||||
@ -145,7 +143,7 @@ main()
|
||||
|
||||
printf("*** Checking reading fixed-length HDF5 string att through netCDF-4 API...");
|
||||
{
|
||||
int ncid, varid, ndims;
|
||||
int ncid;
|
||||
nc_type type;
|
||||
size_t len;
|
||||
char *data_in;
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int res = 0;
|
||||
int ncid = 0;
|
||||
|
||||
printf("\n*** Testing libhdf5 file compatibility (open files generated by hdf5 1.10).\n");
|
||||
|
@ -16,16 +16,19 @@ int main()
|
||||
{
|
||||
int status;
|
||||
int id;
|
||||
int rh_id, varid, v1, v2, v3, v4;
|
||||
int v1, v2, v3, v4;
|
||||
int dimids[2];
|
||||
|
||||
|
||||
nc_create(FILENAME, NC_CLOBBER, &id);
|
||||
nc_redef(id);
|
||||
|
||||
status = nc_def_dim(id, "dim1", 10, &dimids[0]);
|
||||
status = nc_def_var(id, "dim1", NC_FLOAT, 1, dimids, &v1);
|
||||
status = nc_def_var(id, "var1", NC_FLOAT, 1, dimids, &v2);
|
||||
if ((status = nc_def_dim(id, "dim1", 10, &dimids[0])))
|
||||
return status;
|
||||
if ((status = nc_def_var(id, "dim1", NC_FLOAT, 1, dimids, &v1)))
|
||||
return status;
|
||||
if ((status = nc_def_var(id, "var1", NC_FLOAT, 1, dimids, &v2)))
|
||||
return status;
|
||||
|
||||
nc_close(id);
|
||||
|
||||
@ -35,7 +38,8 @@ int main()
|
||||
nc_rename_var(id, v1,"dim_new1");
|
||||
nc_rename_dim(id, dimids[0], "dim_new1");
|
||||
|
||||
status = nc_def_dim(id, "dim2", 20, &dimids[1]);
|
||||
if ((status = nc_def_dim(id, "dim2", 20, &dimids[1])))
|
||||
return status;
|
||||
nc_def_var(id, "dim2", NC_FLOAT, 1, &dimids[1], &v3);
|
||||
nc_def_var(id, "var2", NC_FLOAT, 2, dimids, &v4);
|
||||
|
||||
|
@ -173,7 +173,7 @@ main(int argc, char **argv)
|
||||
#define RANK_g1_lon 1
|
||||
|
||||
/* IDs of file, groups, dimensions, variables, attributes */
|
||||
int ncid, g1_grp, lon_dim, lon_var, g1_lon_var, units_att;
|
||||
int ncid, g1_grp, lon_dim, lon_var, g1_lon_var;
|
||||
size_t lon_len = 4;
|
||||
char *data_in;
|
||||
|
||||
@ -222,8 +222,6 @@ main(int argc, char **argv)
|
||||
/* reopen the file again and see if renamed attribute exists and
|
||||
has expected value */
|
||||
{
|
||||
nc_type att_type;
|
||||
size_t att_len;
|
||||
|
||||
if (nc_open(file_names[format], NC_NOWRITE, &ncid)) ERR;
|
||||
if (nc_inq_grp_ncid(ncid, GRP_NAME, &g1_grp)) ERR;
|
||||
|
@ -330,7 +330,7 @@ main(int argc, char **argv)
|
||||
int dimid[NDIMS_1], var_dimids[VAR_DIMS] = {2, 0, 1};
|
||||
float fill_value = -9999.0f;
|
||||
char long_name[] = PRES_MAX_WIND;
|
||||
int i, attid[NUM_ATTS];
|
||||
int i;
|
||||
|
||||
ncid = nccreate(FILE_NAME, NC_NETCDF4);
|
||||
|
||||
@ -364,8 +364,7 @@ main(int argc, char **argv)
|
||||
/* Now add a fill value. This will acutually cause HDF5 to
|
||||
* destroy the dataset and recreate it, recreating also the
|
||||
* three attributes that are attached to it. */
|
||||
attid[3] = ncattput(ncid, varid, _FillValue, NC_FLOAT,
|
||||
1, &fill_value);
|
||||
ncattput(ncid, varid, _FillValue, NC_FLOAT, 1, &fill_value);
|
||||
|
||||
/* Check to ensure the atts have their expected attnums. */
|
||||
if (nc_inq_attid(ncid, 0, LONG_NAME, &attnum_in)) ERR;
|
||||
|
Loading…
Reference in New Issue
Block a user