|
|
|||
|
||||
NF_DEF_VAR_DEFLATEThe function NF_DEF_VAR_DEFLATE sets the deflate parameters for a variable in a netCDF-4 file.
When using parallel I/O for writing data, deflate cannot be used. This is because the compression makes it impossible for the HDF5 library to exactly map the data to disk location.
(Deflated data can be read with parallel I/O).
NC_DEF_VAR_DEFLATE must be called after the variable is defined, but before NC_ENDDEF is called.
NF_DEF_VAR_DEFLATE(INTEGER NCID, INTEGER VARID, INTEGER SHUFFLE, INTEGER DEFLATE,
INTEGER DEFLATE_LEVEL);
NCIDVARIDSHUFFLEDEFLATEDEFLATE_LEVELIf set to zero, no deflation takes place and the def_var_deflate call is ignored. This is slightly different from HDF5 handing of 0 deflate, which turns on the filter but makes only trivial changes to the data.
Informal testing at NetCDF World Headquarters suggests that there is little to be gained (with the limited set of test data used here), in setting the deflate level above 2 or 3.
NF_DEF_VAR_DEFLATE returns the value NF_NOERR if no errors occurred. Otherwise, the returned status indicates an error.
Possible return codes include:
NF_NOERRNF_BADIDNF_ENOTNC4NF_ENOTVARNF_ELATEDEFNF_ENOTINDEFINENF_EPERMNF_EINVALIn this example from nf_test/ftst_vars.F, a file is created with two dimensions and one variable. Chunking, deflate, and the fletcher32 filter are turned on. The deflate level is set to 4 below.
C Create the netCDF file.
retval = nf_create(FILE_NAME, NF_NETCDF4, ncid)
if (retval .ne. nf_noerr) call handle_err(retval)
C Define the dimensions.
retval = nf_def_dim(ncid, "x", NX, x_dimid)
if (retval .ne. nf_noerr) call handle_err(retval)
retval = nf_def_dim(ncid, "y", NY, y_dimid)
if (retval .ne. nf_noerr) call handle_err(retval)
C Define the variable.
dimids(1) = y_dimid
dimids(2) = x_dimid
retval = NF_DEF_VAR(ncid, "data", NF_INT, NDIMS, dimids, varid)
if (retval .ne. nf_noerr) call handle_err(retval)
C Turn on chunking.
chunks(1) = NY
chunks(2) = NX
retval = NF_DEF_VAR_chunking(ncid, varid, 0, chunks)
if (retval .ne. nf_noerr) call handle_err(retval)
C Turn on deflate, fletcher32.
retval = NF_DEF_VAR_deflate(ncid, varid, 0, 1, 4)
if (retval .ne. nf_noerr) call handle_err(retval)
retval = NF_DEF_VAR_fletcher32(ncid, varid, 1)
if (retval .ne. nf_noerr) call handle_err(retval)
| Contact Us Site Map Search Terms and Conditions Privacy Policy Participation Policy | ||||||
|
||||||