[1022] | 1 | /*! \file |
---|
| 2 | Functions for getting data from variables. |
---|
| 3 | |
---|
| 4 | Copyright 2011 University Corporation for Atmospheric |
---|
| 5 | Research/Unidata. See \ref COPYRIGHT file for more info. */ |
---|
| 6 | |
---|
| 7 | #include "ncdispatch.h" |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | /** \internal |
---|
| 11 | \ingroup variables |
---|
| 12 | |
---|
| 13 | */ |
---|
| 14 | int |
---|
| 15 | NC_get_vara(int ncid, int varid, |
---|
| 16 | const size_t *start, const size_t *edges, |
---|
| 17 | void *value, nc_type memtype) |
---|
| 18 | { |
---|
| 19 | NC* ncp; |
---|
| 20 | int stat = NC_check_id(ncid, &ncp); |
---|
| 21 | if(stat != NC_NOERR) return stat; |
---|
| 22 | #ifdef USE_NETCDF4 |
---|
| 23 | if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT; |
---|
| 24 | #endif |
---|
| 25 | if(edges == NULL) { |
---|
| 26 | size_t shape[NC_MAX_VAR_DIMS]; |
---|
| 27 | int ndims; |
---|
| 28 | stat = nc_inq_varndims(ncid, varid, &ndims); |
---|
| 29 | if(stat != NC_NOERR) return stat; |
---|
| 30 | stat = NC_getshape(ncid,varid,ndims,shape); |
---|
| 31 | if(stat != NC_NOERR) return stat; |
---|
| 32 | return ncp->dispatch->get_vara(ncid,varid,start,shape,value,memtype); |
---|
| 33 | } else |
---|
| 34 | return ncp->dispatch->get_vara(ncid,varid,start,edges,value,memtype); |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | /** \ingroup variables |
---|
| 38 | \internal |
---|
| 39 | */ |
---|
| 40 | static int |
---|
| 41 | NC_get_var(int ncid, int varid, void *value, nc_type memtype) |
---|
| 42 | { |
---|
| 43 | int ndims; |
---|
| 44 | size_t shape[NC_MAX_VAR_DIMS]; |
---|
| 45 | int stat = nc_inq_varndims(ncid,varid, &ndims); |
---|
| 46 | if(stat) return stat; |
---|
| 47 | stat = NC_getshape(ncid,varid, ndims, shape); |
---|
| 48 | if(stat) return stat; |
---|
| 49 | return NC_get_vara(ncid, varid, NC_coord_zero, shape, value, memtype); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | /** \internal |
---|
| 53 | \ingroup variables |
---|
| 54 | Most dispatch tables will use the default procedures |
---|
| 55 | */ |
---|
| 56 | int |
---|
| 57 | NCDEFAULT_get_vars(int ncid, int varid, const size_t * start, |
---|
| 58 | const size_t * edges, const ptrdiff_t * stride, |
---|
| 59 | void *value, nc_type memtype) |
---|
| 60 | { |
---|
| 61 | NC* ncp; |
---|
| 62 | int stat = NC_check_id(ncid, &ncp); |
---|
| 63 | |
---|
| 64 | if(stat != NC_NOERR) return stat; |
---|
| 65 | return ncp->dispatch->get_varm(ncid,varid,start,edges,stride,NULL,value,memtype); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /** \internal |
---|
| 69 | \ingroup variables |
---|
| 70 | */ |
---|
| 71 | static int |
---|
| 72 | NC_get_var1(int ncid, int varid, const size_t *coord, void* value, |
---|
| 73 | nc_type memtype) |
---|
| 74 | { |
---|
| 75 | return NC_get_vara(ncid, varid, coord, NC_coord_one, value, memtype); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | /** \internal |
---|
| 79 | \ingroup variables |
---|
| 80 | */ |
---|
| 81 | int |
---|
| 82 | NCDEFAULT_get_varm(int ncid, int varid, const size_t *start, |
---|
| 83 | const size_t *edges, const ptrdiff_t *stride, |
---|
| 84 | const ptrdiff_t *imapp, void *value0, nc_type memtype) |
---|
| 85 | { |
---|
| 86 | int status = NC_NOERR; |
---|
| 87 | nc_type vartype = NC_NAT; |
---|
| 88 | int varndims,maxidim; |
---|
| 89 | NC* ncp; |
---|
| 90 | size_t memtypelen; |
---|
| 91 | ptrdiff_t cvtmap[NC_MAX_VAR_DIMS]; |
---|
| 92 | char* value = (char*)value0; |
---|
| 93 | |
---|
| 94 | status = NC_check_id (ncid, &ncp); |
---|
| 95 | if(status != NC_NOERR) return status; |
---|
| 96 | |
---|
| 97 | /* |
---|
| 98 | if(NC_indef(ncp)) return NC_EINDEFINE; |
---|
| 99 | */ |
---|
| 100 | |
---|
| 101 | status = nc_inq_vartype(ncid, varid, &vartype); |
---|
| 102 | if(status != NC_NOERR) return status; |
---|
| 103 | /* Check that this is an atomic type */ |
---|
| 104 | if(vartype >= NC_MAX_ATOMIC_TYPE) |
---|
| 105 | return NC_EMAPTYPE; |
---|
| 106 | |
---|
| 107 | status = nc_inq_varndims(ncid, varid, &varndims); |
---|
| 108 | if(status != NC_NOERR) return status; |
---|
| 109 | |
---|
| 110 | if(memtype == NC_NAT) { |
---|
| 111 | if(imapp != NULL && varndims != 0) { |
---|
| 112 | /* |
---|
| 113 | * convert map units from bytes to units of sizeof(type) |
---|
| 114 | */ |
---|
| 115 | size_t ii; |
---|
| 116 | const ptrdiff_t szof = (ptrdiff_t) nctypelen(vartype); |
---|
| 117 | for(ii = 0; ii < varndims; ii++) { |
---|
| 118 | if(imapp[ii] % szof != 0) { |
---|
| 119 | /*free(cvtmap);*/ |
---|
| 120 | return NC_EINVAL; |
---|
| 121 | } |
---|
| 122 | cvtmap[ii] = imapp[ii] / szof; |
---|
| 123 | } |
---|
| 124 | imapp = cvtmap; |
---|
| 125 | } |
---|
| 126 | memtype = vartype; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | if(memtype == NC_CHAR && vartype != NC_CHAR) |
---|
| 130 | return NC_ECHAR; |
---|
| 131 | else if(memtype != NC_CHAR && vartype == NC_CHAR) |
---|
| 132 | return NC_ECHAR; |
---|
| 133 | |
---|
| 134 | memtypelen = nctypelen(memtype); |
---|
| 135 | |
---|
| 136 | maxidim = (int) varndims - 1; |
---|
| 137 | |
---|
| 138 | if (maxidim < 0) |
---|
| 139 | { |
---|
| 140 | /* |
---|
| 141 | * The variable is a scalar; consequently, |
---|
| 142 | * there s only one thing to get and only one place to put it. |
---|
| 143 | * (Why was I called?) |
---|
| 144 | */ |
---|
| 145 | size_t edge1[1] = {1}; |
---|
| 146 | return NC_get_vara(ncid, varid, start, edge1, value, memtype); |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | /* |
---|
| 150 | * else |
---|
| 151 | * The variable is an array. |
---|
| 152 | */ |
---|
| 153 | { |
---|
| 154 | int idim; |
---|
| 155 | size_t *mystart = NULL; |
---|
| 156 | size_t *myedges; |
---|
| 157 | size_t *iocount; /* count vector */ |
---|
| 158 | size_t *stop; /* stop indexes */ |
---|
| 159 | size_t *length; /* edge lengths in bytes */ |
---|
| 160 | ptrdiff_t *mystride; |
---|
| 161 | ptrdiff_t *mymap; |
---|
| 162 | size_t varshape[NC_MAX_VAR_DIMS]; |
---|
| 163 | int isrecvar; |
---|
| 164 | size_t numrecs; |
---|
| 165 | |
---|
| 166 | /* Compute some dimension related values */ |
---|
| 167 | isrecvar = NC_is_recvar(ncid,varid,&numrecs); |
---|
| 168 | NC_getshape(ncid,varid,varndims,varshape); |
---|
| 169 | |
---|
| 170 | /* |
---|
| 171 | * Verify stride argument; also see if stride is all ones |
---|
| 172 | */ |
---|
| 173 | if(stride != NULL) { |
---|
| 174 | int stride1 = 1; |
---|
| 175 | for (idim = 0; idim <= maxidim; ++idim) |
---|
| 176 | { |
---|
| 177 | if (stride[idim] == 0 |
---|
| 178 | /* cast needed for braindead systems with signed size_t */ |
---|
| 179 | || ((unsigned long) stride[idim] >= X_INT_MAX)) |
---|
| 180 | { |
---|
| 181 | return NC_ESTRIDE; |
---|
| 182 | } |
---|
| 183 | if(stride[idim] != 1) stride1 = 0; |
---|
| 184 | } |
---|
| 185 | /* If stride1 is true, and there is no imap |
---|
| 186 | then call get_vara directly. |
---|
| 187 | */ |
---|
| 188 | if(stride1 && imapp == NULL) { |
---|
| 189 | return NC_get_vara(ncid, varid, start, edges, value, memtype); |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | /* assert(sizeof(ptrdiff_t) >= sizeof(size_t)); */ |
---|
| 194 | /* Allocate space for mystart,mystride,mymap etc.all at once */ |
---|
| 195 | mystart = (size_t *)calloc(varndims * 7, sizeof(ptrdiff_t)); |
---|
| 196 | if(mystart == NULL) return NC_ENOMEM; |
---|
| 197 | myedges = mystart + varndims; |
---|
| 198 | iocount = myedges + varndims; |
---|
| 199 | stop = iocount + varndims; |
---|
| 200 | length = stop + varndims; |
---|
| 201 | mystride = (ptrdiff_t *)(length + varndims); |
---|
| 202 | mymap = mystride + varndims; |
---|
| 203 | |
---|
| 204 | /* |
---|
| 205 | * Initialize I/O parameters. |
---|
| 206 | */ |
---|
| 207 | for (idim = maxidim; idim >= 0; --idim) |
---|
| 208 | { |
---|
| 209 | mystart[idim] = start != NULL |
---|
| 210 | ? start[idim] |
---|
| 211 | : 0; |
---|
| 212 | |
---|
| 213 | if (edges != NULL && edges[idim] == 0) |
---|
| 214 | { |
---|
| 215 | status = NC_NOERR; /* read/write no data */ |
---|
| 216 | goto done; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | #ifdef COMPLEX |
---|
| 220 | myedges[idim] = edges != NULL |
---|
| 221 | ? edges[idim] |
---|
| 222 | : idim == 0 && isrecvar |
---|
| 223 | ? numrecs - mystart[idim] |
---|
| 224 | : varshape[idim] - mystart[idim]; |
---|
| 225 | #else |
---|
| 226 | if(edges != NULL) |
---|
| 227 | myedges[idim] = edges[idim]; |
---|
| 228 | else if (idim == 0 && isrecvar) |
---|
| 229 | myedges[idim] = numrecs - mystart[idim]; |
---|
| 230 | else |
---|
| 231 | myedges[idim] = varshape[idim] - mystart[idim]; |
---|
| 232 | #endif |
---|
| 233 | |
---|
| 234 | mystride[idim] = stride != NULL |
---|
| 235 | ? stride[idim] |
---|
| 236 | : 1; |
---|
| 237 | |
---|
| 238 | /* Remember: imapp is byte oriented, not index oriented */ |
---|
| 239 | #ifdef COMPLEX |
---|
| 240 | mymap[idim] = (imapp != NULL |
---|
| 241 | ? imapp[idim] |
---|
| 242 | : (idim == maxidim ? 1 |
---|
| 243 | : mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1])); |
---|
| 244 | #else |
---|
| 245 | if(imapp != NULL) |
---|
| 246 | mymap[idim] = imapp[idim]; |
---|
| 247 | else if (idim == maxidim) |
---|
| 248 | mymap[idim] = 1; |
---|
| 249 | else |
---|
| 250 | mymap[idim] = |
---|
| 251 | mymap[idim + 1] * (ptrdiff_t) myedges[idim + 1]; |
---|
| 252 | #endif |
---|
| 253 | iocount[idim] = 1; |
---|
| 254 | length[idim] = mymap[idim] * myedges[idim]; |
---|
| 255 | stop[idim] = mystart[idim] + myedges[idim] * mystride[idim]; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | /* |
---|
| 259 | * Check start, edges |
---|
| 260 | */ |
---|
| 261 | for (idim = maxidim; idim >= 0; --idim) |
---|
| 262 | { |
---|
| 263 | size_t dimlen = |
---|
| 264 | idim == 0 && isrecvar |
---|
| 265 | ? numrecs |
---|
| 266 | : varshape[idim]; |
---|
| 267 | if (mystart[idim] >= dimlen) |
---|
| 268 | { |
---|
| 269 | status = NC_EINVALCOORDS; |
---|
| 270 | goto done; |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | if (mystart[idim] + myedges[idim] > dimlen) |
---|
| 274 | { |
---|
| 275 | status = NC_EEDGE; |
---|
| 276 | goto done; |
---|
| 277 | } |
---|
| 278 | |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | |
---|
| 282 | /* Lower body */ |
---|
| 283 | /* |
---|
| 284 | * As an optimization, adjust I/O parameters when the fastest |
---|
| 285 | * dimension has unity stride both externally and internally. |
---|
| 286 | * In this case, the user could have called a simpler routine |
---|
| 287 | * (i.e. ncvar$1() |
---|
| 288 | */ |
---|
| 289 | if (mystride[maxidim] == 1 |
---|
| 290 | && mymap[maxidim] == 1) |
---|
| 291 | { |
---|
| 292 | iocount[maxidim] = myedges[maxidim]; |
---|
| 293 | mystride[maxidim] = (ptrdiff_t) myedges[maxidim]; |
---|
| 294 | mymap[maxidim] = (ptrdiff_t) length[maxidim]; |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | /* |
---|
| 298 | * Perform I/O. Exit when done. |
---|
| 299 | */ |
---|
| 300 | for (;;) |
---|
| 301 | { |
---|
| 302 | /* TODO: */ |
---|
| 303 | int lstatus = NC_get_vara(ncid, varid, mystart, iocount, |
---|
| 304 | value, memtype); |
---|
| 305 | if (lstatus != NC_NOERR) { |
---|
| 306 | if(status == NC_NOERR || lstatus != NC_ERANGE) |
---|
| 307 | status = lstatus; |
---|
| 308 | } |
---|
| 309 | /* |
---|
| 310 | * The following code permutes through the variable s |
---|
| 311 | * external start-index space and it s internal address |
---|
| 312 | * space. At the UPC, this algorithm is commonly |
---|
| 313 | * called "odometer code". |
---|
| 314 | */ |
---|
| 315 | idim = maxidim; |
---|
| 316 | carry: |
---|
| 317 | value += (mymap[idim] * memtypelen); |
---|
| 318 | mystart[idim] += mystride[idim]; |
---|
| 319 | if (mystart[idim] == stop[idim]) |
---|
| 320 | { |
---|
| 321 | mystart[idim] = start[idim]; |
---|
| 322 | value -= (length[idim] * memtypelen); |
---|
| 323 | if (--idim < 0) |
---|
| 324 | break; /* normal return */ |
---|
| 325 | goto carry; |
---|
| 326 | } |
---|
| 327 | } /* I/O loop */ |
---|
| 328 | done: |
---|
| 329 | free(mystart); |
---|
| 330 | } /* variable is array */ |
---|
| 331 | return status; |
---|
| 332 | } |
---|
| 333 | |
---|
| 334 | /** \ingroup variables |
---|
| 335 | \internal |
---|
| 336 | Called by externally visible nc_get_vars_xxx routines */ |
---|
| 337 | static int |
---|
| 338 | NC_get_vars(int ncid, int varid, const size_t *start, |
---|
| 339 | const size_t *edges, const ptrdiff_t *stride, void *value, |
---|
| 340 | nc_type memtype) |
---|
| 341 | { |
---|
| 342 | NC* ncp; |
---|
| 343 | int stat = NC_check_id(ncid, &ncp); |
---|
| 344 | |
---|
| 345 | if(stat != NC_NOERR) return stat; |
---|
| 346 | #ifdef USE_NETCDF4 |
---|
| 347 | if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT; |
---|
| 348 | #endif |
---|
| 349 | return ncp->dispatch->get_vars(ncid,varid,start,edges,stride,value,memtype); |
---|
| 350 | } |
---|
| 351 | |
---|
| 352 | /** \ingroup variables |
---|
| 353 | \internal |
---|
| 354 | Called by externally visible nc_get_varm_xxx routines |
---|
| 355 | */ |
---|
| 356 | static int |
---|
| 357 | NC_get_varm(int ncid, int varid, const size_t *start, |
---|
| 358 | const size_t *edges, const ptrdiff_t *stride, const ptrdiff_t* map, |
---|
| 359 | void *value, nc_type memtype) |
---|
| 360 | { |
---|
| 361 | NC* ncp; |
---|
| 362 | int stat = NC_check_id(ncid, &ncp); |
---|
| 363 | |
---|
| 364 | if(stat != NC_NOERR) return stat; |
---|
| 365 | #ifdef USE_NETCDF4 |
---|
| 366 | if(memtype >= NC_FIRSTUSERTYPEID) memtype = NC_NAT; |
---|
| 367 | #endif |
---|
| 368 | return ncp->dispatch->get_varm(ncid,varid,start,edges,stride,map,value,memtype); |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | /** \name Reading Data from Variables |
---|
| 372 | |
---|
| 373 | Functions to read data from variables. */ |
---|
| 374 | /*! \{ */ /* All these functions are part of this named group... */ |
---|
| 375 | |
---|
| 376 | /** \ingroup variables |
---|
| 377 | Read an array of values from a variable. |
---|
| 378 | |
---|
| 379 | The array to be read is specified by giving a corner and a vector of |
---|
| 380 | edge lengths to \ref specify_hyperslab. |
---|
| 381 | |
---|
| 382 | The data values are read into consecutive locations with the last |
---|
| 383 | dimension varying fastest. The netCDF dataset must be in data mode |
---|
| 384 | (for netCDF-4/HDF5 files, the switch to data mode will happen |
---|
| 385 | automatically, unless the classic model is used). |
---|
| 386 | |
---|
| 387 | The nc_get_vara() function will read a variable of any type, |
---|
| 388 | including user defined type. For this function, the type of the data |
---|
| 389 | in memory must match the type of the variable - no data conversion is |
---|
| 390 | done. |
---|
| 391 | |
---|
| 392 | Other nc_get_vara_ functions will convert data to the desired output |
---|
| 393 | type as needed. |
---|
| 394 | |
---|
| 395 | \param ncid NetCDF or group ID, from a previous call to nc_open(), |
---|
| 396 | nc_create(), nc_def_grp(), or associated inquiry functions such as |
---|
| 397 | nc_inq_ncid(). |
---|
| 398 | |
---|
| 399 | \param varid Variable ID |
---|
| 400 | |
---|
| 401 | \param startp Start vector with one element for each dimension to \ref |
---|
| 402 | specify_hyperslab. |
---|
| 403 | |
---|
| 404 | \param countp Count vector with one element for each dimension to \ref |
---|
| 405 | specify_hyperslab. |
---|
| 406 | |
---|
| 407 | \param ip Pointer where the data will be copied. Memory must be |
---|
| 408 | allocated by the user before this function is called. |
---|
| 409 | |
---|
| 410 | \returns ::NC_NOERR No error. |
---|
| 411 | \returns ::NC_ENOTVAR Variable not found. |
---|
| 412 | \returns ::NC_EINVALCOORDS Index exceeds dimension bound. |
---|
| 413 | \returns ::NC_EEDGE Start+count exceeds dimension bound. |
---|
| 414 | \returns ::NC_ERANGE One or more of the values are out of range. |
---|
| 415 | \returns ::NC_EINDEFINE Operation not allowed in define mode. |
---|
| 416 | \returns ::NC_EBADID Bad ncid. |
---|
| 417 | |
---|
| 418 | \section Example |
---|
| 419 | |
---|
| 420 | Here is an example using nc_get_vara_double() to read all the values of |
---|
| 421 | the variable named rh from an existing netCDF dataset named |
---|
| 422 | foo.nc. For simplicity in this example, we assume that we know that rh |
---|
| 423 | is dimensioned with time, lat, and lon, and that there are three time |
---|
| 424 | values, five lat values, and ten lon values. |
---|
| 425 | |
---|
| 426 | \code |
---|
| 427 | #include <netcdf.h> |
---|
| 428 | ... |
---|
| 429 | #define TIMES 3 |
---|
| 430 | #define LATS 5 |
---|
| 431 | #define LONS 10 |
---|
| 432 | int status; |
---|
| 433 | int ncid; |
---|
| 434 | int rh_id; |
---|
| 435 | static size_t start[] = {0, 0, 0}; |
---|
| 436 | static size_t count[] = {TIMES, LATS, LONS}; |
---|
| 437 | double rh_vals[TIMES*LATS*LONS]; |
---|
| 438 | ... |
---|
| 439 | status = nc_open("foo.nc", NC_NOWRITE, &ncid); |
---|
| 440 | if (status != NC_NOERR) handle_error(status); |
---|
| 441 | ... |
---|
| 442 | status = nc_inq_varid (ncid, "rh", &rh_id); |
---|
| 443 | if (status != NC_NOERR) handle_error(status); |
---|
| 444 | ... |
---|
| 445 | status = nc_get_vara_double(ncid, rh_id, start, count, rh_vals); |
---|
| 446 | if (status != NC_NOERR) handle_error(status); |
---|
| 447 | \endcode |
---|
| 448 | */ |
---|
| 449 | /**@{*/ |
---|
| 450 | int |
---|
| 451 | nc_get_vara(int ncid, int varid, const size_t *startp, |
---|
| 452 | const size_t *countp, void *ip) |
---|
| 453 | { |
---|
| 454 | NC* ncp = NULL; |
---|
| 455 | nc_type xtype = NC_NAT; |
---|
| 456 | int stat = NC_check_id(ncid, &ncp); |
---|
| 457 | if(stat != NC_NOERR) return stat; |
---|
| 458 | stat = nc_inq_vartype(ncid, varid, &xtype); |
---|
| 459 | if(stat != NC_NOERR) return stat; |
---|
| 460 | return NC_get_vara(ncid, varid, startp, countp, ip, xtype); |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | int |
---|
| 464 | nc_get_vara_text(int ncid, int varid, const size_t *startp, |
---|
| 465 | const size_t *countp, char *ip) |
---|
| 466 | { |
---|
| 467 | NC* ncp; |
---|
| 468 | int stat = NC_check_id(ncid, &ncp); |
---|
| 469 | if(stat != NC_NOERR) return stat; |
---|
| 470 | return NC_get_vara(ncid, varid, startp, countp, |
---|
| 471 | (void *)ip, NC_CHAR); |
---|
| 472 | } |
---|
| 473 | |
---|
| 474 | int |
---|
| 475 | nc_get_vara_schar(int ncid, int varid, const size_t *startp, |
---|
| 476 | const size_t *countp, signed char *ip) |
---|
| 477 | { |
---|
| 478 | NC* ncp; |
---|
| 479 | int stat = NC_check_id(ncid, &ncp); |
---|
| 480 | if(stat != NC_NOERR) return stat; |
---|
| 481 | return NC_get_vara(ncid, varid, startp, countp, |
---|
| 482 | (void *)ip, NC_BYTE); |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | int |
---|
| 486 | nc_get_vara_uchar(int ncid, int varid, const size_t *startp, |
---|
| 487 | const size_t *countp, unsigned char *ip) |
---|
| 488 | { |
---|
| 489 | NC* ncp; |
---|
| 490 | int stat = NC_check_id(ncid, &ncp); |
---|
| 491 | if(stat != NC_NOERR) return stat; |
---|
| 492 | return NC_get_vara(ncid, varid, startp, countp, |
---|
| 493 | (void *)ip, T_uchar); |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | int |
---|
| 497 | nc_get_vara_short(int ncid, int varid, const size_t *startp, |
---|
| 498 | const size_t *countp, short *ip) |
---|
| 499 | { |
---|
| 500 | NC* ncp; |
---|
| 501 | int stat = NC_check_id(ncid, &ncp); |
---|
| 502 | if(stat != NC_NOERR) return stat; |
---|
| 503 | return NC_get_vara(ncid, varid, startp, countp, |
---|
| 504 | (void *)ip, NC_SHORT); |
---|
| 505 | } |
---|
| 506 | |
---|
| 507 | int |
---|
| 508 | nc_get_vara_int(int ncid, int varid, |
---|
| 509 | const size_t *startp, const size_t *countp, int *ip) |
---|
| 510 | { |
---|
| 511 | NC* ncp; |
---|
| 512 | int stat = NC_check_id(ncid, &ncp); |
---|
| 513 | if(stat != NC_NOERR) return stat; |
---|
| 514 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_INT); |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | int |
---|
| 518 | nc_get_vara_long(int ncid, int varid, |
---|
| 519 | const size_t *startp, const size_t *countp, long *ip) |
---|
| 520 | { |
---|
| 521 | NC* ncp; |
---|
| 522 | int stat = NC_check_id(ncid, &ncp); |
---|
| 523 | if(stat != NC_NOERR) return stat; |
---|
| 524 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_long); |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | int |
---|
| 528 | nc_get_vara_float(int ncid, int varid, |
---|
| 529 | const size_t *startp, const size_t *countp, float *ip) |
---|
| 530 | { |
---|
| 531 | NC* ncp; |
---|
| 532 | int stat = NC_check_id(ncid, &ncp); |
---|
| 533 | if(stat != NC_NOERR) return stat; |
---|
| 534 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_float); |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | |
---|
| 538 | int |
---|
| 539 | nc_get_vara_double(int ncid, int varid, const size_t *startp, |
---|
| 540 | const size_t *countp, double *ip) |
---|
| 541 | { |
---|
| 542 | NC* ncp; |
---|
| 543 | int stat = NC_check_id(ncid, &ncp); |
---|
| 544 | if(stat != NC_NOERR) return stat; |
---|
| 545 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_double); |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | int |
---|
| 549 | nc_get_vara_ubyte(int ncid, int varid, |
---|
| 550 | const size_t *startp, const size_t *countp, unsigned char *ip) |
---|
| 551 | { |
---|
| 552 | NC* ncp; |
---|
| 553 | int stat = NC_check_id(ncid, &ncp); |
---|
| 554 | if(stat != NC_NOERR) return stat; |
---|
| 555 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ubyte); |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | int |
---|
| 559 | nc_get_vara_ushort(int ncid, int varid, |
---|
| 560 | const size_t *startp, const size_t *countp, unsigned short *ip) |
---|
| 561 | { |
---|
| 562 | NC* ncp; |
---|
| 563 | int stat = NC_check_id(ncid, &ncp); |
---|
| 564 | if(stat != NC_NOERR) return stat; |
---|
| 565 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_ushort); |
---|
| 566 | } |
---|
| 567 | |
---|
| 568 | int |
---|
| 569 | nc_get_vara_uint(int ncid, int varid, |
---|
| 570 | const size_t *startp, const size_t *countp, unsigned int *ip) |
---|
| 571 | { |
---|
| 572 | NC* ncp; |
---|
| 573 | int stat = NC_check_id(ncid, &ncp); |
---|
| 574 | if(stat != NC_NOERR) return stat; |
---|
| 575 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_uint); |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | int |
---|
| 579 | nc_get_vara_longlong(int ncid, int varid, |
---|
| 580 | const size_t *startp, const size_t *countp, long long *ip) |
---|
| 581 | { |
---|
| 582 | NC* ncp; |
---|
| 583 | int stat = NC_check_id(ncid, &ncp); |
---|
| 584 | if(stat != NC_NOERR) return stat; |
---|
| 585 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,T_longlong); |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | int |
---|
| 589 | nc_get_vara_ulonglong(int ncid, int varid, |
---|
| 590 | const size_t *startp, const size_t *countp, unsigned long long *ip) |
---|
| 591 | { |
---|
| 592 | NC* ncp; |
---|
| 593 | int stat = NC_check_id(ncid, &ncp); |
---|
| 594 | if(stat != NC_NOERR) return stat; |
---|
| 595 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_UINT64); |
---|
| 596 | } |
---|
| 597 | |
---|
| 598 | #ifdef USE_NETCDF4 |
---|
| 599 | int |
---|
| 600 | nc_get_vara_string(int ncid, int varid, |
---|
| 601 | const size_t *startp, const size_t *countp, char* *ip) |
---|
| 602 | { |
---|
| 603 | NC* ncp; |
---|
| 604 | int stat = NC_check_id(ncid, &ncp); |
---|
| 605 | if(stat != NC_NOERR) return stat; |
---|
| 606 | return NC_get_vara(ncid,varid,startp,countp, (void *)ip,NC_STRING); |
---|
| 607 | } |
---|
| 608 | |
---|
| 609 | #endif /*USE_NETCDF4*/ |
---|
| 610 | /**@}*/ |
---|
| 611 | |
---|
| 612 | /** \ingroup variables |
---|
| 613 | Read a single datum from a variable. |
---|
| 614 | |
---|
| 615 | Inputs are the netCDF ID, the variable ID, a multidimensional index |
---|
| 616 | that specifies which value to get, and the address of a location into |
---|
| 617 | which the data value will be read. The value is converted from the |
---|
| 618 | external data type of the variable, if necessary. |
---|
| 619 | |
---|
| 620 | The nc_get_var1() function will read a variable of any type, including |
---|
| 621 | user defined type. For this function, the type of the data in memory |
---|
| 622 | must match the type of the variable - no data conversion is done. |
---|
| 623 | |
---|
| 624 | Other nc_get_var1_ functions will convert data to the desired output |
---|
| 625 | type as needed. |
---|
| 626 | |
---|
| 627 | \param ncid NetCDF or group ID, from a previous call to nc_open(), |
---|
| 628 | nc_create(), nc_def_grp(), or associated inquiry functions such as |
---|
| 629 | nc_inq_ncid(). |
---|
| 630 | |
---|
| 631 | \param varid Variable ID |
---|
| 632 | |
---|
| 633 | \param indexp Index vector with one element for each dimension. |
---|
| 634 | |
---|
| 635 | \param ip Pointer where the data will be copied. Memory must be |
---|
| 636 | allocated by the user before this function is called. |
---|
| 637 | |
---|
| 638 | \returns ::NC_NOERR No error. |
---|
| 639 | \returns ::NC_ENOTVAR Variable not found. |
---|
| 640 | \returns ::NC_EINVALCOORDS Index exceeds dimension bound. |
---|
| 641 | \returns ::NC_ERANGE One or more of the values are out of range. |
---|
| 642 | \returns ::NC_EINDEFINE Operation not allowed in define mode. |
---|
| 643 | \returns ::NC_EBADID Bad ncid. |
---|
| 644 | */ |
---|
| 645 | /** \{ */ |
---|
| 646 | int |
---|
| 647 | nc_get_var1(int ncid, int varid, const size_t *indexp, void *ip) |
---|
| 648 | { |
---|
| 649 | return NC_get_var1(ncid, varid, indexp, ip, NC_NAT); |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | int |
---|
| 653 | nc_get_var1_text(int ncid, int varid, const size_t *indexp, char *ip) |
---|
| 654 | { |
---|
| 655 | NC* ncp; |
---|
| 656 | int stat = NC_check_id(ncid, &ncp); |
---|
| 657 | if(stat != NC_NOERR) return stat; |
---|
| 658 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_CHAR); |
---|
| 659 | } |
---|
| 660 | |
---|
| 661 | int |
---|
| 662 | nc_get_var1_schar(int ncid, int varid, const size_t *indexp, signed char *ip) |
---|
| 663 | { |
---|
| 664 | NC* ncp; |
---|
| 665 | int stat = NC_check_id(ncid, &ncp); |
---|
| 666 | if(stat != NC_NOERR) return stat; |
---|
| 667 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_BYTE); |
---|
| 668 | } |
---|
| 669 | |
---|
| 670 | int |
---|
| 671 | nc_get_var1_uchar(int ncid, int varid, const size_t *indexp, unsigned char *ip) |
---|
| 672 | { |
---|
| 673 | NC* ncp; |
---|
| 674 | int stat = NC_check_id(ncid, &ncp); |
---|
| 675 | if(stat != NC_NOERR) return stat; |
---|
| 676 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE); |
---|
| 677 | } |
---|
| 678 | |
---|
| 679 | int |
---|
| 680 | nc_get_var1_short(int ncid, int varid, const size_t *indexp, short *ip) |
---|
| 681 | { |
---|
| 682 | NC* ncp; |
---|
| 683 | int stat = NC_check_id(ncid, &ncp); |
---|
| 684 | if(stat != NC_NOERR) return stat; |
---|
| 685 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_SHORT); |
---|
| 686 | } |
---|
| 687 | |
---|
| 688 | int |
---|
| 689 | nc_get_var1_int(int ncid, int varid, const size_t *indexp, int *ip) |
---|
| 690 | { |
---|
| 691 | NC* ncp; |
---|
| 692 | int stat = NC_check_id(ncid, &ncp); |
---|
| 693 | if(stat != NC_NOERR) return stat; |
---|
| 694 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT); |
---|
| 695 | } |
---|
| 696 | |
---|
| 697 | int |
---|
| 698 | nc_get_var1_long(int ncid, int varid, const size_t *indexp, |
---|
| 699 | long *ip) |
---|
| 700 | { |
---|
| 701 | NC* ncp; |
---|
| 702 | int stat = NC_check_id(ncid, &ncp); |
---|
| 703 | if(stat != NC_NOERR) return stat; |
---|
| 704 | return NC_get_var1(ncid, varid, indexp, (void *)ip, longtype); |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | int |
---|
| 708 | nc_get_var1_float(int ncid, int varid, const size_t *indexp, |
---|
| 709 | float *ip) |
---|
| 710 | { |
---|
| 711 | NC* ncp; |
---|
| 712 | int stat = NC_check_id(ncid, &ncp); |
---|
| 713 | if(stat != NC_NOERR) return stat; |
---|
| 714 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_FLOAT); |
---|
| 715 | } |
---|
| 716 | |
---|
| 717 | int |
---|
| 718 | nc_get_var1_double(int ncid, int varid, const size_t *indexp, |
---|
| 719 | double *ip) |
---|
| 720 | { |
---|
| 721 | NC* ncp; |
---|
| 722 | int stat = NC_check_id(ncid, &ncp); |
---|
| 723 | if(stat != NC_NOERR) return stat; |
---|
| 724 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_DOUBLE); |
---|
| 725 | } |
---|
| 726 | |
---|
| 727 | int |
---|
| 728 | nc_get_var1_ubyte(int ncid, int varid, const size_t *indexp, |
---|
| 729 | unsigned char *ip) |
---|
| 730 | { |
---|
| 731 | NC* ncp; |
---|
| 732 | int stat = NC_check_id(ncid, &ncp); |
---|
| 733 | if(stat != NC_NOERR) return stat; |
---|
| 734 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UBYTE); |
---|
| 735 | } |
---|
| 736 | |
---|
| 737 | int |
---|
| 738 | nc_get_var1_ushort(int ncid, int varid, const size_t *indexp, |
---|
| 739 | unsigned short *ip) |
---|
| 740 | { |
---|
| 741 | NC* ncp; |
---|
| 742 | int stat = NC_check_id(ncid, &ncp); |
---|
| 743 | if(stat != NC_NOERR) return stat; |
---|
| 744 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_USHORT); |
---|
| 745 | } |
---|
| 746 | |
---|
| 747 | int |
---|
| 748 | nc_get_var1_uint(int ncid, int varid, const size_t *indexp, |
---|
| 749 | unsigned int *ip) |
---|
| 750 | { |
---|
| 751 | NC* ncp; |
---|
| 752 | int stat = NC_check_id(ncid, &ncp); |
---|
| 753 | if(stat != NC_NOERR) return stat; |
---|
| 754 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT); |
---|
| 755 | } |
---|
| 756 | |
---|
| 757 | int |
---|
| 758 | nc_get_var1_longlong(int ncid, int varid, const size_t *indexp, |
---|
| 759 | long long *ip) |
---|
| 760 | { |
---|
| 761 | NC* ncp; |
---|
| 762 | int stat = NC_check_id(ncid, &ncp); |
---|
| 763 | if(stat != NC_NOERR) return stat; |
---|
| 764 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_INT64); |
---|
| 765 | } |
---|
| 766 | |
---|
| 767 | int |
---|
| 768 | nc_get_var1_ulonglong(int ncid, int varid, const size_t *indexp, |
---|
| 769 | unsigned long long *ip) |
---|
| 770 | { |
---|
| 771 | NC* ncp; |
---|
| 772 | int stat = NC_check_id(ncid, &ncp); |
---|
| 773 | if(stat != NC_NOERR) return stat; |
---|
| 774 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_UINT64); |
---|
| 775 | } |
---|
| 776 | |
---|
| 777 | #ifdef USE_NETCDF4 |
---|
| 778 | int |
---|
| 779 | nc_get_var1_string(int ncid, int varid, const size_t *indexp, char* *ip) |
---|
| 780 | { |
---|
| 781 | NC* ncp; |
---|
| 782 | int stat = NC_check_id(ncid, &ncp); |
---|
| 783 | if(stat != NC_NOERR) return stat; |
---|
| 784 | return NC_get_var1(ncid, varid, indexp, (void *)ip, NC_STRING); |
---|
| 785 | } |
---|
| 786 | #endif /*USE_NETCDF4*/ |
---|
| 787 | /** \} */ |
---|
| 788 | |
---|
| 789 | /** \ingroup variables |
---|
| 790 | Read an entire variable in one call. |
---|
| 791 | |
---|
| 792 | This function will read all the values from a netCDF variable of an |
---|
| 793 | open netCDF dataset. |
---|
| 794 | |
---|
| 795 | This is the simplest interface to use for reading the value of a |
---|
| 796 | scalar variable or when all the values of a multidimensional variable |
---|
| 797 | can be read at once. The values are read into consecutive locations |
---|
| 798 | with the last dimension varying fastest. The netCDF dataset must be in |
---|
| 799 | data mode. |
---|
| 800 | |
---|
| 801 | Take care when using this function with record variables (variables |
---|
| 802 | that use the ::NC_UNLIMITED dimension). If you try to read all the |
---|
| 803 | values of a record variable into an array but there are more records |
---|
| 804 | in the file than you assume, more data will be read than you expect, |
---|
| 805 | which may cause a segmentation violation. To avoid such problems, it |
---|
| 806 | is better to use the nc_get_vara interfaces for variables that use the |
---|
| 807 | ::NC_UNLIMITED dimension. |
---|
| 808 | |
---|
| 809 | The functions for types ubyte, ushort, uint, longlong, ulonglong, and |
---|
| 810 | string are only available for netCDF-4/HDF5 files. |
---|
| 811 | |
---|
| 812 | The nc_get_var() function will read a variable of any type, including |
---|
| 813 | user defined type. For this function, the type of the data in memory |
---|
| 814 | must match the type of the variable - no data conversion is done. |
---|
| 815 | |
---|
| 816 | \param ncid NetCDF or group ID, from a previous call to nc_open(), |
---|
| 817 | nc_create(), nc_def_grp(), or associated inquiry functions such as |
---|
| 818 | nc_inq_ncid(). |
---|
| 819 | |
---|
| 820 | \param varid Variable ID |
---|
| 821 | |
---|
| 822 | \param ip Pointer where the data will be copied. Memory must be |
---|
| 823 | allocated by the user before this function is called. |
---|
| 824 | |
---|
| 825 | \returns ::NC_NOERR No error. |
---|
| 826 | \returns ::NC_ENOTVAR Variable not found. |
---|
| 827 | \returns ::NC_ERANGE One or more of the values are out of range. |
---|
| 828 | \returns ::NC_EINDEFINE Operation not allowed in define mode. |
---|
| 829 | \returns ::NC_EBADID Bad ncid. |
---|
| 830 | */ |
---|
| 831 | /** \{ */ |
---|
| 832 | int |
---|
| 833 | nc_get_var(int ncid, int varid, void *ip) |
---|
| 834 | { |
---|
| 835 | return NC_get_var(ncid, varid, ip, NC_NAT); |
---|
| 836 | } |
---|
| 837 | |
---|
| 838 | int |
---|
| 839 | nc_get_var_text(int ncid, int varid, char *ip) |
---|
| 840 | { |
---|
| 841 | NC *ncp; |
---|
| 842 | int stat = NC_check_id(ncid, &ncp); |
---|
| 843 | if(stat != NC_NOERR) return stat; |
---|
| 844 | return NC_get_var(ncid, varid, (void *)ip, NC_CHAR); |
---|
| 845 | } |
---|
| 846 | |
---|
| 847 | int |
---|
| 848 | nc_get_var_schar(int ncid, int varid, signed char *ip) |
---|
| 849 | { |
---|
| 850 | NC *ncp; |
---|
| 851 | int stat = NC_check_id(ncid, &ncp); |
---|
| 852 | if(stat != NC_NOERR) return stat; |
---|
| 853 | return NC_get_var(ncid, varid, (void *)ip, NC_BYTE); |
---|
| 854 | } |
---|
| 855 | |
---|
| 856 | int |
---|
| 857 | nc_get_var_uchar(int ncid, int varid, unsigned char *ip) |
---|
| 858 | { |
---|
| 859 | NC *ncp; |
---|
| 860 | int stat = NC_check_id(ncid, &ncp); |
---|
| 861 | if(stat != NC_NOERR) return stat; |
---|
| 862 | return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE); |
---|
| 863 | } |
---|
| 864 | |
---|
| 865 | int |
---|
| 866 | nc_get_var_short(int ncid, int varid, short *ip) |
---|
| 867 | { |
---|
| 868 | NC* ncp; |
---|
| 869 | int stat = NC_check_id(ncid, &ncp); |
---|
| 870 | if(stat != NC_NOERR) return stat; |
---|
| 871 | return NC_get_var(ncid, varid, (void *)ip, NC_SHORT); |
---|
| 872 | } |
---|
| 873 | |
---|
| 874 | int |
---|
| 875 | nc_get_var_int(int ncid, int varid, int *ip) |
---|
| 876 | { |
---|
| 877 | NC* ncp; |
---|
| 878 | int stat = NC_check_id(ncid, &ncp); |
---|
| 879 | if(stat != NC_NOERR) return stat; |
---|
| 880 | return NC_get_var(ncid,varid, (void *)ip, NC_INT); |
---|
| 881 | } |
---|
| 882 | |
---|
| 883 | int |
---|
| 884 | nc_get_var_long(int ncid, int varid, long *ip) |
---|
| 885 | { |
---|
| 886 | NC* ncp; |
---|
| 887 | int stat = NC_check_id(ncid, &ncp); |
---|
| 888 | if(stat != NC_NOERR) return stat; |
---|
| 889 | return NC_get_var(ncid,varid, (void *)ip, longtype); |
---|
| 890 | } |
---|
| 891 | |
---|
| 892 | int |
---|
| 893 | nc_get_var_float(int ncid, int varid, float *ip) |
---|
| 894 | { |
---|
| 895 | NC* ncp; |
---|
| 896 | int stat = NC_check_id(ncid, &ncp); |
---|
| 897 | if(stat != NC_NOERR) return stat; |
---|
| 898 | return NC_get_var(ncid,varid, (void *)ip, NC_FLOAT); |
---|
| 899 | } |
---|
| 900 | |
---|
| 901 | int |
---|
| 902 | nc_get_var_double(int ncid, int varid, double *ip) |
---|
| 903 | { |
---|
| 904 | NC* ncp; |
---|
| 905 | int stat = NC_check_id(ncid, &ncp); |
---|
| 906 | if(stat != NC_NOERR) return stat; |
---|
| 907 | return NC_get_var(ncid,varid, (void *)ip, NC_DOUBLE); |
---|
| 908 | } |
---|
| 909 | |
---|
| 910 | int |
---|
| 911 | nc_get_var_ubyte(int ncid, int varid, unsigned char *ip) |
---|
| 912 | { |
---|
| 913 | NC* ncp; |
---|
| 914 | int stat = NC_check_id(ncid, &ncp); |
---|
| 915 | if(stat != NC_NOERR) return stat; |
---|
| 916 | return NC_get_var(ncid,varid, (void *)ip, NC_UBYTE); |
---|
| 917 | } |
---|
| 918 | |
---|
| 919 | int |
---|
| 920 | nc_get_var_ushort(int ncid, int varid, unsigned short *ip) |
---|
| 921 | { |
---|
| 922 | NC* ncp; |
---|
| 923 | int stat = NC_check_id(ncid, &ncp); |
---|
| 924 | if(stat != NC_NOERR) return stat; |
---|
| 925 | return NC_get_var(ncid,varid, (void *)ip, NC_USHORT); |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | int |
---|
| 929 | nc_get_var_uint(int ncid, int varid, unsigned int *ip) |
---|
| 930 | { |
---|
| 931 | NC* ncp; |
---|
| 932 | int stat = NC_check_id(ncid, &ncp); |
---|
| 933 | if(stat != NC_NOERR) return stat; |
---|
| 934 | return NC_get_var(ncid,varid, (void *)ip, NC_UINT); |
---|
| 935 | } |
---|
| 936 | |
---|
| 937 | int |
---|
| 938 | nc_get_var_longlong(int ncid, int varid, long long *ip) |
---|
| 939 | { |
---|
| 940 | NC* ncp; |
---|
| 941 | int stat = NC_check_id(ncid, &ncp); |
---|
| 942 | if(stat != NC_NOERR) return stat; |
---|
| 943 | return NC_get_var(ncid,varid, (void *)ip, NC_INT64); |
---|
| 944 | } |
---|
| 945 | |
---|
| 946 | int |
---|
| 947 | nc_get_var_ulonglong(int ncid, int varid, unsigned long long *ip) |
---|
| 948 | { |
---|
| 949 | NC* ncp; |
---|
| 950 | int stat = NC_check_id(ncid, &ncp); |
---|
| 951 | if(stat != NC_NOERR) return stat; |
---|
| 952 | return NC_get_var(ncid,varid, (void *)ip,NC_UINT64); |
---|
| 953 | } |
---|
| 954 | |
---|
| 955 | #ifdef USE_NETCDF4 |
---|
| 956 | int |
---|
| 957 | nc_get_var_string(int ncid, int varid, char* *ip) |
---|
| 958 | { |
---|
| 959 | NC* ncp; |
---|
| 960 | int stat = NC_check_id(ncid, &ncp); |
---|
| 961 | if(stat != NC_NOERR) return stat; |
---|
| 962 | return NC_get_var(ncid,varid, (void *)ip,NC_STRING); |
---|
| 963 | } |
---|
| 964 | #endif /*USE_NETCDF4*/ |
---|
| 965 | /** \} */ |
---|
| 966 | |
---|
| 967 | /** \ingroup variables |
---|
| 968 | Read a strided array from a variable. |
---|
| 969 | |
---|
| 970 | This function reads a subsampled (strided) array section of values |
---|
| 971 | from a netCDF variable of an open netCDF dataset. The subsampled array |
---|
| 972 | section is specified by giving a corner, a vector of edge lengths, and |
---|
| 973 | a stride vector. The values are read with the last dimension of the |
---|
| 974 | netCDF variable varying fastest. The netCDF dataset must be in data |
---|
| 975 | mode. |
---|
| 976 | |
---|
| 977 | The nc_get_vars() function will read a variable of any type, including |
---|
| 978 | user defined type. For this function, the type of the data in memory |
---|
| 979 | must match the type of the variable - no data conversion is done. |
---|
| 980 | |
---|
| 981 | \param ncid NetCDF or group ID, from a previous call to nc_open(), |
---|
| 982 | nc_create(), nc_def_grp(), or associated inquiry functions such as |
---|
| 983 | nc_inq_ncid(). |
---|
| 984 | |
---|
| 985 | \param varid Variable ID |
---|
| 986 | |
---|
| 987 | \param startp Start vector with one element for each dimension to \ref |
---|
| 988 | specify_hyperslab. |
---|
| 989 | |
---|
| 990 | \param countp Count vector with one element for each dimension to \ref |
---|
| 991 | specify_hyperslab. |
---|
| 992 | |
---|
| 993 | \param stridep Stride vector with one element for each dimension to |
---|
| 994 | \ref specify_hyperslab. |
---|
| 995 | |
---|
| 996 | \param ip Pointer where the data will be copied. Memory must be |
---|
| 997 | allocated by the user before this function is called. |
---|
| 998 | |
---|
| 999 | \returns ::NC_NOERR No error. |
---|
| 1000 | \returns ::NC_ENOTVAR Variable not found. |
---|
| 1001 | \returns ::NC_EINVALCOORDS Index exceeds dimension bound. |
---|
| 1002 | \returns ::NC_ERANGE One or more of the values are out of range. |
---|
| 1003 | \returns ::NC_EINDEFINE Operation not allowed in define mode. |
---|
| 1004 | \returns ::NC_EBADID Bad ncid. |
---|
| 1005 | */ |
---|
| 1006 | /** \{ */ |
---|
| 1007 | int |
---|
| 1008 | nc_get_vars (int ncid, int varid, const size_t * startp, |
---|
| 1009 | const size_t * countp, const ptrdiff_t * stridep, |
---|
| 1010 | void *ip) |
---|
| 1011 | { |
---|
| 1012 | NC* ncp; |
---|
| 1013 | int stat = NC_NOERR; |
---|
| 1014 | |
---|
| 1015 | if ((stat = NC_check_id(ncid, &ncp))) |
---|
| 1016 | return stat; |
---|
| 1017 | return ncp->dispatch->get_vars(ncid, varid, startp, countp, stridep, |
---|
| 1018 | ip, NC_NAT); |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | int |
---|
| 1022 | nc_get_vars_text(int ncid, int varid, const size_t *startp, |
---|
| 1023 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1024 | char *ip) |
---|
| 1025 | { |
---|
| 1026 | NC* ncp; |
---|
| 1027 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1028 | if(stat != NC_NOERR) return stat; |
---|
| 1029 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1030 | (void *)ip, NC_CHAR); |
---|
| 1031 | } |
---|
| 1032 | |
---|
| 1033 | int |
---|
| 1034 | nc_get_vars_schar(int ncid, int varid, const size_t *startp, |
---|
| 1035 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1036 | signed char *ip) |
---|
| 1037 | { |
---|
| 1038 | NC* ncp; |
---|
| 1039 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1040 | if(stat != NC_NOERR) return stat; |
---|
| 1041 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1042 | (void *)ip, NC_BYTE); |
---|
| 1043 | } |
---|
| 1044 | |
---|
| 1045 | int |
---|
| 1046 | nc_get_vars_uchar(int ncid, int varid, const size_t *startp, |
---|
| 1047 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1048 | unsigned char *ip) |
---|
| 1049 | { |
---|
| 1050 | NC* ncp; |
---|
| 1051 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1052 | if(stat != NC_NOERR) return stat; |
---|
| 1053 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1054 | (void *)ip, T_uchar); |
---|
| 1055 | } |
---|
| 1056 | |
---|
| 1057 | int |
---|
| 1058 | nc_get_vars_short(int ncid, int varid, const size_t *startp, |
---|
| 1059 | const size_t *countp, const ptrdiff_t *stridep, |
---|
| 1060 | short *ip) |
---|
| 1061 | { |
---|
| 1062 | NC* ncp; |
---|
| 1063 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1064 | if(stat != NC_NOERR) return stat; |
---|
| 1065 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1066 | (void *)ip, NC_SHORT); |
---|
| 1067 | } |
---|
| 1068 | |
---|
| 1069 | int |
---|
| 1070 | nc_get_vars_int(int ncid, int varid, const size_t *startp, |
---|
| 1071 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1072 | int *ip) |
---|
| 1073 | { |
---|
| 1074 | NC* ncp; |
---|
| 1075 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1076 | if(stat != NC_NOERR) return stat; |
---|
| 1077 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1078 | (void *)ip, NC_INT); |
---|
| 1079 | } |
---|
| 1080 | |
---|
| 1081 | int |
---|
| 1082 | nc_get_vars_long(int ncid, int varid, const size_t *startp, |
---|
| 1083 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1084 | long *ip) |
---|
| 1085 | { |
---|
| 1086 | NC* ncp; |
---|
| 1087 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1088 | if(stat != NC_NOERR) return stat; |
---|
| 1089 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1090 | (void *)ip, T_long); |
---|
| 1091 | } |
---|
| 1092 | |
---|
| 1093 | int |
---|
| 1094 | nc_get_vars_float(int ncid, int varid, const size_t *startp, |
---|
| 1095 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1096 | float *ip) |
---|
| 1097 | { |
---|
| 1098 | NC* ncp; |
---|
| 1099 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1100 | if(stat != NC_NOERR) return stat; |
---|
| 1101 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1102 | (void *)ip, T_float); |
---|
| 1103 | } |
---|
| 1104 | |
---|
| 1105 | int |
---|
| 1106 | nc_get_vars_double(int ncid, int varid, const size_t *startp, |
---|
| 1107 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1108 | double *ip) |
---|
| 1109 | { |
---|
| 1110 | NC* ncp; |
---|
| 1111 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1112 | if(stat != NC_NOERR) return stat; |
---|
| 1113 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1114 | (void *)ip, T_double); |
---|
| 1115 | } |
---|
| 1116 | |
---|
| 1117 | int |
---|
| 1118 | nc_get_vars_ubyte(int ncid, int varid, const size_t *startp, |
---|
| 1119 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1120 | unsigned char *ip) |
---|
| 1121 | { |
---|
| 1122 | NC* ncp; |
---|
| 1123 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1124 | if(stat != NC_NOERR) return stat; |
---|
| 1125 | return NC_get_vars(ncid,varid, startp, countp, stridep, |
---|
| 1126 | (void *)ip, T_ubyte); |
---|
| 1127 | } |
---|
| 1128 | |
---|
| 1129 | int |
---|
| 1130 | nc_get_vars_ushort(int ncid, int varid, const size_t *startp, |
---|
| 1131 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1132 | unsigned short *ip) |
---|
| 1133 | { |
---|
| 1134 | NC* ncp; |
---|
| 1135 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1136 | if(stat != NC_NOERR) return stat; |
---|
| 1137 | return NC_get_vars(ncid,varid,startp,countp, stridep, |
---|
| 1138 | (void *)ip, T_ushort); |
---|
| 1139 | } |
---|
| 1140 | |
---|
| 1141 | int |
---|
| 1142 | nc_get_vars_uint(int ncid, int varid, const size_t *startp, |
---|
| 1143 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1144 | unsigned int *ip) |
---|
| 1145 | { |
---|
| 1146 | NC* ncp; |
---|
| 1147 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1148 | if(stat != NC_NOERR) return stat; |
---|
| 1149 | return NC_get_vars(ncid,varid,startp, countp, stridep, |
---|
| 1150 | (void *)ip, T_uint); |
---|
| 1151 | } |
---|
| 1152 | |
---|
| 1153 | int |
---|
| 1154 | nc_get_vars_longlong(int ncid, int varid, const size_t *startp, |
---|
| 1155 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1156 | long long *ip) |
---|
| 1157 | { |
---|
| 1158 | NC* ncp; |
---|
| 1159 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1160 | if(stat != NC_NOERR) return stat; |
---|
| 1161 | return NC_get_vars(ncid, varid, startp, countp, stridep, |
---|
| 1162 | (void *)ip, T_longlong); |
---|
| 1163 | } |
---|
| 1164 | |
---|
| 1165 | int |
---|
| 1166 | nc_get_vars_ulonglong(int ncid, int varid, const size_t *startp, |
---|
| 1167 | const size_t *countp, const ptrdiff_t * stridep, |
---|
| 1168 | unsigned long long *ip) |
---|
| 1169 | { |
---|
| 1170 | NC* ncp; |
---|
| 1171 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1172 | if(stat != NC_NOERR) return stat; |
---|
| 1173 | return NC_get_vars(ncid, varid, startp, countp, stridep, |
---|
| 1174 | (void *)ip, NC_UINT64); |
---|
| 1175 | } |
---|
| 1176 | |
---|
| 1177 | #ifdef USE_NETCDF4 |
---|
| 1178 | int |
---|
| 1179 | nc_get_vars_string(int ncid, int varid, |
---|
| 1180 | const size_t *startp, const size_t *countp, |
---|
| 1181 | const ptrdiff_t * stridep, |
---|
| 1182 | char* *ip) |
---|
| 1183 | { |
---|
| 1184 | NC* ncp; |
---|
| 1185 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1186 | if(stat != NC_NOERR) return stat; |
---|
| 1187 | return NC_get_vars(ncid, varid, startp, countp, stridep, |
---|
| 1188 | (void *)ip, NC_STRING); |
---|
| 1189 | } |
---|
| 1190 | #endif /*USE_NETCDF4*/ |
---|
| 1191 | /** \} */ |
---|
| 1192 | |
---|
| 1193 | /** \ingroup variables |
---|
| 1194 | Read a mapped array from a variable. |
---|
| 1195 | |
---|
| 1196 | The nc_get_varm_ type family of functions reads a mapped array section |
---|
| 1197 | of values from a netCDF variable of an open netCDF dataset. The mapped |
---|
| 1198 | array section is specified by giving a corner, a vector of edge |
---|
| 1199 | lengths, a stride vector, and an index mapping vector. The index |
---|
| 1200 | mapping vector is a vector of integers that specifies the mapping |
---|
| 1201 | between the dimensions of a netCDF variable and the in-memory |
---|
| 1202 | structure of the internal data array. No assumptions are made about |
---|
| 1203 | the ordering or length of the dimensions of the data array. The netCDF |
---|
| 1204 | dataset must be in data mode. |
---|
| 1205 | |
---|
| 1206 | The functions for types ubyte, ushort, uint, longlong, ulonglong, and |
---|
| 1207 | string are only available for netCDF-4/HDF5 files. |
---|
| 1208 | |
---|
| 1209 | The nc_get_varm() function will read a variable of any type, including |
---|
| 1210 | user defined type. For this function, the type of the data in memory |
---|
| 1211 | must match the type of the variable - no data conversion is done. |
---|
| 1212 | |
---|
| 1213 | \param ncid NetCDF or group ID, from a previous call to nc_open(), |
---|
| 1214 | nc_create(), nc_def_grp(), or associated inquiry functions such as |
---|
| 1215 | nc_inq_ncid(). |
---|
| 1216 | |
---|
| 1217 | \param varid Variable ID |
---|
| 1218 | |
---|
| 1219 | \param startp Start vector with one element for each dimension to \ref |
---|
| 1220 | specify_hyperslab. |
---|
| 1221 | |
---|
| 1222 | \param countp Count vector with one element for each dimension to \ref |
---|
| 1223 | specify_hyperslab. |
---|
| 1224 | |
---|
| 1225 | \param stridep Stride vector with one element for each dimension to |
---|
| 1226 | \ref specify_hyperslab. |
---|
| 1227 | |
---|
| 1228 | \param imapp Mapping vector with one element for each dimension to |
---|
| 1229 | \ref specify_hyperslab. |
---|
| 1230 | |
---|
| 1231 | \param ip Pointer where the data will be copied. Memory must be |
---|
| 1232 | allocated by the user before this function is called. |
---|
| 1233 | |
---|
| 1234 | \returns ::NC_NOERR No error. |
---|
| 1235 | \returns ::NC_ENOTVAR Variable not found. |
---|
| 1236 | \returns ::NC_EINVALCOORDS Index exceeds dimension bound. |
---|
| 1237 | \returns ::NC_ERANGE One or more of the values are out of range. |
---|
| 1238 | \returns ::NC_EINDEFINE Operation not allowed in define mode. |
---|
| 1239 | \returns ::NC_EBADID Bad ncid. |
---|
| 1240 | */ |
---|
| 1241 | /** \{ */ |
---|
| 1242 | int |
---|
| 1243 | nc_get_varm(int ncid, int varid, const size_t * startp, |
---|
| 1244 | const size_t * countp, const ptrdiff_t * stridep, |
---|
| 1245 | const ptrdiff_t * imapp, void *ip) |
---|
| 1246 | { |
---|
| 1247 | NC* ncp; |
---|
| 1248 | int stat = NC_NOERR; |
---|
| 1249 | |
---|
| 1250 | if ((stat = NC_check_id(ncid, &ncp))) |
---|
| 1251 | return stat; |
---|
| 1252 | return ncp->dispatch->get_varm(ncid, varid, startp, countp, |
---|
| 1253 | stridep, imapp, ip, NC_NAT); |
---|
| 1254 | } |
---|
| 1255 | |
---|
| 1256 | int |
---|
| 1257 | nc_get_varm_schar(int ncid, int varid, |
---|
| 1258 | const size_t *startp, const size_t *countp, |
---|
| 1259 | const ptrdiff_t *stridep, |
---|
| 1260 | const ptrdiff_t *imapp, signed char *ip) |
---|
| 1261 | { |
---|
| 1262 | NC *ncp; |
---|
| 1263 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1264 | if(stat != NC_NOERR) return stat; |
---|
| 1265 | return NC_get_varm(ncid, varid, startp, countp, |
---|
| 1266 | stridep, imapp, (void *)ip, NC_BYTE); |
---|
| 1267 | } |
---|
| 1268 | |
---|
| 1269 | int |
---|
| 1270 | nc_get_varm_uchar(int ncid, int varid, |
---|
| 1271 | const size_t *startp, const size_t *countp, |
---|
| 1272 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1273 | unsigned char *ip) |
---|
| 1274 | { |
---|
| 1275 | NC *ncp; |
---|
| 1276 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1277 | if(stat != NC_NOERR) return stat; |
---|
| 1278 | return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_uchar); |
---|
| 1279 | } |
---|
| 1280 | |
---|
| 1281 | int |
---|
| 1282 | nc_get_varm_short(int ncid, int varid, const size_t *startp, |
---|
| 1283 | const size_t *countp, const ptrdiff_t *stridep, |
---|
| 1284 | const ptrdiff_t *imapp, short *ip) |
---|
| 1285 | { |
---|
| 1286 | NC *ncp; |
---|
| 1287 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1288 | if(stat != NC_NOERR) return stat; |
---|
| 1289 | return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_SHORT); |
---|
| 1290 | } |
---|
| 1291 | |
---|
| 1292 | int |
---|
| 1293 | nc_get_varm_int(int ncid, int varid, |
---|
| 1294 | const size_t *startp, const size_t *countp, |
---|
| 1295 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1296 | int *ip) |
---|
| 1297 | { |
---|
| 1298 | NC *ncp; |
---|
| 1299 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1300 | if(stat != NC_NOERR) return stat; |
---|
| 1301 | return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,NC_INT); |
---|
| 1302 | } |
---|
| 1303 | |
---|
| 1304 | int |
---|
| 1305 | nc_get_varm_long(int ncid, int varid, |
---|
| 1306 | const size_t *startp, const size_t *countp, |
---|
| 1307 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1308 | long *ip) |
---|
| 1309 | { |
---|
| 1310 | NC *ncp; |
---|
| 1311 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1312 | if(stat != NC_NOERR) return stat; |
---|
| 1313 | return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_long); |
---|
| 1314 | } |
---|
| 1315 | |
---|
| 1316 | int |
---|
| 1317 | nc_get_varm_float(int ncid, int varid, |
---|
| 1318 | const size_t *startp, const size_t *countp, |
---|
| 1319 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1320 | float *ip) |
---|
| 1321 | { |
---|
| 1322 | NC *ncp; |
---|
| 1323 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1324 | if(stat != NC_NOERR) return stat; |
---|
| 1325 | return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_float); |
---|
| 1326 | } |
---|
| 1327 | |
---|
| 1328 | int |
---|
| 1329 | nc_get_varm_double(int ncid, int varid, |
---|
| 1330 | const size_t *startp, const size_t *countp, |
---|
| 1331 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1332 | double *ip) |
---|
| 1333 | { |
---|
| 1334 | NC *ncp; |
---|
| 1335 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1336 | if(stat != NC_NOERR) return stat; |
---|
| 1337 | return NC_get_varm(ncid,varid,startp,countp,stridep,imapp, (void *)ip,T_double); |
---|
| 1338 | } |
---|
| 1339 | |
---|
| 1340 | int |
---|
| 1341 | nc_get_varm_ubyte(int ncid, int varid, |
---|
| 1342 | const size_t *startp, const size_t *countp, |
---|
| 1343 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1344 | unsigned char *ip) |
---|
| 1345 | { |
---|
| 1346 | NC *ncp; |
---|
| 1347 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1348 | if(stat != NC_NOERR) return stat; |
---|
| 1349 | return NC_get_varm(ncid,varid,startp,countp,stridep, |
---|
| 1350 | imapp, (void *)ip, T_ubyte); |
---|
| 1351 | } |
---|
| 1352 | |
---|
| 1353 | int |
---|
| 1354 | nc_get_varm_ushort(int ncid, int varid, |
---|
| 1355 | const size_t *startp, const size_t *countp, |
---|
| 1356 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1357 | unsigned short *ip) |
---|
| 1358 | { |
---|
| 1359 | NC *ncp; |
---|
| 1360 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1361 | if(stat != NC_NOERR) return stat; |
---|
| 1362 | return NC_get_varm(ncid, varid, startp, countp, stridep, |
---|
| 1363 | imapp, (void *)ip, T_ushort); |
---|
| 1364 | } |
---|
| 1365 | |
---|
| 1366 | int |
---|
| 1367 | nc_get_varm_uint(int ncid, int varid, |
---|
| 1368 | const size_t *startp, const size_t *countp, |
---|
| 1369 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1370 | unsigned int *ip) |
---|
| 1371 | { |
---|
| 1372 | NC *ncp; |
---|
| 1373 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1374 | if(stat != NC_NOERR) return stat; |
---|
| 1375 | return NC_get_varm(ncid, varid, startp, countp, |
---|
| 1376 | stridep, imapp, (void *)ip, T_uint); |
---|
| 1377 | } |
---|
| 1378 | |
---|
| 1379 | int |
---|
| 1380 | nc_get_varm_longlong(int ncid, int varid, const size_t *startp, |
---|
| 1381 | const size_t *countp, const ptrdiff_t *stridep, |
---|
| 1382 | const ptrdiff_t *imapp, long long *ip) |
---|
| 1383 | { |
---|
| 1384 | NC *ncp; |
---|
| 1385 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1386 | if(stat != NC_NOERR) return stat; |
---|
| 1387 | return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, |
---|
| 1388 | (void *)ip, T_longlong); |
---|
| 1389 | } |
---|
| 1390 | |
---|
| 1391 | int |
---|
| 1392 | nc_get_varm_ulonglong(int ncid, int varid, |
---|
| 1393 | const size_t *startp, const size_t *countp, |
---|
| 1394 | const ptrdiff_t *stridep, const ptrdiff_t *imapp, |
---|
| 1395 | unsigned long long *ip) |
---|
| 1396 | { |
---|
| 1397 | NC *ncp; |
---|
| 1398 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1399 | if(stat != NC_NOERR) return stat; |
---|
| 1400 | return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, |
---|
| 1401 | (void *)ip, NC_UINT64); |
---|
| 1402 | } |
---|
| 1403 | |
---|
| 1404 | int |
---|
| 1405 | nc_get_varm_text(int ncid, int varid, const size_t *startp, |
---|
| 1406 | const size_t *countp, const ptrdiff_t *stridep, |
---|
| 1407 | const ptrdiff_t *imapp, char *ip) |
---|
| 1408 | { |
---|
| 1409 | NC *ncp; |
---|
| 1410 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1411 | if(stat != NC_NOERR) return stat; |
---|
| 1412 | return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, |
---|
| 1413 | (void *)ip, NC_CHAR); |
---|
| 1414 | } |
---|
| 1415 | |
---|
| 1416 | #ifdef USE_NETCDF4 |
---|
| 1417 | int |
---|
| 1418 | nc_get_varm_string(int ncid, int varid, const size_t *startp, |
---|
| 1419 | const size_t *countp, const ptrdiff_t *stridep, |
---|
| 1420 | const ptrdiff_t *imapp, char **ip) |
---|
| 1421 | { |
---|
| 1422 | NC *ncp; |
---|
| 1423 | int stat = NC_check_id(ncid, &ncp); |
---|
| 1424 | if(stat != NC_NOERR) return stat; |
---|
| 1425 | return NC_get_varm(ncid, varid, startp, countp, stridep, imapp, |
---|
| 1426 | (void *)ip, NC_STRING); |
---|
| 1427 | } |
---|
| 1428 | /** \} */ |
---|
| 1429 | #endif /*USE_NETCDF4*/ |
---|
| 1430 | |
---|
| 1431 | /*! \} */ /* End of named group... */ |
---|
| 1432 | |
---|