|
|
|||
|
||||
Next: NF_INQ_VAR_ENDIAN, Previous: NF_INQ_VAR_FLETCHER32, Up: Variables
NF_DEF_VAR_ENDIANThe function NF_DEF_VAR_ENDIAN sets the endianness for a variable in a netCDF-4 file.
This function must be called after the variable is defined, but before NF_ENDDEF is called.
By default, netCDF-4 variables are in native endianness. That is, they are big-endian on a big-endian machine, and little-endian on a little endian machine.
In some cases a user might wish to change from native endianness to either big or little-endianness. This function allows them to do that.
NF_DEF_VAR_ENDIAN(INTEGER NCID, INTEGER VARID, INTEGER ENDIAN)
NCIDVARIDENDIANNF_DEF_VAR_ENDIAN 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_EPERMIn this example from nf_test/ftst_vars.c, a file is created with one variable, and its endianness is set to NF_ENDIAN_BIG.
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 Set variable to big-endian (default is whatever is native to
C writing machine).
retval = NF_DEF_VAR_endian(ncid, varid, NF_ENDIAN_BIG)
if (retval .ne. nf_noerr) call handle_err(retval)
| Contact Us Site Map Search Terms and Conditions Privacy Policy Participation Policy | |||||
|
|||||