/src/netcdf-c/libdispatch/dattput.c
| Line | Count | Source | 
| 1 |  | /* Copyright 2018 University Corporation for Atmospheric | 
| 2 |  |    Research/Unidata. See copyright file for more info.  */ | 
| 3 |  | /** | 
| 4 |  |  * @file | 
| 5 |  |  * Functions to write attributes. | 
| 6 |  |  * | 
| 7 |  |  * These functions write attributes. | 
| 8 |  |  */ | 
| 9 |  | #include "ncdispatch.h" | 
| 10 |  |  | 
| 11 |  | /** | 
| 12 |  |  * @anchor writing_attributes | 
| 13 |  |  * @name Writing Attributes | 
| 14 |  |  * | 
| 15 |  |  * Functions to write attributes. | 
| 16 |  |  * | 
| 17 |  |  * For netCDF classic formats, attributes are defined when the dataset | 
| 18 |  |  * is first created, while the netCDF dataset is in define | 
| 19 |  |  * mode. Additional attributes may be added later by reentering define | 
| 20 |  |  * mode. For netCDF-4/HDF5 netCDF files, attributes may be defined at | 
| 21 |  |  * any time. | 
| 22 |  |  * | 
| 23 |  |  * In classic format files, the data type, length, and value of an | 
| 24 |  |  * attribute may be changed even when in data mode, as long as the | 
| 25 |  |  * changed attribute requires no more space than the attribute as | 
| 26 |  |  * originally defined. In netCDF-4/HDF5 files, attribute name, length, | 
| 27 |  |  * and value may be changed at any time. | 
| 28 |  |  * | 
| 29 |  |  * Attribute data conversion automatically takes place when the type | 
| 30 |  |  * of the data does not match the xtype argument. All attribute data | 
| 31 |  |  * values are converted to xtype before being written to the file. | 
| 32 |  |  * | 
| 33 |  |  * If writing a new attribute, or if the space required to store | 
| 34 |  |  * the attribute is greater than before, the netCDF dataset must be in | 
| 35 |  |  * define mode for classic formats (or netCDF-4/HDF5 with | 
| 36 |  |  * NC_CLASSIC_MODEL). | 
| 37 |  |  * | 
| 38 |  |  * @note With netCDF-4 files, nc_put_att will notice if you are | 
| 39 |  |  * writing a _FillValue attribute, and will tell the HDF5 layer to use | 
| 40 |  |  * the specified fill value for that variable.  With either classic or | 
| 41 |  |  * netCDF-4 files, a _FillValue attribute will be checked for | 
| 42 |  |  * validity, to make sure it has only one value and that its type | 
| 43 |  |  * matches the type of the associated variable. | 
| 44 |  |  * | 
| 45 |  | */ | 
| 46 |  |  | 
| 47 |  | /**@{*/  /* Start doxygen member group. */ | 
| 48 |  | /** | 
| 49 |  |  * @ingroup attributes | 
| 50 |  |  * Write a string attribute. | 
| 51 |  |  * | 
| 52 |  |  * The function nc_put_att_string adds or changes a variable attribute | 
| 53 |  |  * or global attribute of an open netCDF dataset. The string type is | 
| 54 |  |  * only available in netCDF-4/HDF5 files, when ::NC_CLASSIC_MODEL has | 
| 55 |  |  * not been used in nc_create(). | 
| 56 |  |  * | 
| 57 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 58 |  |  * | 
| 59 |  |  * @param ncid NetCDF file or group ID. | 
| 60 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 61 |  |  * @param name Attribute @ref object_name. | 
| 62 |  |  * @param len Number of values provided for the attribute. | 
| 63 |  |  * @param value Pointer to one or more values. | 
| 64 |  |  * | 
| 65 |  |  * @return ::NC_NOERR No error. | 
| 66 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 67 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 68 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 69 |  |  * @return ::NC_ENOMEM Out of memory | 
| 70 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 71 |  |  * | 
| 72 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 73 |  | */ | 
| 74 |  | int | 
| 75 |  | nc_put_att_string(int ncid, int varid, const char *name, | 
| 76 |  |       size_t len, const char** value) | 
| 77 | 0 | { | 
| 78 | 0 |     NC* ncp; | 
| 79 | 0 |     int stat = NC_check_id(ncid, &ncp); | 
| 80 | 0 |     if(stat != NC_NOERR) return stat; | 
| 81 | 0 |     return ncp->dispatch->put_att(ncid, varid, name, NC_STRING, | 
| 82 | 0 |           len, (void*)value, NC_STRING); | 
| 83 | 0 | } | 
| 84 |  |  | 
| 85 |  | /** | 
| 86 |  |  * @ingroup attributes | 
| 87 |  |  * Write a text attribute. | 
| 88 |  |  * | 
| 89 |  |  * Add or change a text attribute. If this attribute is new, or if the | 
| 90 |  |  * space required to store the attribute is greater than before, the | 
| 91 |  |  * netCDF dataset must be in define mode for classic formats (or | 
| 92 |  |  * netCDF-4/HDF5 with NC_CLASSIC_MODEL). | 
| 93 |  |  * | 
| 94 |  |  * Type conversion is not available with text attributes. | 
| 95 |  |  * | 
| 96 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 97 |  |  * | 
| 98 |  |  * @note Whether or not this length includes the NULL character in C | 
| 99 |  |  * char arrays is a user decision. If the NULL character is not | 
| 100 |  |  * written, then all C programs must add the NULL character after | 
| 101 |  |  * reading a text attribute. | 
| 102 |  |  * | 
| 103 |  |  * @param ncid NetCDF file or group ID. | 
| 104 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 105 |  |  * @param name Attribute @ref object_name. | 
| 106 |  |  * @param len The length of the text array. | 
| 107 |  |  * @param value Pointer to the start of the character array. | 
| 108 |  |  * | 
| 109 |  |  * @section nc_put_att_text_example Example | 
| 110 |  |  * | 
| 111 |  |  * Here is an example using nc_put_att_double() to add a variable | 
| 112 |  |  * attribute named valid_range for a netCDF variable named rh and | 
| 113 |  |  * nc_put_att_text() to add a global attribute named title to an | 
| 114 |  |  * existing netCDF dataset named foo.nc: | 
| 115 |  |  * | 
| 116 |  | @code | 
| 117 |  |      #include <netcdf.h> | 
| 118 |  |         ... | 
| 119 |  |      int  status; | 
| 120 |  |      int  ncid; | 
| 121 |  |      int  rh_id; | 
| 122 |  |      static double rh_range[] = {0.0, 100.0}; | 
| 123 |  |      static char title[] = "example netCDF dataset"; | 
| 124 |  |         ... | 
| 125 |  |      status = nc_open("foo.nc", NC_WRITE, &ncid); | 
| 126 |  |      if (status != NC_NOERR) handle_error(status); | 
| 127 |  |         ... | 
| 128 |  |      status = nc_redef(ncid); | 
| 129 |  |      if (status != NC_NOERR) handle_error(status); | 
| 130 |  |      status = nc_inq_varid (ncid, "rh", &rh_id); | 
| 131 |  |      if (status != NC_NOERR) handle_error(status); | 
| 132 |  |         ... | 
| 133 |  |      status = nc_put_att_double (ncid, rh_id, "valid_range", | 
| 134 |  |                                  NC_DOUBLE, 2, rh_range); | 
| 135 |  |      if (status != NC_NOERR) handle_error(status); | 
| 136 |  |      status = nc_put_att_text (ncid, NC_GLOBAL, "title", | 
| 137 |  |                                strlen(title), title) | 
| 138 |  |      if (status != NC_NOERR) handle_error(status); | 
| 139 |  |         ... | 
| 140 |  |      status = nc_enddef(ncid); | 
| 141 |  |      if (status != NC_NOERR) handle_error(status); | 
| 142 |  | @endcode | 
| 143 |  |  | 
| 144 |  |  * @return ::NC_NOERR No error. | 
| 145 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 146 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 147 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 148 |  |  * @return ::NC_ENOMEM Out of memory | 
| 149 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 150 |  |  * | 
| 151 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 152 |  | */ | 
| 153 |  | int nc_put_att_text(int ncid, int varid, const char *name, | 
| 154 |  |     size_t len, const char *value) | 
| 155 | 0 | { | 
| 156 | 0 |    NC* ncp; | 
| 157 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 158 | 0 |    if(stat != NC_NOERR) return stat; | 
| 159 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, NC_CHAR, len, | 
| 160 | 0 |          (void *)value, NC_CHAR); | 
| 161 | 0 | } | 
| 162 |  |  | 
| 163 |  | /** | 
| 164 |  |  * @ingroup attributes | 
| 165 |  |  * Write an attribute of any type. | 
| 166 |  |  * | 
| 167 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 168 |  |  * | 
| 169 |  |  * @param ncid NetCDF file or group ID. | 
| 170 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 171 |  |  * @param name Attribute @ref object_name. | 
| 172 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 173 |  |  * to this type. | 
| 174 |  |  * @param len Number of values provided for the attribute. | 
| 175 |  |  * @param value Pointer to one or more values. | 
| 176 |  |  * | 
| 177 |  |  * @section nc_put_att_double_example Example | 
| 178 |  |  * | 
| 179 |  |  * Here is an example using nc_put_att_double() to add a variable | 
| 180 |  |  * attribute named valid_range for a netCDF variable named rh and | 
| 181 |  |  * nc_put_att_text() to add a global attribute named title to an | 
| 182 |  |  * existing netCDF dataset named foo.nc: | 
| 183 |  |  * | 
| 184 |  | @code | 
| 185 |  |      #include <netcdf.h> | 
| 186 |  |         ... | 
| 187 |  |      int  status; | 
| 188 |  |      int  ncid; | 
| 189 |  |      int  rh_id; | 
| 190 |  |      static double rh_range[] = {0.0, 100.0}; | 
| 191 |  |      static char title[] = "example netCDF dataset"; | 
| 192 |  |         ... | 
| 193 |  |      status = nc_open("foo.nc", NC_WRITE, &ncid); | 
| 194 |  |      if (status != NC_NOERR) handle_error(status); | 
| 195 |  |         ... | 
| 196 |  |      status = nc_redef(ncid); | 
| 197 |  |      if (status != NC_NOERR) handle_error(status); | 
| 198 |  |      status = nc_inq_varid (ncid, "rh", &rh_id); | 
| 199 |  |      if (status != NC_NOERR) handle_error(status); | 
| 200 |  |         ... | 
| 201 |  |      status = nc_put_att_double (ncid, rh_id, "valid_range", | 
| 202 |  |                                  NC_DOUBLE, 2, rh_range); | 
| 203 |  |      if (status != NC_NOERR) handle_error(status); | 
| 204 |  |      status = nc_put_att_text (ncid, NC_GLOBAL, "title", | 
| 205 |  |                                strlen(title), title) | 
| 206 |  |      if (status != NC_NOERR) handle_error(status); | 
| 207 |  |         ... | 
| 208 |  |      status = nc_enddef(ncid); | 
| 209 |  |      if (status != NC_NOERR) handle_error(status); | 
| 210 |  | @endcode | 
| 211 |  |  | 
| 212 |  |  * @return ::NC_NOERR No error. | 
| 213 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 214 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 215 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 216 |  |  * @return ::NC_ENOMEM Out of memory | 
| 217 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 218 |  |  * | 
| 219 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 220 |  | */ | 
| 221 |  | int | 
| 222 |  | nc_put_att(int ncid, int varid, const char *name, nc_type xtype, | 
| 223 |  |      size_t len, const void *value) | 
| 224 | 0 | { | 
| 225 | 0 |    NC* ncp; | 
| 226 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 227 | 0 |    if(stat != NC_NOERR) return stat; | 
| 228 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 229 | 0 |          value, xtype); | 
| 230 | 0 | } | 
| 231 |  |  | 
| 232 |  | /** | 
| 233 |  |  * @ingroup attributes | 
| 234 |  |  * Write an attribute of type signed char. | 
| 235 |  |  * | 
| 236 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 237 |  |  * | 
| 238 |  |  * @param ncid NetCDF file or group ID. | 
| 239 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 240 |  |  * @param name Attribute @ref object_name. | 
| 241 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 242 |  |  * to this type. | 
| 243 |  |  * @param len Number of values provided for the attribute. | 
| 244 |  |  * @param value Pointer to one or more values. | 
| 245 |  |  * | 
| 246 |  |  * @return ::NC_NOERR No error. | 
| 247 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 248 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 249 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 250 |  |  * @return ::NC_ENOMEM Out of memory | 
| 251 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 252 |  |  * | 
| 253 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 254 |  | */ | 
| 255 |  | int | 
| 256 |  | nc_put_att_schar(int ncid, int varid, const char *name, | 
| 257 |  |      nc_type xtype, size_t len, const signed char *value) | 
| 258 | 0 | { | 
| 259 | 0 |    NC *ncp; | 
| 260 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 261 | 0 |    if(stat != NC_NOERR) return stat; | 
| 262 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 263 | 0 |          (void *)value, NC_BYTE); | 
| 264 | 0 | } | 
| 265 |  |  | 
| 266 |  | /** | 
| 267 |  |  * @ingroup attributes | 
| 268 |  |  * Write an attribute of type unsigned char. | 
| 269 |  |  * | 
| 270 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 271 |  |  * | 
| 272 |  |  * @param ncid NetCDF file or group ID. | 
| 273 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 274 |  |  * @param name Attribute @ref object_name. | 
| 275 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 276 |  |  * to this type. | 
| 277 |  |  * @param len Number of values provided for the attribute. | 
| 278 |  |  * @param value Pointer to one or more values. | 
| 279 |  |  * | 
| 280 |  |  * @return ::NC_NOERR No error. | 
| 281 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 282 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 283 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 284 |  |  * @return ::NC_ENOMEM Out of memory | 
| 285 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 286 |  |  * | 
| 287 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 288 |  | */ | 
| 289 |  | int | 
| 290 |  | nc_put_att_uchar(int ncid, int varid, const char *name, | 
| 291 |  |      nc_type xtype, size_t len, const unsigned char *value) | 
| 292 | 0 | { | 
| 293 | 0 |    NC* ncp; | 
| 294 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 295 | 0 |    if(stat != NC_NOERR) return stat; | 
| 296 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 297 | 0 |          (void *)value, NC_UBYTE); | 
| 298 | 0 | } | 
| 299 |  |  | 
| 300 |  | /** | 
| 301 |  |  * @ingroup attributes | 
| 302 |  |  * Write an attribute of type short. | 
| 303 |  |  * | 
| 304 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 305 |  |  * | 
| 306 |  |  * @param ncid NetCDF file or group ID. | 
| 307 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 308 |  |  * @param name Attribute @ref object_name. | 
| 309 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 310 |  |  * to this type. | 
| 311 |  |  * @param len Number of values provided for the attribute. | 
| 312 |  |  * @param value Pointer to one or more values. | 
| 313 |  |  * | 
| 314 |  |  * @return ::NC_NOERR No error. | 
| 315 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 316 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 317 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 318 |  |  * @return ::NC_ENOMEM Out of memory | 
| 319 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 320 |  |  * | 
| 321 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 322 |  | */ | 
| 323 |  | int | 
| 324 |  | nc_put_att_short(int ncid, int varid, const char *name, | 
| 325 |  |      nc_type xtype, size_t len, const short *value) | 
| 326 | 0 | { | 
| 327 | 0 |    NC* ncp; | 
| 328 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 329 | 0 |    if(stat != NC_NOERR) return stat; | 
| 330 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 331 | 0 |          (void *)value, NC_SHORT); | 
| 332 | 0 | } | 
| 333 |  |  | 
| 334 |  | /** | 
| 335 |  |  * @ingroup attributes | 
| 336 |  |  * Write an attribute of type int. | 
| 337 |  |  * | 
| 338 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 339 |  |  * | 
| 340 |  |  * @param ncid NetCDF file or group ID. | 
| 341 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 342 |  |  * @param name Attribute @ref object_name. | 
| 343 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 344 |  |  * to this type. | 
| 345 |  |  * @param len Number of values provided for the attribute. | 
| 346 |  |  * @param value Pointer to one or more values. | 
| 347 |  |  * | 
| 348 |  |  * @return ::NC_NOERR No error. | 
| 349 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 350 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 351 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 352 |  |  * @return ::NC_ENOMEM Out of memory | 
| 353 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 354 |  |  * | 
| 355 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 356 |  | */ | 
| 357 |  | int | 
| 358 |  | nc_put_att_int(int ncid, int varid, const char *name, | 
| 359 |  |          nc_type xtype, size_t len, const int *value) | 
| 360 | 0 | { | 
| 361 | 0 |    NC* ncp; | 
| 362 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 363 | 0 |    if(stat != NC_NOERR) return stat; | 
| 364 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 365 | 0 |          (void *)value, NC_INT); | 
| 366 | 0 | } | 
| 367 |  |  | 
| 368 |  | /** | 
| 369 |  |  * @ingroup attributes | 
| 370 |  |  * Write an attribute of type long. | 
| 371 |  |  * | 
| 372 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 373 |  |  * | 
| 374 |  |  * @param ncid NetCDF file or group ID. | 
| 375 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 376 |  |  * @param name Attribute @ref object_name. | 
| 377 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 378 |  |  * to this type. | 
| 379 |  |  * @param len Number of values provided for the attribute. | 
| 380 |  |  * @param value Pointer to one or more values. | 
| 381 |  |  * | 
| 382 |  |  * @return ::NC_NOERR No error. | 
| 383 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 384 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 385 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 386 |  |  * @return ::NC_ENOMEM Out of memory | 
| 387 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 388 |  |  * | 
| 389 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 390 |  | */ | 
| 391 |  | int | 
| 392 |  | nc_put_att_long(int ncid, int varid, const char *name, | 
| 393 |  |     nc_type xtype, size_t len, const long *value) | 
| 394 | 0 | { | 
| 395 | 0 |    NC* ncp; | 
| 396 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 397 | 0 |    if(stat != NC_NOERR) return stat; | 
| 398 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 399 | 0 |          (void *)value, longtype); | 
| 400 | 0 | } | 
| 401 |  |  | 
| 402 |  | /** | 
| 403 |  |  * @ingroup attributes | 
| 404 |  |  * Write an attribute of type float. | 
| 405 |  |  * | 
| 406 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 407 |  |  * | 
| 408 |  |  * @param ncid NetCDF file or group ID. | 
| 409 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 410 |  |  * @param name Attribute @ref object_name. | 
| 411 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 412 |  |  * to this type. | 
| 413 |  |  * @param len Number of values provided for the attribute. | 
| 414 |  |  * @param value Pointer to one or more values. | 
| 415 |  |  * | 
| 416 |  |  * @return ::NC_NOERR No error. | 
| 417 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 418 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 419 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 420 |  |  * @return ::NC_ENOMEM Out of memory | 
| 421 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 422 |  |  * | 
| 423 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 424 |  | */ | 
| 425 |  | int | 
| 426 |  | nc_put_att_float(int ncid, int varid, const char *name, | 
| 427 |  |      nc_type xtype, size_t len, const float *value) | 
| 428 | 0 | { | 
| 429 | 0 |    NC* ncp; | 
| 430 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 431 | 0 |    if(stat != NC_NOERR) return stat; | 
| 432 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 433 | 0 |          (void *)value, NC_FLOAT); | 
| 434 | 0 | } | 
| 435 |  |  | 
| 436 |  | /** | 
| 437 |  |  * @ingroup attributes | 
| 438 |  |  * Write an attribute of type double. | 
| 439 |  |  * | 
| 440 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 441 |  |  * | 
| 442 |  |  * @param ncid NetCDF file or group ID. | 
| 443 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 444 |  |  * @param name Attribute @ref object_name. | 
| 445 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 446 |  |  * to this type. | 
| 447 |  |  * @param len Number of values provided for the attribute. | 
| 448 |  |  * @param value Pointer to one or more values. | 
| 449 |  |  * | 
| 450 |  |  * @return ::NC_NOERR No error. | 
| 451 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 452 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 453 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 454 |  |  * @return ::NC_ENOMEM Out of memory | 
| 455 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 456 |  |  * | 
| 457 |  |  * @author Glenn Davis, Ed Hartnett, Dennis Heimbigner | 
| 458 |  | */ | 
| 459 |  | int | 
| 460 |  | nc_put_att_double(int ncid, int varid, const char *name, | 
| 461 |  |       nc_type xtype, size_t len, const double *value) | 
| 462 | 0 | { | 
| 463 | 0 |    NC* ncp; | 
| 464 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 465 | 0 |    if(stat != NC_NOERR) return stat; | 
| 466 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 467 | 0 |          (void *)value, NC_DOUBLE); | 
| 468 | 0 | } | 
| 469 |  |  | 
| 470 |  | /** | 
| 471 |  |  * @ingroup attributes | 
| 472 |  |  * Write an attribute of type unsigned char. | 
| 473 |  |  * | 
| 474 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 475 |  |  * | 
| 476 |  |  * @param ncid NetCDF file or group ID. | 
| 477 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 478 |  |  * @param name Attribute @ref object_name. | 
| 479 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 480 |  |  * to this type. | 
| 481 |  |  * @param len Number of values provided for the attribute. | 
| 482 |  |  * @param value Pointer to one or more values. | 
| 483 |  |  * | 
| 484 |  |  * @return ::NC_NOERR No error. | 
| 485 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 486 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 487 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 488 |  |  * @return ::NC_ENOMEM Out of memory | 
| 489 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 490 |  |  * | 
| 491 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 492 |  | */ | 
| 493 |  | int | 
| 494 |  | nc_put_att_ubyte(int ncid, int varid, const char *name, | 
| 495 |  |      nc_type xtype, size_t len, const unsigned char *value) | 
| 496 | 0 | { | 
| 497 | 0 |    NC* ncp; | 
| 498 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 499 | 0 |    if(stat != NC_NOERR) return stat; | 
| 500 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 501 | 0 |          (void *)value, NC_UBYTE); | 
| 502 | 0 | } | 
| 503 |  |  | 
| 504 |  | /** | 
| 505 |  |  * @ingroup attributes | 
| 506 |  |  * Write an attribute of type unsigned short. | 
| 507 |  |  * | 
| 508 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 509 |  |  * | 
| 510 |  |  * @param ncid NetCDF file or group ID. | 
| 511 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 512 |  |  * @param name Attribute @ref object_name. | 
| 513 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 514 |  |  * to this type. | 
| 515 |  |  * @param len Number of values provided for the attribute. | 
| 516 |  |  * @param value Pointer to one or more values. | 
| 517 |  |  * | 
| 518 |  |  * @return ::NC_NOERR No error. | 
| 519 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 520 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 521 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 522 |  |  * @return ::NC_ENOMEM Out of memory | 
| 523 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 524 |  |  * | 
| 525 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 526 |  | */ | 
| 527 |  | int | 
| 528 |  | nc_put_att_ushort(int ncid, int varid, const char *name, | 
| 529 |  |       nc_type xtype, size_t len, const unsigned short *value) | 
| 530 | 0 | { | 
| 531 | 0 |    NC* ncp; | 
| 532 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 533 | 0 |    if(stat != NC_NOERR) return stat; | 
| 534 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 535 | 0 |          (void *)value, NC_USHORT); | 
| 536 | 0 | } | 
| 537 |  |  | 
| 538 |  | /** | 
| 539 |  |  * @ingroup attributes | 
| 540 |  |  * Write an attribute of type unsigned int. | 
| 541 |  |  * | 
| 542 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 543 |  |  * | 
| 544 |  |  * @param ncid NetCDF file or group ID. | 
| 545 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 546 |  |  * @param name Attribute @ref object_name. | 
| 547 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 548 |  |  * to this type. | 
| 549 |  |  * @param len Number of values provided for the attribute. | 
| 550 |  |  * @param value Pointer to one or more values. | 
| 551 |  |  * | 
| 552 |  |  * @return ::NC_NOERR No error. | 
| 553 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 554 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 555 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 556 |  |  * @return ::NC_ENOMEM Out of memory | 
| 557 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 558 |  |  * | 
| 559 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 560 |  | */ | 
| 561 |  | int | 
| 562 |  | nc_put_att_uint(int ncid, int varid, const char *name, | 
| 563 |  |     nc_type xtype, size_t len, const unsigned int *value) | 
| 564 | 0 | { | 
| 565 | 0 |    NC* ncp; | 
| 566 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 567 | 0 |    if(stat != NC_NOERR) return stat; | 
| 568 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 569 | 0 |          (void *)value, NC_UINT); | 
| 570 | 0 | } | 
| 571 |  |  | 
| 572 |  | /** | 
| 573 |  |  * @ingroup attributes | 
| 574 |  |  * Write an attribute of type long long. | 
| 575 |  |  * | 
| 576 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 577 |  |  * | 
| 578 |  |  * @param ncid NetCDF file or group ID. | 
| 579 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 580 |  |  * @param name Attribute @ref object_name. | 
| 581 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 582 |  |  * to this type. | 
| 583 |  |  * @param len Number of values provided for the attribute. | 
| 584 |  |  * @param value Pointer to one or more values. | 
| 585 |  |  * | 
| 586 |  |  * @return ::NC_NOERR No error. | 
| 587 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 588 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 589 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 590 |  |  * @return ::NC_ENOMEM Out of memory | 
| 591 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 592 |  |  * | 
| 593 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 594 |  | */ | 
| 595 |  | int | 
| 596 |  | nc_put_att_longlong(int ncid, int varid, const char *name, | 
| 597 |  |         nc_type xtype, size_t len, | 
| 598 |  |         const long long *value) | 
| 599 | 0 | { | 
| 600 | 0 |    NC* ncp; | 
| 601 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 602 | 0 |    if(stat != NC_NOERR) return stat; | 
| 603 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 604 | 0 |          (void *)value, NC_INT64); | 
| 605 | 0 | } | 
| 606 |  |  | 
| 607 |  | /** | 
| 608 |  |  * @ingroup attributes | 
| 609 |  |  * Write an attribute of type unsigned long long. | 
| 610 |  |  * | 
| 611 |  |  * Also see @ref writing_attributes "Writing Attributes" | 
| 612 |  |  * | 
| 613 |  |  * @param ncid NetCDF file or group ID. | 
| 614 |  |  * @param varid Variable ID, or ::NC_GLOBAL for a global attribute. | 
| 615 |  |  * @param name Attribute @ref object_name. | 
| 616 |  |  * @param xtype The type of attribute to write. Data will be converted | 
| 617 |  |  * to this type. | 
| 618 |  |  * @param len Number of values provided for the attribute. | 
| 619 |  |  * @param value Pointer to one or more values. | 
| 620 |  |  * | 
| 621 |  |  * @return ::NC_NOERR No error. | 
| 622 |  |  * @return ::NC_EINVAL Invalid or global _FillValue. | 
| 623 |  |  * @return ::NC_ENOTVAR Couldn't find varid. | 
| 624 |  |  * @return ::NC_EBADTYPE Fill value and var must be same type. | 
| 625 |  |  * @return ::NC_ENOMEM Out of memory | 
| 626 |  |  * @return ::NC_ELATEFILL Too late to set fill value. | 
| 627 |  |  * | 
| 628 |  |  * @author Ed Hartnett, Dennis Heimbigner | 
| 629 |  | */ | 
| 630 |  | int | 
| 631 |  | nc_put_att_ulonglong(int ncid, int varid, const char *name, | 
| 632 |  |          nc_type xtype, size_t len, | 
| 633 |  |          const unsigned long long *value) | 
| 634 | 0 | { | 
| 635 | 0 |    NC* ncp; | 
| 636 | 0 |    int stat = NC_check_id(ncid, &ncp); | 
| 637 | 0 |    if(stat != NC_NOERR) return stat; | 
| 638 | 0 |    return ncp->dispatch->put_att(ncid, varid, name, xtype, len, | 
| 639 | 0 |          (void *)value, NC_UINT64); | 
| 640 | 0 | } | 
| 641 |  |  | 
| 642 |  | /**@}*/  /* End doxygen member group. */ |