/* Set compression settings for a variable. Lower is faster, higher is * better. Must be called after nc_def_var and before nc_enddef. */ EXTERNL int nc_def_var_deflate(int ncid, int varid, int shuffle, int deflate, int deflate_level); /* Find out compression settings of a var. */ EXTERNL int nc_inq_var_deflate(int ncid, int varid, int *shufflep, int *deflatep, int *deflate_levelp);
if (nc_create(FILE_NAME, NC_NETCDF4, &ncid)) ERR; if (nc_def_dim(ncid, DIM1_NAME, DIM1_LEN, &dimids[0])) ERR; if (nc_def_dim(ncid, DIM2_NAME, DIM2_LEN, &dimids[1])) ERR; if (nc_def_dim(ncid, DIM3_NAME, DIM3_LEN, &dimids[2])) ERR; if (nc_def_var(ncid, VAR_BYTE_NAME, NC_BYTE, 2, dimids, &byte_varid)) ERR; if (nc_def_var_deflate(ncid, byte_varid, 0, 1, DEFLATE_LEVEL_4)) ERR; if (nc_def_var(ncid, VAR_CHAR_NAME, NC_CHAR, 3, dimids, &char_varid)) ERR; if (nc_def_var_deflate(ncid, byte_varid, 0, 1, DEFLATE_LEVEL_4)) ERR; if (nc_put_var_schar(ncid, byte_varid, (signed char *)byte_out)) ERR; if (nc_put_var_text(ncid, char_varid, (char *)char_out)) ERR; ... /* Open the file and check data. */ if (nc_open(FILE_NAME, 0, &ncid)) ERR; if (nc_get_var_schar(ncid, byte_varid, (signed char *)byte_in)) ERR; for (i = 0; i < DIM1_LEN; i++) for (j = 0; j < DIM2_LEN; j++) if (byte_in[i][j] != byte_out[i][j]) ERR;