dvarput.c 36 KB

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