From ba9402750f189f19a3e546a63974825ce9590074 Mon Sep 17 00:00:00 2001 From: Wei-keng Liao Date: Sat, 23 Dec 2017 13:39:54 -0600 Subject: [PATCH] test all available file formats in tst_def_var_fill.c --- nc_test/tst_def_var_fill.c | 141 ++++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 63 deletions(-) diff --git a/nc_test/tst_def_var_fill.c b/nc_test/tst_def_var_fill.c index d88d10ced..bab7775ee 100644 --- a/nc_test/tst_def_var_fill.c +++ b/nc_test/tst_def_var_fill.c @@ -34,8 +34,10 @@ int main(int argc, char** argv) { char filename[256]; - int i, j, err, nerrs=0, ncid, varid[2], dimid[2], *buf; + int i, j, k, err, nerrs=0, ncid, varid[2], dimid[2], *buf; size_t start[2], count[2]; + int formats[5]={NC_FORMAT_CLASSIC, NC_FORMAT_64BIT_OFFSET, NC_FORMAT_CDF5, + NC_FORMAT_NETCDF4, NC_FORMAT_NETCDF4_CLASSIC}; if (argc > 2) { printf("Usage: %s [filename]\n",argv[0]); @@ -49,78 +51,91 @@ int main(int argc, char** argv) { printf("%-66s ------ ", cmd_str); fflush(stdout); free(cmd_str); - /* create a new file for writing ----------------------------------------*/ - err = nc_create(filename, NC_CLOBBER, &ncid); CHECK_ERR - - /* define dimension */ - err = nc_def_dim(ncid, "Y", NY, &dimid[0]); CHECK_ERR - err = nc_def_dim(ncid, "X", NX, &dimid[1]); CHECK_ERR - - /* define variables */ - err = nc_def_var(ncid, "var_nofill", NC_INT, 2, dimid, &varid[0]); CHECK_ERR - err = nc_def_var(ncid, "var_fill", NC_INT, 2, dimid, &varid[1]); CHECK_ERR - - /* set fill mode for variables */ - err = nc_def_var_fill(ncid, NC_GLOBAL, 0, NULL); EXP_ERR(NC_EGLOBAL) - err = nc_def_var_fill(ncid, varid[0], 1, NULL); CHECK_ERR - err = nc_def_var_fill(ncid, varid[1], 0, NULL); CHECK_ERR - - err = nc_enddef(ncid); CHECK_ERR - - /* write a subarray to both variables */ buf = (int*) malloc(NY*NX * sizeof(int)); - for (i=0; i