Rate This Document
Findability
Accuracy
Completeness
Readability

Attribute Information Writing

Function Syntax

  • Write an attribute.

    nc_put_att(int ncid, int varid, const char* name, int xtype, size_t len, const void* op)

  • Write an attribute of the int type.

    nc_put_att_int(int ncid, int varid, const char* name, nc_type xtype, size_t len, const int *op)

  • Write an attribute of the float type.

    nc_put_att_float(int ncid, int varid, const char* name, nc_type xtype, size_t len, const float *op)

  • Write an attribute of the double type.

    nc_put_att_double(int ncid, int varid, const char* name, nc_type xtype, size_t len, const double *op)

  • Write an attribute of the text type.

    nc_put_att_text(int ncid, int varid, const char* name, size_t len, const char *op)

Parameters

Parameter

Description

Value Range

Input/Output

ncid

File ID

Non-negative integer

Input

varid

Variable ID

Non-negative integer

Input

xtype

Attribute type

Non-negative integer

Input

name

Attribute name

Non-empty

Input

len

Attribute name length

Non-negative integer

Input

op

Pointer to data

Non-empty

Input

Return Value

  • Success: NC_NOERR
  • Failure: An error code is returned.

Error Code

Error Code

Description

NC_EBADID

Invalid ncid

NC_ENOTVAR

Invalid variable ID

NC_EINVAL

Invalid argument

NC_ENOMEM

Insufficient memory

Notes

  • Ensure that the pointer memory size is correct. Hyper IO cannot check the pointer size.
  • Currently, only attributes of the preceding types can be written. Ensure that the types correspond to the functions.
  • nc_type is an alias of the int type.