dvarget.c 39 KB

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