dsubstrate.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. /** \substrate
  2. Define the substrate dispatch table and functions
  3. These functions end up calling functions in one of the dispatch layers
  4. (netCDF-4, dap server, etc) using the substrate field of struct NC.
  5. Copyright 2010 University Corporation for Atmospheric
  6. Research/Unidata. See COPYRIGHT file for more info.
  7. */
  8. #include "netcdf.h"
  9. #include "ncdispatch.h"
  10. /* forward */
  11. static NC_Dispatch NCSUBSTRATE_dispatch_base;
  12. /*
  13. Note that because many of the signatures differ
  14. from the netcdf API, we need to break
  15. the abstraction and invoke the
  16. substrate dispatch table directly.
  17. */
  18. int
  19. NCSUBSTRATE_initialize(void)
  20. {
  21. NCSUBSTRATE_dispatch_table = &NCSUBSTRATE_dispatch_base;
  22. return NC_NOERR;
  23. }
  24. static int
  25. NCSUB_new_nc(NC** ncp)
  26. {
  27. NC* nc;
  28. /* Allocate memory for this info. */
  29. if (!(nc = calloc(1, sizeof(struct NC))))
  30. return NC_ENOMEM;
  31. if(ncp) *ncp = nc;
  32. return NC_NOERR;
  33. }
  34. static int
  35. NCSUB_redef(int ncid)
  36. {
  37. NC *nc, *ncsub;
  38. int ncstat = NC_check_id(ncid, &nc);
  39. if(ncstat != NC_NOERR) return ncstat;
  40. ncstat = NC_check_id(nc->substrate,&ncsub);
  41. if(ncstat != NC_NOERR) return ncstat;
  42. return ncsub->dispatch->redef(nc->substrate);
  43. }
  44. static int
  45. NCSUB__enddef(int ncid, size_t a1, size_t a2, size_t a3, size_t a4)
  46. {
  47. NC *nc, *ncsub;
  48. int ncstat = NC_check_id(ncid, &nc);
  49. if(ncstat != NC_NOERR) return ncstat;
  50. ncstat = NC_check_id(nc->substrate, &ncsub);
  51. if(ncstat != NC_NOERR) return ncstat;
  52. return ncsub->dispatch->_enddef(nc->substrate,a1,a2,a3,a4);
  53. }
  54. static int
  55. NCSUB_sync(int ncid)
  56. {
  57. NC *nc, *ncsub;
  58. int ncstat = NC_check_id(ncid, &nc);
  59. if(ncstat != NC_NOERR) return ncstat;
  60. ncstat = NC_check_id(nc->substrate, &ncsub);
  61. if(ncstat != NC_NOERR) return ncstat;
  62. return ncsub->dispatch->sync(nc->substrate);
  63. }
  64. static int
  65. NCSUB_abort(int ncid)
  66. {
  67. NC *nc, *ncsub;
  68. int ncstat = NC_check_id(ncid, &nc);
  69. if(ncstat != NC_NOERR) return ncstat;
  70. ncstat = NC_check_id(nc->substrate, &ncsub);
  71. if(ncstat != NC_NOERR) return ncstat;
  72. return ncsub->dispatch->abort(nc->substrate);
  73. }
  74. static int
  75. NCSUB_close(int ncid)
  76. {
  77. NC *nc, *ncsub;
  78. int ncstat = NC_check_id(ncid, &nc);
  79. if(ncstat != NC_NOERR) return ncstat;
  80. ncstat = NC_check_id(nc->substrate, &ncsub);
  81. if(ncstat != NC_NOERR) return ncstat;
  82. return ncsub->dispatch->close(nc->substrate);
  83. }
  84. static int
  85. NCSUB_set_fill(int ncid, int a1, int* a2)
  86. {
  87. NC *nc, *ncsub;
  88. int ncstat = NC_check_id(ncid, &nc);
  89. if(ncstat != NC_NOERR) return ncstat;
  90. ncstat = NC_check_id(nc->substrate, &ncsub);
  91. if(ncstat != NC_NOERR) return ncstat;
  92. return ncsub->dispatch->set_fill(nc->substrate,a1,a2);
  93. }
  94. static int
  95. NCSUB_inq_base_pe(int ncid, int* a1)
  96. {
  97. NC *nc, *ncsub;
  98. int ncstat = NC_check_id(ncid, &nc);
  99. if(ncstat != NC_NOERR) return ncstat;
  100. ncstat = NC_check_id(nc->substrate, &ncsub);
  101. if(ncstat != NC_NOERR) return ncstat;
  102. return ncsub->dispatch->inq_base_pe(nc->substrate,a1);
  103. }
  104. static int
  105. NCSUB_set_base_pe(int ncid, int a1)
  106. {
  107. NC *nc, *ncsub;
  108. int ncstat = NC_check_id(ncid, &nc);
  109. if(ncstat != NC_NOERR) return ncstat;
  110. ncstat = NC_check_id(nc->substrate, &ncsub);
  111. if(ncstat != NC_NOERR) return ncstat;
  112. return ncsub->dispatch->set_base_pe(nc->substrate,a1);
  113. }
  114. static int
  115. NCSUB_inq_format(int ncid, int* a1)
  116. {
  117. NC *nc, *ncsub;
  118. int ncstat = NC_check_id(ncid, &nc);
  119. if(ncstat != NC_NOERR) return ncstat;
  120. ncstat = NC_check_id(nc->substrate, &ncsub);
  121. if(ncstat != NC_NOERR) return ncstat;
  122. return ncsub->dispatch->inq_format(nc->substrate,a1);
  123. }
  124. static int
  125. NCSUB_inq(int ncid, int* a1, int* a2, int* a3, int* a4)
  126. {
  127. NC *nc, *ncsub;
  128. int ncstat = NC_check_id(ncid, &nc);
  129. if(ncstat != NC_NOERR) return ncstat;
  130. ncstat = NC_check_id(nc->substrate, &ncsub);
  131. if(ncstat != NC_NOERR) return ncstat;
  132. return ncsub->dispatch->inq(nc->substrate,a1,a2,a3,a4);
  133. }
  134. static int
  135. NCSUB_inq_type(int ncid, nc_type a1, char* a2, size_t* a3)
  136. {
  137. NC *nc, *ncsub;
  138. int ncstat = NC_check_id(ncid, &nc);
  139. if(ncstat != NC_NOERR) return ncstat;
  140. ncstat = NC_check_id(nc->substrate, &ncsub);
  141. if(ncstat != NC_NOERR) return ncstat;
  142. return ncsub->dispatch->inq_type(nc->substrate,a1,a2,a3);
  143. }
  144. static int
  145. NCSUB_def_dim(int ncid, const char* a1, size_t a2, int* a3)
  146. {
  147. NC *nc, *ncsub;
  148. int ncstat = NC_check_id(ncid, &nc);
  149. if(ncstat != NC_NOERR) return ncstat;
  150. ncstat = NC_check_id(nc->substrate, &ncsub);
  151. if(ncstat != NC_NOERR) return ncstat;
  152. return ncsub->dispatch->def_dim(nc->substrate,a1,a2,a3);
  153. }
  154. static int
  155. NCSUB_inq_dimid(int ncid, const char* a1, int* a2)
  156. {
  157. NC *nc, *ncsub;
  158. int ncstat = NC_check_id(ncid, &nc);
  159. if(ncstat != NC_NOERR) return ncstat;
  160. ncstat = NC_check_id(nc->substrate, &ncsub);
  161. if(ncstat != NC_NOERR) return ncstat;
  162. return ncsub->dispatch->inq_dimid(nc->substrate,a1,a2);
  163. }
  164. static int
  165. NCSUB_inq_dim(int ncid, int a1, char* a2, size_t* a3)
  166. {
  167. NC *nc, *ncsub;
  168. int ncstat = NC_check_id(ncid, &nc);
  169. if(ncstat != NC_NOERR) return ncstat;
  170. ncstat = NC_check_id(nc->substrate, &ncsub);
  171. if(ncstat != NC_NOERR) return ncstat;
  172. return ncsub->dispatch->inq_dim(nc->substrate,a1,a2,a3);
  173. }
  174. static int
  175. NCSUB_inq_unlimdim(int ncid, int* a1)
  176. {
  177. NC *nc, *ncsub;
  178. int ncstat = NC_check_id(ncid, &nc);
  179. if(ncstat != NC_NOERR) return ncstat;
  180. ncstat = NC_check_id(nc->substrate, &ncsub);
  181. if(ncstat != NC_NOERR) return ncstat;
  182. return ncsub->dispatch->inq_unlimdim(nc->substrate,a1);
  183. }
  184. static int
  185. NCSUB_rename_dim(int ncid, int a1, const char* a2)
  186. {
  187. NC *nc, *ncsub;
  188. int ncstat = NC_check_id(ncid, &nc);
  189. if(ncstat != NC_NOERR) return ncstat;
  190. ncstat = NC_check_id(nc->substrate, &ncsub);
  191. if(ncstat != NC_NOERR) return ncstat;
  192. return ncsub->dispatch->rename_dim(nc->substrate,a1,a2);
  193. }
  194. static int
  195. NCSUB_inq_att(int ncid, int a1, const char* a2, nc_type* a3, size_t* a4)
  196. {
  197. NC *nc, *ncsub;
  198. int ncstat = NC_check_id(ncid, &nc);
  199. if(ncstat != NC_NOERR) return ncstat;
  200. ncstat = NC_check_id(nc->substrate, &ncsub);
  201. if(ncstat != NC_NOERR) return ncstat;
  202. return ncsub->dispatch->inq_att(nc->substrate,a1,a2,a3,a4);
  203. }
  204. static int
  205. NCSUB_inq_attid(int ncid, int a1, const char* a2, int* a3)
  206. {
  207. NC *nc, *ncsub;
  208. int ncstat = NC_check_id(ncid, &nc);
  209. if(ncstat != NC_NOERR) return ncstat;
  210. ncstat = NC_check_id(nc->substrate, &ncsub);
  211. if(ncstat != NC_NOERR) return ncstat;
  212. return ncsub->dispatch->inq_attid(nc->substrate,a1,a2,a3);
  213. }
  214. static int
  215. NCSUB_inq_attname(int ncid, int a1, int a2, char* a3)
  216. {
  217. NC *nc, *ncsub;
  218. int ncstat = NC_check_id(ncid, &nc);
  219. if(ncstat != NC_NOERR) return ncstat;
  220. ncstat = NC_check_id(nc->substrate, &ncsub);
  221. if(ncstat != NC_NOERR) return ncstat;
  222. return ncsub->dispatch->inq_attname(nc->substrate,a1,a2,a3);
  223. }
  224. static int
  225. NCSUB_rename_att(int ncid, int a1, const char* a2, const char* a3)
  226. {
  227. NC *nc, *ncsub;
  228. int ncstat = NC_check_id(ncid, &nc);
  229. if(ncstat != NC_NOERR) return ncstat;
  230. ncstat = NC_check_id(nc->substrate, &ncsub);
  231. if(ncstat != NC_NOERR) return ncstat;
  232. return ncsub->dispatch->rename_att(nc->substrate,a1,a2,a3);
  233. }
  234. static int
  235. NCSUB_del_att(int ncid, int a1, const char* a2)
  236. {
  237. NC *nc, *ncsub;
  238. int ncstat = NC_check_id(ncid, &nc);
  239. if(ncstat != NC_NOERR) return ncstat;
  240. ncstat = NC_check_id(nc->substrate, &ncsub);
  241. if(ncstat != NC_NOERR) return ncstat;
  242. return ncsub->dispatch->del_att(nc->substrate,a1,a2);
  243. }
  244. static int
  245. NCSUB_get_att(int ncid, int a1, const char* a2, void* a3, nc_type a4)
  246. {
  247. NC *nc, *ncsub;
  248. int ncstat = NC_check_id(ncid, &nc);
  249. if(ncstat != NC_NOERR) return ncstat;
  250. ncstat = NC_check_id(nc->substrate, &ncsub);
  251. if(ncstat != NC_NOERR) return ncstat;
  252. return ncsub->dispatch->get_att(nc->substrate,a1,a2,a3,a4);
  253. }
  254. static int
  255. NCSUB_put_att(int ncid, int a1, const char* a2, nc_type a3, size_t a4, const void* a5, nc_type a6)
  256. {
  257. NC *nc, *ncsub;
  258. int ncstat = NC_check_id(ncid, &nc);
  259. if(ncstat != NC_NOERR) return ncstat;
  260. ncstat = NC_check_id(nc->substrate, &ncsub);
  261. if(ncstat != NC_NOERR) return ncstat;
  262. return ncsub->dispatch->put_att(nc->substrate,a1,a2,a3,a4,a5,a6);
  263. }
  264. static int
  265. NCSUB_def_var(int ncid, const char* a1, nc_type a2, int a3, const int* a4, int* a5)
  266. {
  267. NC *nc, *ncsub;
  268. int ncstat = NC_check_id(ncid, &nc);
  269. if(ncstat != NC_NOERR) return ncstat;
  270. ncstat = NC_check_id(nc->substrate, &ncsub);
  271. if(ncstat != NC_NOERR) return ncstat;
  272. return ncsub->dispatch->def_var(nc->substrate,a1,a2,a3,a4,a5);
  273. }
  274. static int
  275. NCSUB_inq_varid(int ncid, const char* a1, int* a2)
  276. {
  277. NC *nc, *ncsub;
  278. int ncstat = NC_check_id(ncid, &nc);
  279. if(ncstat != NC_NOERR) return ncstat;
  280. ncstat = NC_check_id(nc->substrate, &ncsub);
  281. if(ncstat != NC_NOERR) return ncstat;
  282. return ncsub->dispatch->inq_varid(nc->substrate,a1,a2);
  283. }
  284. static int
  285. NCSUB_rename_var(int ncid, int a1, const char* a2)
  286. {
  287. NC *nc, *ncsub;
  288. int ncstat = NC_check_id(ncid, &nc);
  289. if(ncstat != NC_NOERR) return ncstat;
  290. ncstat = NC_check_id(nc->substrate, &ncsub);
  291. if(ncstat != NC_NOERR) return ncstat;
  292. return ncsub->dispatch->rename_var(nc->substrate,a1,a2);
  293. }
  294. static int
  295. NCSUB_get_vara(int ncid, int a1, const size_t* a2, const size_t* a3, void* a4, nc_type a5)
  296. {
  297. NC *nc, *ncsub;
  298. int ncstat = NC_check_id(ncid, &nc);
  299. if(ncstat != NC_NOERR) return ncstat;
  300. ncstat = NC_check_id(nc->substrate, &ncsub);
  301. if(ncstat != NC_NOERR) return ncstat;
  302. return ncsub->dispatch->get_vara(nc->substrate,a1,a2,a3,a4,a5);
  303. }
  304. static int
  305. NCSUB_put_vara(int ncid, int a1, const size_t* a2, const size_t* a3, const void* a4, nc_type a5)
  306. {
  307. NC *nc, *ncsub;
  308. int ncstat = NC_check_id(ncid, &nc);
  309. if(ncstat != NC_NOERR) return ncstat;
  310. ncstat = NC_check_id(nc->substrate, &ncsub);
  311. if(ncstat != NC_NOERR) return ncstat;
  312. return ncsub->dispatch->put_vara(nc->substrate,a1,a2,a3,a4,a5);
  313. }
  314. /* Added to solve Ferret performance problem with Opendap */
  315. static int
  316. NCSUB_get_vars(int ncid, int a1, const size_t* a2, const size_t* a3, const ptrdiff_t* a4, void* a5, nc_type a6)
  317. {
  318. NC *nc, *ncsub;
  319. int ncstat = NC_check_id(ncid, &nc);
  320. if(ncstat != NC_NOERR) return ncstat;
  321. ncstat = NC_check_id(nc->substrate, &ncsub);
  322. if(ncstat != NC_NOERR) return ncstat;
  323. return ncsub->dispatch->get_vars(nc->substrate,a1,a2,a3,a4,a5,a6);
  324. }
  325. static int
  326. NCSUB_put_vars(int ncid, int a1, const size_t* a2, const size_t* a3, const ptrdiff_t* a4, const void* a5, nc_type a6)
  327. {
  328. NC *nc, *ncsub;
  329. int ncstat = NC_check_id(ncid, &nc);
  330. if(ncstat != NC_NOERR) return ncstat;
  331. ncstat = NC_check_id(nc->substrate, &ncsub);
  332. if(ncstat != NC_NOERR) return ncstat;
  333. return ncsub->dispatch->put_vars(nc->substrate,a1,a2,a3,a4,a5,a6);
  334. }
  335. static int
  336. NCSUB_get_varm(int ncid, int a1, const size_t* a2, const size_t* a3, const ptrdiff_t* a4, const ptrdiff_t* a5, void* a6, nc_type a7)
  337. {
  338. NC *nc, *ncsub;
  339. int ncstat = NC_check_id(ncid, &nc);
  340. if(ncstat != NC_NOERR) return ncstat;
  341. ncstat = NC_check_id(nc->substrate, &ncsub);
  342. if(ncstat != NC_NOERR) return ncstat;
  343. return ncsub->dispatch->get_varm(nc->substrate,a1,a2,a3,a4,a5,a6,a7);
  344. }
  345. static int
  346. NCSUB_put_varm(int ncid, int a1, const size_t* a2, const size_t* a3, const ptrdiff_t* a4, const ptrdiff_t* a5, const void* a6, nc_type a7)
  347. {
  348. NC *nc, *ncsub;
  349. int ncstat = NC_check_id(ncid, &nc);
  350. if(ncstat != NC_NOERR) return ncstat;
  351. ncstat = NC_check_id(nc->substrate, &ncsub);
  352. if(ncstat != NC_NOERR) return ncstat;
  353. return ncsub->dispatch->put_varm(nc->substrate,a1,a2,a3,a4,a5,a6,a7);
  354. }
  355. static int
  356. NCSUB_inq_var_all(int ncid, int varid, char* name, nc_type* xtypep,
  357. int* ndimsp, int* dimidsp, int* nattsp,
  358. int* shufflep, int* deflatep, int* deflate_levelp,
  359. int* fletcher32p, int* contiguousp, size_t* chunksizesp,
  360. int* no_fill, void* fill_valuep, int* endiannessp,
  361. int* options_maskp, int* pixels_per_blockp)
  362. {
  363. NC *nc, *ncsub;
  364. int ncstat = NC_check_id(ncid, &nc);
  365. if(ncstat != NC_NOERR) return ncstat;
  366. ncstat = NC_check_id(nc->substrate, &ncsub);
  367. if(ncstat != NC_NOERR) return ncstat;
  368. return ncsub->dispatch->inq_var_all(nc->substrate,varid,name,xtypep,
  369. ndimsp,dimidsp,nattsp,shufflep,
  370. deflatep,deflate_levelp,fletcher32p,
  371. contiguousp,chunksizesp,
  372. no_fill,fill_valuep,
  373. endiannessp,
  374. options_maskp,pixels_per_blockp);
  375. }
  376. #ifdef USE_NETCDF4
  377. static int
  378. NCSUB_show_metadata(int ncid)
  379. {
  380. NC *nc, *ncsub;
  381. int ncstat = NC_check_id(ncid, &nc);
  382. if(ncstat != NC_NOERR) return ncstat;
  383. ncstat = NC_check_id(nc->substrate, &ncsub);
  384. if(ncstat != NC_NOERR) return ncstat;
  385. return ncsub->dispatch->show_metadata(nc->substrate);
  386. }
  387. static int
  388. NCSUB_inq_unlimdims(int ncid, int* a1, int* a2)
  389. {
  390. NC *nc, *ncsub;
  391. int ncstat = NC_check_id(ncid, &nc);
  392. if(ncstat != NC_NOERR) return ncstat;
  393. ncstat = NC_check_id(nc->substrate, &ncsub);
  394. if(ncstat != NC_NOERR) return ncstat;
  395. return ncsub->dispatch->inq_unlimdims(nc->substrate,a1,a2);
  396. }
  397. static int
  398. NCSUB_var_par_access(int ncid, int a1, int a2)
  399. {
  400. NC *nc, *ncsub;
  401. int ncstat = NC_check_id(ncid, &nc);
  402. if(ncstat != NC_NOERR) return ncstat;
  403. ncstat = NC_check_id(nc->substrate, &ncsub);
  404. if(ncstat != NC_NOERR) return ncstat;
  405. return ncsub->dispatch->var_par_access(nc->substrate,a1,a2);
  406. }
  407. static int
  408. NCSUB_inq_ncid(int ncid, const char* a1, int* a2)
  409. {
  410. NC *nc, *ncsub;
  411. int ncstat = NC_check_id(ncid, &nc);
  412. if(ncstat != NC_NOERR) return ncstat;
  413. ncstat = NC_check_id(nc->substrate, &ncsub);
  414. if(ncstat != NC_NOERR) return ncstat;
  415. return ncsub->dispatch->inq_ncid(nc->substrate,a1,a2);
  416. }
  417. static int
  418. NCSUB_inq_grps(int ncid, int* a1, int* a2)
  419. {
  420. NC *nc, *ncsub;
  421. int ncstat = NC_check_id(ncid, &nc);
  422. if(ncstat != NC_NOERR) return ncstat;
  423. ncstat = NC_check_id(nc->substrate, &ncsub);
  424. if(ncstat != NC_NOERR) return ncstat;
  425. return ncsub->dispatch->inq_grps(nc->substrate,a1,a2);
  426. }
  427. static int
  428. NCSUB_inq_grpname(int ncid, char* a1)
  429. {
  430. NC *nc, *ncsub;
  431. int ncstat = NC_check_id(ncid, &nc);
  432. if(ncstat != NC_NOERR) return ncstat;
  433. ncstat = NC_check_id(nc->substrate, &ncsub);
  434. if(ncstat != NC_NOERR) return ncstat;
  435. return ncsub->dispatch->inq_grpname(nc->substrate,a1);
  436. }
  437. static int
  438. NCSUB_inq_grpname_full(int ncid, size_t* a1, char* a2)
  439. {
  440. NC *nc, *ncsub;
  441. int ncstat = NC_check_id(ncid, &nc);
  442. if(ncstat != NC_NOERR) return ncstat;
  443. ncstat = NC_check_id(nc->substrate, &ncsub);
  444. if(ncstat != NC_NOERR) return ncstat;
  445. return ncsub->dispatch->inq_grpname_full(nc->substrate,a1,a2);
  446. }
  447. static int
  448. NCSUB_inq_grp_parent(int ncid, int* a1)
  449. {
  450. NC *nc, *ncsub;
  451. int ncstat = NC_check_id(ncid, &nc);
  452. if(ncstat != NC_NOERR) return ncstat;
  453. ncstat = NC_check_id(nc->substrate, &ncsub);
  454. if(ncstat != NC_NOERR) return ncstat;
  455. return ncsub->dispatch->inq_grp_parent(nc->substrate,a1);
  456. }
  457. static int
  458. NCSUB_inq_grp_full_ncid(int ncid, const char* a1, int* a2)
  459. {
  460. NC *nc, *ncsub;
  461. int ncstat = NC_check_id(ncid, &nc);
  462. if(ncstat != NC_NOERR) return ncstat;
  463. ncstat = NC_check_id(nc->substrate, &ncsub);
  464. if(ncstat != NC_NOERR) return ncstat;
  465. return ncsub->dispatch->inq_grp_full_ncid(nc->substrate,a1,a2);
  466. }
  467. static int
  468. NCSUB_inq_varids(int ncid, int* a1, int* a2)
  469. {
  470. NC *nc, *ncsub;
  471. int ncstat = NC_check_id(ncid, &nc);
  472. if(ncstat != NC_NOERR) return ncstat;
  473. ncstat = NC_check_id(nc->substrate, &ncsub);
  474. if(ncstat != NC_NOERR) return ncstat;
  475. return ncsub->dispatch->inq_varids(nc->substrate,a1,a2);
  476. }
  477. static int
  478. NCSUB_inq_dimids(int ncid, int* a1, int* a2, int a3)
  479. {
  480. NC *nc, *ncsub;
  481. int ncstat = NC_check_id(ncid, &nc);
  482. if(ncstat != NC_NOERR) return ncstat;
  483. ncstat = NC_check_id(nc->substrate, &ncsub);
  484. if(ncstat != NC_NOERR) return ncstat;
  485. return ncsub->dispatch->inq_dimids(nc->substrate,a1,a2,a3);
  486. }
  487. static int
  488. NCSUB_inq_typeids(int ncid, int* a1, int* a2)
  489. {
  490. NC *nc, *ncsub;
  491. int ncstat = NC_check_id(ncid, &nc);
  492. if(ncstat != NC_NOERR) return ncstat;
  493. ncstat = NC_check_id(nc->substrate, &ncsub);
  494. if(ncstat != NC_NOERR) return ncstat;
  495. return ncsub->dispatch->inq_typeids(nc->substrate,a1,a2);
  496. }
  497. static int
  498. NCSUB_inq_type_equal(int ncid, nc_type a1, int a2, nc_type a3, int* a4)
  499. {
  500. NC *nc, *ncsub;
  501. int ncstat = NC_check_id(ncid, &nc);
  502. if(ncstat != NC_NOERR) return ncstat;
  503. ncstat = NC_check_id(nc->substrate, &ncsub);
  504. if(ncstat != NC_NOERR) return ncstat;
  505. return ncsub->dispatch->inq_type_equal(nc->substrate,a1,a2,a3,a4);
  506. }
  507. static int
  508. NCSUB_def_grp(int ncid, const char* a1, int* a2)
  509. {
  510. NC *nc, *ncsub;
  511. int ncstat = NC_check_id(ncid, &nc);
  512. if(ncstat != NC_NOERR) return ncstat;
  513. ncstat = NC_check_id(nc->substrate, &ncsub);
  514. if(ncstat != NC_NOERR) return ncstat;
  515. return ncsub->dispatch->def_grp(nc->substrate,a1,a2);
  516. }
  517. static int
  518. NCSUB_inq_user_type(int ncid, nc_type a1, char* a2, size_t* a3, nc_type* a4, size_t* a5, int* a6)
  519. {
  520. NC *nc, *ncsub;
  521. int ncstat = NC_check_id(ncid, &nc);
  522. if(ncstat != NC_NOERR) return ncstat;
  523. ncstat = NC_check_id(nc->substrate, &ncsub);
  524. if(ncstat != NC_NOERR) return ncstat;
  525. return ncsub->dispatch->inq_user_type(nc->substrate,a1,a2,a3,a4,a5,a6);
  526. }
  527. static int
  528. NCSUB_inq_typeid(int ncid, const char* a1, nc_type* a2)
  529. {
  530. NC *nc, *ncsub;
  531. int ncstat = NC_check_id(ncid, &nc);
  532. if(ncstat != NC_NOERR) return ncstat;
  533. ncstat = NC_check_id(nc->substrate, &ncsub);
  534. if(ncstat != NC_NOERR) return ncstat;
  535. return ncsub->dispatch->inq_typeid(nc->substrate,a1,a2);
  536. }
  537. static int
  538. NCSUB_def_compound(int ncid, size_t a1, const char* a2, nc_type* a3)
  539. {
  540. NC *nc, *ncsub;
  541. int ncstat = NC_check_id(ncid, &nc);
  542. if(ncstat != NC_NOERR) return ncstat;
  543. ncstat = NC_check_id(nc->substrate, &ncsub);
  544. if(ncstat != NC_NOERR) return ncstat;
  545. return ncsub->dispatch->def_compound(nc->substrate,a1,a2,a3);
  546. }
  547. static int
  548. NCSUB_insert_compound(int ncid, nc_type a1, const char* a2, size_t a3, nc_type a4)
  549. {
  550. NC *nc, *ncsub;
  551. int ncstat = NC_check_id(ncid, &nc);
  552. if(ncstat != NC_NOERR) return ncstat;
  553. ncstat = NC_check_id(nc->substrate, &ncsub);
  554. if(ncstat != NC_NOERR) return ncstat;
  555. return ncsub->dispatch->insert_compound(nc->substrate,a1,a2,a3,a4);
  556. }
  557. static int
  558. NCSUB_insert_array_compound(int ncid, nc_type a1, const char* a2, size_t a3, nc_type a4, int a5, const int* a6)
  559. {
  560. NC *nc, *ncsub;
  561. int ncstat = NC_check_id(ncid, &nc);
  562. if(ncstat != NC_NOERR) return ncstat;
  563. ncstat = NC_check_id(nc->substrate, &ncsub);
  564. if(ncstat != NC_NOERR) return ncstat;
  565. return ncsub->dispatch->insert_array_compound(nc->substrate,a1,a2,a3,a4,a5,a6);
  566. }
  567. static int
  568. NCSUB_inq_compound_field(int ncid, nc_type a1, int a2, char* a3, size_t* a4, nc_type* a5, int* a6, int* a7)
  569. {
  570. NC *nc, *ncsub;
  571. int ncstat = NC_check_id(ncid, &nc);
  572. if(ncstat != NC_NOERR) return ncstat;
  573. ncstat = NC_check_id(nc->substrate, &ncsub);
  574. if(ncstat != NC_NOERR) return ncstat;
  575. return ncsub->dispatch->inq_compound_field(nc->substrate,a1,a2,a3,a4,a5,a6,a7);
  576. }
  577. static int
  578. NCSUB_inq_compound_fieldindex(int ncid, nc_type a1, const char* a2, int* a3)
  579. {
  580. NC *nc, *ncsub;
  581. int ncstat = NC_check_id(ncid, &nc);
  582. if(ncstat != NC_NOERR) return ncstat;
  583. ncstat = NC_check_id(nc->substrate, &ncsub);
  584. if(ncstat != NC_NOERR) return ncstat;
  585. return ncsub->dispatch->inq_compound_fieldindex(nc->substrate,a1,a2,a3);
  586. }
  587. static int
  588. NCSUB_def_vlen(int ncid, const char* a1, nc_type a2, nc_type* a3)
  589. {
  590. NC *nc, *ncsub;
  591. int ncstat = NC_check_id(ncid, &nc);
  592. if(ncstat != NC_NOERR) return ncstat;
  593. ncstat = NC_check_id(nc->substrate, &ncsub);
  594. if(ncstat != NC_NOERR) return ncstat;
  595. return ncsub->dispatch->def_vlen(nc->substrate,a1,a2,a3);
  596. }
  597. static int
  598. NCSUB_put_vlen_element(int ncid, int a1, void* a2, size_t a3, const void* a4)
  599. {
  600. NC *nc, *ncsub;
  601. int ncstat = NC_check_id(ncid, &nc);
  602. if(ncstat != NC_NOERR) return ncstat;
  603. ncstat = NC_check_id(nc->substrate, &ncsub);
  604. if(ncstat != NC_NOERR) return ncstat;
  605. return ncsub->dispatch->put_vlen_element(nc->substrate,a1,a2,a3,a4);
  606. }
  607. static int
  608. NCSUB_get_vlen_element(int ncid, int a1, const void* a2, size_t* a3, void* a4)
  609. {
  610. NC *nc, *ncsub;
  611. int ncstat = NC_check_id(ncid, &nc);
  612. if(ncstat != NC_NOERR) return ncstat;
  613. ncstat = NC_check_id(nc->substrate, &ncsub);
  614. if(ncstat != NC_NOERR) return ncstat;
  615. return ncsub->dispatch->get_vlen_element(nc->substrate,a1,a2,a3,a4);
  616. }
  617. static int
  618. NCSUB_def_enum(int ncid, nc_type a1, const char* a2, nc_type* a3)
  619. {
  620. NC *nc, *ncsub;
  621. int ncstat = NC_check_id(ncid, &nc);
  622. if(ncstat != NC_NOERR) return ncstat;
  623. ncstat = NC_check_id(nc->substrate, &ncsub);
  624. if(ncstat != NC_NOERR) return ncstat;
  625. return ncsub->dispatch->def_enum(nc->substrate,a1,a2,a3);
  626. }
  627. static int
  628. NCSUB_insert_enum(int ncid, nc_type a1, const char* a2, const void* a3)
  629. {
  630. NC *nc, *ncsub;
  631. int ncstat = NC_check_id(ncid, &nc);
  632. if(ncstat != NC_NOERR) return ncstat;
  633. ncstat = NC_check_id(nc->substrate, &ncsub);
  634. if(ncstat != NC_NOERR) return ncstat;
  635. return ncsub->dispatch->insert_enum(nc->substrate,a1,a2,a3);
  636. }
  637. static int
  638. NCSUB_inq_enum_member(int ncid, nc_type a1, int a2, char* a3, void* a4)
  639. {
  640. NC *nc, *ncsub;
  641. int ncstat = NC_check_id(ncid, &nc);
  642. if(ncstat != NC_NOERR) return ncstat;
  643. ncstat = NC_check_id(nc->substrate, &ncsub);
  644. if(ncstat != NC_NOERR) return ncstat;
  645. return ncsub->dispatch->inq_enum_member(nc->substrate,a1,a2,a3,a4);
  646. }
  647. static int
  648. NCSUB_inq_enum_ident(int ncid, nc_type a1, long long a2, char* a3)
  649. {
  650. NC *nc, *ncsub;
  651. int ncstat = NC_check_id(ncid, &nc);
  652. if(ncstat != NC_NOERR) return ncstat;
  653. ncstat = NC_check_id(nc->substrate, &ncsub);
  654. if(ncstat != NC_NOERR) return ncstat;
  655. return ncsub->dispatch->inq_enum_ident(nc->substrate,a1,a2,a3);
  656. }
  657. static int
  658. NCSUB_def_opaque(int ncid, size_t a1, const char* a2, nc_type* a3)
  659. {
  660. NC *nc, *ncsub;
  661. int ncstat = NC_check_id(ncid, &nc);
  662. if(ncstat != NC_NOERR) return ncstat;
  663. ncstat = NC_check_id(nc->substrate, &ncsub);
  664. if(ncstat != NC_NOERR) return ncstat;
  665. return ncsub->dispatch->def_opaque(nc->substrate,a1,a2,a3);
  666. }
  667. static int
  668. NCSUB_def_var_deflate(int ncid, int a1, int a2, int a3, int a4)
  669. {
  670. NC *nc, *ncsub;
  671. int ncstat = NC_check_id(ncid, &nc);
  672. if(ncstat != NC_NOERR) return ncstat;
  673. ncstat = NC_check_id(nc->substrate, &ncsub);
  674. if(ncstat != NC_NOERR) return ncstat;
  675. return ncsub->dispatch->def_var_deflate(nc->substrate,a1,a2,a3,a4);
  676. }
  677. static int
  678. NCSUB_def_var_fletcher32(int ncid, int a1, int a2)
  679. {
  680. NC *nc, *ncsub;
  681. int ncstat = NC_check_id(ncid, &nc);
  682. if(ncstat != NC_NOERR) return ncstat;
  683. ncstat = NC_check_id(nc->substrate, &ncsub);
  684. if(ncstat != NC_NOERR) return ncstat;
  685. return ncsub->dispatch->def_var_fletcher32(nc->substrate,a1,a2);
  686. }
  687. static int
  688. NCSUB_def_var_chunking(int ncid, int a1, int a2, const size_t* a3)
  689. {
  690. NC *nc, *ncsub;
  691. int ncstat = NC_check_id(ncid, &nc);
  692. if(ncstat != NC_NOERR) return ncstat;
  693. ncstat = NC_check_id(nc->substrate, &ncsub);
  694. if(ncstat != NC_NOERR) return ncstat;
  695. return ncsub->dispatch->def_var_chunking(nc->substrate,a1,a2,a3);
  696. }
  697. static int
  698. NCSUB_def_var_fill(int ncid, int a1, int a2, const void* a3)
  699. {
  700. NC *nc, *ncsub;
  701. int ncstat = NC_check_id(ncid, &nc);
  702. if(ncstat != NC_NOERR) return ncstat;
  703. ncstat = NC_check_id(nc->substrate, &ncsub);
  704. if(ncstat != NC_NOERR) return ncstat;
  705. return ncsub->dispatch->def_var_fill(nc->substrate,a1,a2,a3);
  706. }
  707. static int
  708. NCSUB_def_var_endian(int ncid, int a1, int a2)
  709. {
  710. NC *nc, *ncsub;
  711. int ncstat = NC_check_id(ncid, &nc);
  712. if(ncstat != NC_NOERR) return ncstat;
  713. ncstat = NC_check_id(nc->substrate, &ncsub);
  714. if(ncstat != NC_NOERR) return ncstat;
  715. return ncsub->dispatch->def_var_endian(nc->substrate,a1,a2);
  716. }
  717. static int
  718. NCSUB_set_var_chunk_cache(int ncid, int a1, size_t a2, size_t a3, float a4)
  719. {
  720. NC *nc, *ncsub;
  721. int ncstat = NC_check_id(ncid, &nc);
  722. if(ncstat != NC_NOERR) return ncstat;
  723. ncstat = NC_check_id(nc->substrate, &ncsub);
  724. if(ncstat != NC_NOERR) return ncstat;
  725. return ncsub->dispatch->set_var_chunk_cache(nc->substrate,a1,a2,a3,a4);
  726. }
  727. static int
  728. NCSUB_get_var_chunk_cache(int ncid, int a1, size_t* a2, size_t* a3, float* a4)
  729. {
  730. NC *nc, *ncsub;
  731. int ncstat = NC_check_id(ncid, &nc);
  732. if(ncstat != NC_NOERR) return ncstat;
  733. ncstat = NC_check_id(nc->substrate, &ncsub);
  734. if(ncstat != NC_NOERR) return ncstat;
  735. return ncsub->dispatch->get_var_chunk_cache(nc->substrate,a1,a2,a3,a4);
  736. }
  737. #endif /*USE_NETCDF4*/
  738. /* Declare here to avoid having a bunch of static forward declarations */
  739. static NC_Dispatch NCSUBSTRATE_dispatch_base = {
  740. 0,
  741. NCSUB_new_nc,
  742. NULL, /*NC_create*/
  743. NULL, /*NC_open*/
  744. NCSUB_redef,
  745. NCSUB__enddef,
  746. NCSUB_sync,
  747. NCSUB_abort,
  748. NCSUB_close,
  749. NCSUB_set_fill,
  750. NCSUB_inq_base_pe,
  751. NCSUB_set_base_pe,
  752. NCSUB_inq_format,
  753. NCSUB_inq,
  754. NCSUB_inq_type,
  755. NCSUB_def_dim,
  756. NCSUB_inq_dimid,
  757. NCSUB_inq_dim,
  758. NCSUB_inq_unlimdim,
  759. NCSUB_rename_dim,
  760. NCSUB_inq_att,
  761. NCSUB_inq_attid,
  762. NCSUB_inq_attname,
  763. NCSUB_rename_att,
  764. NCSUB_del_att,
  765. NCSUB_get_att,
  766. NCSUB_put_att,
  767. NCSUB_def_var,
  768. NCSUB_inq_varid,
  769. NCSUB_rename_var,
  770. NCSUB_get_vara,
  771. NCSUB_put_vara,
  772. NCSUB_get_vars,
  773. NCSUB_put_vars,
  774. NCSUB_get_varm,
  775. NCSUB_put_varm,
  776. NCSUB_inq_var_all,
  777. #ifdef USE_NETCDF4
  778. NCSUB_show_metadata,
  779. NCSUB_inq_unlimdims,
  780. NCSUB_var_par_access,
  781. NCSUB_inq_ncid,
  782. NCSUB_inq_grps,
  783. NCSUB_inq_grpname,
  784. NCSUB_inq_grpname_full,
  785. NCSUB_inq_grp_parent,
  786. NCSUB_inq_grp_full_ncid,
  787. NCSUB_inq_varids,
  788. NCSUB_inq_dimids,
  789. NCSUB_inq_typeids,
  790. NCSUB_inq_type_equal,
  791. NCSUB_def_grp,
  792. NCSUB_inq_user_type,
  793. NCSUB_inq_typeid,
  794. NCSUB_def_compound,
  795. NCSUB_insert_compound,
  796. NCSUB_insert_array_compound,
  797. NCSUB_inq_compound_field,
  798. NCSUB_inq_compound_fieldindex,
  799. NCSUB_def_vlen,
  800. NCSUB_put_vlen_element,
  801. NCSUB_get_vlen_element,
  802. NCSUB_def_enum,
  803. NCSUB_insert_enum,
  804. NCSUB_inq_enum_member,
  805. NCSUB_inq_enum_ident,
  806. NCSUB_def_opaque,
  807. NCSUB_def_var_deflate,
  808. NCSUB_def_var_fletcher32,
  809. NCSUB_def_var_chunking,
  810. NCSUB_def_var_fill,
  811. NCSUB_def_var_endian,
  812. NCSUB_set_var_chunk_cache,
  813. NCSUB_get_var_chunk_cache
  814. #endif /*USE_NETCDF4*/
  815. };
  816. NC_Dispatch* NCSUBSTRATE_dispatch_table = NULL; /*Moved here from ddispatch.c*/