cgns_io.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. /* ------------------------------------------------------------------------- *
  2. * CGNS - CFD General Notation System (http://www.cgns.org) *
  3. * CGNS/MLL - Mid-Level Library header file *
  4. * Please see cgnsconfig.h file for this local installation configuration *
  5. * ------------------------------------------------------------------------- */
  6. /* ------------------------------------------------------------------------- *
  7. This software is provided 'as-is', without any express or implied warranty.
  8. In no event will the authors be held liable for any damages arising from
  9. the use of this software.
  10. Permission is granted to anyone to use this software for any purpose,
  11. including commercial applications, and to alter it and redistribute it
  12. freely, subject to the following restrictions:
  13. 1. The origin of this software must not be misrepresented; you must not
  14. claim that you wrote the original software. If you use this software
  15. in a product, an acknowledgment in the product documentation would be
  16. appreciated but is not required.
  17. 2. Altered source versions must be plainly marked as such, and must not
  18. be misrepresented as being the original software.
  19. 3. This notice may not be removed or altered from any source distribution.
  20. * ------------------------------------------------------------------------- */
  21. #ifndef CGNS_IO_H
  22. #define CGNS_IO_H
  23. #include "cgnstypes.h"
  24. #if defined(_WIN32) && defined(BUILD_DLL)
  25. # define CGEXTERN extern __declspec(dllexport)
  26. #else
  27. # define CGEXTERN extern
  28. #endif
  29. /* these should be the same as in cgnslib.h
  30. but are included here for completeness */
  31. #define CGIO_MODE_READ 0
  32. #define CGIO_MODE_WRITE 1
  33. #define CGIO_MODE_MODIFY 2
  34. #define CGIO_FILE_NONE 0
  35. #define CGIO_FILE_ADF 1
  36. #define CGIO_FILE_HDF5 2
  37. #define CGIO_FILE_ADF2 3
  38. #define CGIO_CONTIGUOUS 0
  39. #define CGIO_COMPACT 1
  40. #define CGIO_CHUNKED 2
  41. /* currently these are the same as for ADF */
  42. #define CGIO_MAX_DATATYPE_LENGTH 2
  43. #define CGIO_MAX_DIMENSIONS 12
  44. #define CGIO_MAX_NAME_LENGTH 32
  45. #define CGIO_MAX_LABEL_LENGTH 32
  46. #define CGIO_MAX_VERSION_LENGTH 32
  47. #define CGIO_MAX_DATE_LENGTH 32
  48. #define CGIO_MAX_ERROR_LENGTH 80
  49. #define CGIO_MAX_LINK_DEPTH 100
  50. #define CGIO_MAX_FILE_LENGTH 1024
  51. #define CGIO_MAX_LINK_LENGTH 4096
  52. /* these are the cgio error codes */
  53. #define CGIO_ERR_NONE 0
  54. #define CGIO_ERR_BAD_CGIO -1
  55. #define CGIO_ERR_MALLOC -2
  56. #define CGIO_ERR_FILE_MODE -3
  57. #define CGIO_ERR_FILE_TYPE -4
  58. #define CGIO_ERR_NULL_FILE -5
  59. #define CGIO_ERR_TOO_SMALL -6
  60. #define CGIO_ERR_NOT_FOUND -7
  61. #define CGIO_ERR_NULL_PATH -8
  62. #define CGIO_ERR_NO_MATCH -9
  63. #define CGIO_ERR_FILE_OPEN -10
  64. #define CGIO_ERR_READ_ONLY -11
  65. #define CGIO_ERR_NULL_STRING -12
  66. #define CGIO_ERR_BAD_OPTION -13
  67. #define CGIO_ERR_FILE_RENAME -14
  68. #define CGIO_ERR_TOO_MANY -15
  69. #define CGIO_ERR_DIMENSIONS -16
  70. #define CGIO_ERR_BAD_TYPE -17
  71. #define CGIO_ERR_NOT_HDF5 -18
  72. #ifdef __cplusplus
  73. extern "C" {
  74. #endif
  75. /*---------------------------------------------------------*/
  76. CGEXTERN int cgio_path_add (
  77. const char *path
  78. );
  79. CGEXTERN int cgio_path_delete (
  80. const char *path
  81. );
  82. CGEXTERN int cgio_find_file (
  83. const char *parentfile,
  84. const char *filename,
  85. int file_type,
  86. int max_path_len,
  87. char *pathname
  88. );
  89. /*---------------------------------------------------------*/
  90. CGEXTERN int cgio_is_supported (
  91. int file_type
  92. );
  93. CGEXTERN int cgio_configure (
  94. int what,
  95. void *value
  96. );
  97. CGEXTERN void cgio_cleanup (void);
  98. CGEXTERN int cgio_check_file (
  99. const char *filename,
  100. int *file_type
  101. );
  102. CGEXTERN int cgio_compute_data_size (
  103. const char *data_type,
  104. int num_dims,
  105. const cgsize_t *dim_vals,
  106. cglong_t *count
  107. );
  108. CGEXTERN int cgio_check_dimensions (
  109. int ndims,
  110. const cglong_t *dims
  111. );
  112. CGEXTERN int cgio_copy_dimensions (
  113. int ndims,
  114. const cglong_t *dims64,
  115. cgsize_t *dims
  116. );
  117. /*---------------------------------------------------------*/
  118. CGEXTERN int cgio_open_file (
  119. const char *filename,
  120. int file_mode,
  121. int file_type,
  122. int *cgio_num
  123. );
  124. CGEXTERN int cgio_close_file (
  125. int cgio_num
  126. );
  127. CGEXTERN int cgio_compress_file (
  128. int cgio_num,
  129. const char *filename
  130. );
  131. CGEXTERN int cgio_copy_file (
  132. int cgio_num_inp,
  133. int cgio_num_out,
  134. int follow_links
  135. );
  136. CGEXTERN int cgio_flush_to_disk (
  137. int cgio_num
  138. );
  139. /*---------------------------------------------------------*/
  140. CGEXTERN int cgio_library_version (
  141. int cgio_num,
  142. char *version
  143. );
  144. CGEXTERN int cgio_file_version (
  145. int cgio_num,
  146. char *file_version,
  147. char *creation_date,
  148. char *modified_date
  149. );
  150. CGEXTERN int cgio_get_root_id (
  151. int cgio_num,
  152. double *rootid
  153. );
  154. CGEXTERN int cgio_get_file_type (
  155. int cgio_num,
  156. int *file_type
  157. );
  158. /*---------------------------------------------------------*/
  159. CGEXTERN void cgio_error_code (
  160. int *errcode,
  161. int *file_type
  162. );
  163. CGEXTERN int cgio_error_message (
  164. char *error_msg
  165. );
  166. CGEXTERN void cgio_error_exit (
  167. const char *msg
  168. );
  169. CGEXTERN void cgio_error_abort (
  170. int abort_flag
  171. );
  172. /*---------------------------------------------------------*/
  173. CGEXTERN int cgio_create_node (
  174. int cgio_num,
  175. double pid,
  176. const char *name,
  177. double *id
  178. );
  179. CGEXTERN int cgio_new_node (
  180. int cgio_num,
  181. double pid,
  182. const char *name,
  183. const char *label,
  184. const char *data_type,
  185. int ndims,
  186. const cgsize_t *dims,
  187. const void *data,
  188. double *id
  189. );
  190. CGEXTERN int cgio_delete_node (
  191. int cgio_num,
  192. double pid,
  193. double id
  194. );
  195. CGEXTERN int cgio_move_node (
  196. int cgio_num,
  197. double pid,
  198. double id,
  199. double new_pid
  200. );
  201. CGEXTERN int cgio_copy_node (
  202. int cgio_num_inp,
  203. double id_inp,
  204. int cgio_num_out,
  205. double id_out
  206. );
  207. CGEXTERN int cgio_release_id (
  208. int cgio_num,
  209. double id
  210. );
  211. /*---------------------------------------------------------*/
  212. CGEXTERN int cgio_is_link (
  213. int cgio_num,
  214. double id,
  215. int *link_len
  216. );
  217. CGEXTERN int cgio_link_size (
  218. int cgio_num,
  219. double id,
  220. int *file_len,
  221. int *name_len
  222. );
  223. CGEXTERN int cgio_create_link (
  224. int cgio_num,
  225. double pid,
  226. const char *name,
  227. const char *filename,
  228. const char *name_in_file,
  229. double *id
  230. );
  231. CGEXTERN int cgio_get_link (
  232. int cgio_num,
  233. double id,
  234. char *filename,
  235. char *name_in_file
  236. );
  237. /*---------------------------------------------------------*/
  238. CGEXTERN int cgio_number_children (
  239. int cgio_num,
  240. double id,
  241. int *num_children
  242. );
  243. CGEXTERN int cgio_children_ids (
  244. int cgio_num,
  245. double pid,
  246. int start,
  247. int max_ret,
  248. int *num_ret,
  249. double *ids
  250. );
  251. CGEXTERN int cgio_children_names (
  252. int cgio_num,
  253. double pid,
  254. int start,
  255. int max_ret,
  256. int name_len,
  257. int *num_ret,
  258. char *names
  259. );
  260. /*---------------------------------------------------------*/
  261. CGEXTERN int cgio_get_node_id (
  262. int cgio_num,
  263. double pid,
  264. const char *name,
  265. double *id
  266. );
  267. CGEXTERN int cgio_get_name (
  268. int cgio_num,
  269. double id,
  270. char *name
  271. );
  272. CGEXTERN int cgio_get_label (
  273. int cgio_num,
  274. double id,
  275. char *label
  276. );
  277. CGEXTERN int cgio_get_data_type (
  278. int cgio_num,
  279. double id,
  280. char *data_type
  281. );
  282. CGEXTERN int cgio_get_data_size (
  283. int cgio_num,
  284. double id,
  285. cglong_t *data_size
  286. );
  287. CGEXTERN int cgio_get_dimensions (
  288. int cgio_num,
  289. double id,
  290. int *num_dims,
  291. cgsize_t *dims
  292. );
  293. CGEXTERN int cgio_read_all_data_type (
  294. int cgio_num,
  295. double id,
  296. const char *m_data_type,
  297. void *data
  298. );
  299. CGEXTERN int cgio_read_block_data_type (
  300. int cgio_num,
  301. double id,
  302. cgsize_t b_start,
  303. cgsize_t b_end,
  304. const char *m_data_type,
  305. void *data
  306. );
  307. CGEXTERN int cgio_read_data_type (
  308. int cgio_num,
  309. double id,
  310. const cgsize_t *s_start,
  311. const cgsize_t *s_end,
  312. const cgsize_t *s_stride,
  313. const char *m_data_type,
  314. int m_num_dims,
  315. const cgsize_t *m_dims,
  316. const cgsize_t *m_start,
  317. const cgsize_t *m_end,
  318. const cgsize_t *m_stride,
  319. void *data
  320. );
  321. /*---------------------------------------------------------*/
  322. CGEXTERN int cgio_set_name (
  323. int cgio_num,
  324. double pid,
  325. double id,
  326. const char *name
  327. );
  328. CGEXTERN int cgio_set_label (
  329. int cgio_num,
  330. double id,
  331. const char *label
  332. );
  333. CGEXTERN int cgio_set_dimensions (
  334. int cgio_num,
  335. double id,
  336. const char *data_type,
  337. int num_dims,
  338. const cgsize_t *dims
  339. );
  340. CGEXTERN int cgio_write_all_data (
  341. int cgio_num,
  342. double id,
  343. const void *data
  344. );
  345. CGEXTERN int cgio_write_all_data_type (
  346. int cgio_num,
  347. double id,
  348. const char *m_data_type,
  349. const void *data
  350. );
  351. CGEXTERN int cgio_write_block_data (
  352. int cgio_num,
  353. double id,
  354. cgsize_t b_start,
  355. cgsize_t b_end,
  356. void *data
  357. );
  358. CGEXTERN int cgio_write_data (
  359. int cgio_num,
  360. double id,
  361. const cgsize_t *s_start,
  362. const cgsize_t *s_end,
  363. const cgsize_t *s_stride,
  364. int m_num_dims,
  365. const cgsize_t *m_dims,
  366. const cgsize_t *m_start,
  367. const cgsize_t *m_end,
  368. const cgsize_t *m_stride,
  369. const void *data
  370. );
  371. CGEXTERN int cgio_write_data_type (
  372. int cgio_num,
  373. double id,
  374. const cgsize_t *s_start,
  375. const cgsize_t *s_end,
  376. const cgsize_t *s_stride,
  377. const char *m_data_type,
  378. int m_num_dims,
  379. const cgsize_t *m_dims,
  380. const cgsize_t *m_start,
  381. const cgsize_t *m_end,
  382. const cgsize_t *m_stride,
  383. const void *data
  384. );
  385. #ifdef __cplusplus
  386. }
  387. #endif
  388. #undef CGEXTERN
  389. #endif