PageRenderTime 40ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/contrib/exodusii/5.22b/exodus/cbind/test/testwtbig.c

https://bitbucket.org/vijaysm/libmesh
C | 776 lines | 342 code | 168 blank | 266 comment | 14 complexity | 83f2f8725f367c4dbc3fe775a8920839 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-3.0, MPL-2.0-no-copyleft-exception, GPL-2.0
  1. /*
  2. * Copyright (c) 2005 Sandia Corporation. Under the terms of Contract
  3. * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Governement
  4. * retains certain rights in this software.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are
  8. * met:
  9. *
  10. * * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * * Redistributions in binary form must reproduce the above
  14. * copyright notice, this list of conditions and the following
  15. * disclaimer in the documentation and/or other materials provided
  16. * with the distribution.
  17. *
  18. * * Neither the name of Sandia Corporation nor the names of its
  19. * contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. */
  35. /*****************************************************************************
  36. *
  37. * testwtbig - test write a BIG ExodusII database file
  38. *
  39. * author - Sandia National Laboratories
  40. * Larry A. Schoof - Original
  41. * Vic Yarberry - Added headers and error logging
  42. * 7/7/93 Modified for use with Exodus 2.00
  43. *
  44. *
  45. * environment - UNIX
  46. *
  47. * entry conditions -
  48. *
  49. * exit conditions -
  50. *
  51. * revision history -
  52. *
  53. * This is a test program for the C binding of the EXODUS II
  54. * database write routines.
  55. *
  56. *
  57. *****************************************************************************/
  58. #define BIG 100000
  59. #include <stdlib.h>
  60. #include <stdio.h>
  61. #include "netcdf.h"
  62. #include "exodusII.h"
  63. int main (int argc, char **argv)
  64. {
  65. int exoid, num_dim, num_nodes, num_elem, num_elem_blk;
  66. int num_elem_in_block[10], num_nodes_per_elem[10];
  67. int num_node_sets, num_sides, num_side_sets, error;
  68. int i, j, k, m, *elem_map, *connect;
  69. int node_list[100],elem_list[100],side_list[100];
  70. int ebids[10], ids[10];
  71. int num_sides_per_set[10], num_nodes_per_set[10], num_elem_per_set[10];
  72. int num_df_per_set[10];
  73. int df_ind[10], node_ind[10], elem_ind[10], side_ind[10];
  74. int num_qa_rec, num_info;
  75. int num_glo_vars, num_nod_vars, num_ele_vars;
  76. int *truth_tab;
  77. int whole_time_step, num_time_steps;
  78. int ndims, nvars, ngatts, recdim;
  79. int CPU_word_size,IO_word_size;
  80. int prop_array[2];
  81. float *glob_var_vals, *nodal_var_vals, *elem_var_vals;
  82. float time_value;
  83. float *x, *y, *z, *dummy;
  84. float attrib[1], dist_fact[100];
  85. char *coord_names[3], *qa_record[2][4], *info[3], *var_names[3];
  86. char tmpstr[80];
  87. char *prop_names[2];
  88. ex_opts (EX_VERBOSE | EX_ABORT);
  89. dummy = 0; /* assign this so the Cray compiler doesn't complain */
  90. /* Specify compute and i/o word size */
  91. CPU_word_size = 0; /* sizeof(float) */
  92. IO_word_size = 4; /* (4 bytes) */
  93. /* create EXODUS II file */
  94. exoid = ex_create ("test.exo", /* filename path */
  95. EX_CLOBBER, /* create mode */
  96. &CPU_word_size, /* CPU float word size in bytes */
  97. &IO_word_size); /* I/O float word size in bytes */
  98. printf ("after ex_create for test.exo, exoid = %d\n", exoid);
  99. printf (" cpu word size: %d io word size: %d\n",CPU_word_size,IO_word_size);
  100. /* ncopts = NC_VERBOSE; */
  101. /* initialize file with parameters */
  102. num_dim = 3;
  103. num_nodes = BIG;
  104. num_elem = BIG;
  105. num_elem_blk = 5;
  106. num_node_sets = 2;
  107. num_side_sets = 5;
  108. error = ex_put_init (exoid, "This is a test", num_dim, num_nodes, num_elem,
  109. num_elem_blk, num_node_sets, num_side_sets);
  110. printf ("after ex_put_init, error = %d\n", error);
  111. /* write nodal coordinates values and names to database */
  112. if (!(x = (float *) calloc(BIG, sizeof(float))))
  113. {
  114. printf ("couldn't allocate memory for x node array%d\n");
  115. exit(1);
  116. }
  117. if (!(y = (float *) calloc(BIG, sizeof(float))))
  118. {
  119. printf ("couldn't allocate memory for y node array%d\n");
  120. exit(1);
  121. }
  122. if (!(z = (float *) calloc(BIG, sizeof(float))))
  123. {
  124. printf ("couldn't allocate memory for z node array%d\n");
  125. exit(1);
  126. }
  127. for (i=0; i<num_nodes; i++)
  128. {
  129. /* dummy up the coordinate space */
  130. x[i]=i;
  131. y[i]=i+.1;
  132. z[i]=i+.2;
  133. }
  134. error = ex_put_coord (exoid, x, y, z);
  135. printf ("after ex_put_coord, error = %d\n", error);
  136. coord_names[0] = "xcoor";
  137. coord_names[1] = "ycoor";
  138. coord_names[2] = "zcoor";
  139. error = ex_put_coord_names (exoid, coord_names);
  140. printf ("after ex_put_coord_names, error = %d\n", error);
  141. /* write element order map */
  142. elem_map = (int *) calloc(num_elem, sizeof(int));
  143. for (i=1; i<=num_elem; i++)
  144. {
  145. elem_map[i-1] = i;
  146. }
  147. error = ex_put_map (exoid, elem_map);
  148. printf ("after ex_put_map, error = %d\n", error);
  149. free (elem_map);
  150. /* write element block parameters */
  151. num_elem_in_block[0] = 1;
  152. num_elem_in_block[1] = 1;
  153. num_elem_in_block[2] = 1;
  154. num_elem_in_block[3] = 1;
  155. num_elem_in_block[4] = 1;
  156. num_nodes_per_elem[0] = 4; /* elements in block #1 are 4-node quads */
  157. num_nodes_per_elem[1] = 4; /* elements in block #2 are 4-node quads */
  158. num_nodes_per_elem[2] = 8; /* elements in block #3 are 8-node hexes */
  159. num_nodes_per_elem[3] = 4; /* elements in block #3 are 4-node tetras */
  160. num_nodes_per_elem[4] = 6; /* elements in block #3 are 6-node wedges */
  161. ebids[0] = 10;
  162. ebids[1] = 11;
  163. ebids[2] = 12;
  164. ebids[3] = 13;
  165. ebids[4] = 14;
  166. error = ex_put_elem_block (exoid, ebids[0], "quad", num_elem_in_block[0],
  167. num_nodes_per_elem[0], 1);
  168. printf ("after ex_put_elem_block, error = %d\n", error);
  169. error = ex_put_elem_block (exoid, ebids[1], "quad", num_elem_in_block[1],
  170. num_nodes_per_elem[1], 1);
  171. printf ("after ex_put_elem_block, error = %d\n", error);
  172. error = ex_put_elem_block (exoid, ebids[2], "hex", num_elem_in_block[2],
  173. num_nodes_per_elem[2], 1);
  174. printf ("after ex_put_elem_block, error = %d\n", error);
  175. error = ex_put_elem_block (exoid, ebids[3], "tetra", num_elem_in_block[3],
  176. num_nodes_per_elem[3], 1);
  177. printf ("after ex_put_elem_block, error = %d\n", error);
  178. error = ex_put_elem_block (exoid, ebids[4], "wedge", num_elem_in_block[4],
  179. num_nodes_per_elem[4], 1);
  180. printf ("after ex_put_elem_block, error = %d\n", error);
  181. /* write element block properties */
  182. prop_names[0] = "MATL";
  183. prop_names[1] = "DENSITY";
  184. error = ex_put_prop_names(exoid,EX_ELEM_BLOCK,2,prop_names);
  185. printf ("after ex_put_prop_names, error = %d\n", error);
  186. error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[0], "MATL", 10);
  187. printf ("after ex_put_prop, error = %d\n", error);
  188. error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[1], "MATL", 20);
  189. printf ("after ex_put_prop, error = %d\n", error);
  190. error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[2], "MATL", 30);
  191. printf ("after ex_put_prop, error = %d\n", error);
  192. error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[3], "MATL", 40);
  193. printf ("after ex_put_prop, error = %d\n", error);
  194. error = ex_put_prop(exoid, EX_ELEM_BLOCK, ebids[4], "MATL", 50);
  195. printf ("after ex_put_prop, error = %d\n", error);
  196. /* write element connectivity */
  197. connect = (int *) calloc(8, sizeof(int));
  198. connect[0] = 1; connect[1] = 2; connect[2] = 3; connect[3] = 4;
  199. error = ex_put_elem_conn (exoid, ebids[0], connect);
  200. printf ("after ex_put_elem_conn, error = %d\n", error);
  201. connect[0] = 5; connect[1] = 6; connect[2] = 7; connect[3] = 8;
  202. error = ex_put_elem_conn (exoid, ebids[1], connect);
  203. printf ("after ex_put_elem_conn, error = %d\n", error);
  204. connect[0] = 9; connect[1] = 10; connect[2] = 11; connect[3] = 12;
  205. connect[4] = 13; connect[5] = 14; connect[6] = 15; connect[7] = 16;
  206. error = ex_put_elem_conn (exoid, ebids[2], connect);
  207. printf ("after ex_put_elem_conn, error = %d\n", error);
  208. connect[0] = 17; connect[1] = 18; connect[2] = 19; connect[3] = 20;
  209. error = ex_put_elem_conn (exoid, ebids[3], connect);
  210. printf ("after ex_put_elem_conn, error = %d\n", error);
  211. connect[0] = 21; connect[1] = 22; connect[2] = 23;
  212. connect[3] = 24; connect[4] = 25; connect[5] = 26;
  213. error = ex_put_elem_conn (exoid, ebids[4], connect);
  214. printf ("after ex_put_elem_conn, error = %d\n", error);
  215. free (connect);
  216. /* write element block attributes */
  217. attrib[0] = 3.14159;
  218. error = ex_put_elem_attr (exoid, ebids[0], attrib);
  219. printf ("after ex_put_elem_attr, error = %d\n", error);
  220. attrib[0] = 6.14159;
  221. error = ex_put_elem_attr (exoid, ebids[1], attrib);
  222. printf ("after ex_put_elem_attr, error = %d\n", error);
  223. error = ex_put_elem_attr (exoid, ebids[2], attrib);
  224. printf ("after ex_put_elem_attr, error = %d\n", error);
  225. error = ex_put_elem_attr (exoid, ebids[3], attrib);
  226. printf ("after ex_put_elem_attr, error = %d\n", error);
  227. error = ex_put_elem_attr (exoid, ebids[4], attrib);
  228. printf ("after ex_put_elem_attr, error = %d\n", error);
  229. /* write individual node sets */
  230. error = ex_put_node_set_param (exoid, 20, 5, 5);
  231. printf ("after ex_put_node_set_param, error = %d\n", error);
  232. node_list[0] = 10; node_list[1] = 11; node_list[2] = 12;
  233. node_list[3] = 13; node_list[4] = 14;
  234. dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0;
  235. dist_fact[3] = 4.0; dist_fact[4] = 5.0;
  236. error = ex_put_node_set (exoid, 20, node_list);
  237. printf ("after ex_put_node_set, error = %d\n", error);
  238. error = ex_put_node_set_dist_fact (exoid, 20, dist_fact);
  239. printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
  240. error = ex_put_node_set_param (exoid, 21, 3, 3);
  241. printf ("after ex_put_node_set_param, error = %d\n", error);
  242. node_list[0] = 20; node_list[1] = 21; node_list[2] = 22;
  243. dist_fact[0] = 1.1; dist_fact[1] = 2.1; dist_fact[2] = 3.1;
  244. error = ex_put_node_set (exoid, 21, node_list);
  245. printf ("after ex_put_node_set, error = %d\n", error);
  246. error = ex_put_node_set_dist_fact (exoid, 21, dist_fact);
  247. printf ("after ex_put_node_set_dist_fact, error = %d\n", error);
  248. error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
  249. printf ("after ex_put_prop, error = %d\n", error);
  250. error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
  251. printf ("after ex_put_prop, error = %d\n", error);
  252. prop_array[0] = 1000;
  253. prop_array[1] = 2000;
  254. error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
  255. printf ("after ex_put_prop_array, error = %d\n", error);
  256. /* write concatenated node sets; this produces the same information as
  257. * the above code which writes individual node sets
  258. */
  259. /* THIS SECTION IS COMMENTED OUT
  260. ids[0] = 20; ids[1] = 21;
  261. num_nodes_per_set[0] = 5; num_nodes_per_set[1] = 3;
  262. node_ind[0] = 0; node_ind[1] = 5;
  263. node_list[0] = 10; node_list[1] = 11; node_list[2] = 12;
  264. node_list[3] = 13; node_list[4] = 14;
  265. node_list[5] = 20; node_list[6] = 21; node_list[7] = 22;
  266. num_df_per_set[0] = 5; num_df_per_set[1] = 3;
  267. df_ind[0] = 0; df_ind[1] = 5;
  268. dist_fact[0] = 1.0; dist_fact[1] = 2.0; dist_fact[2] = 3.0;
  269. dist_fact[3] = 4.0; dist_fact[4] = 5.0;
  270. dist_fact[5] = 1.1; dist_fact[6] = 2.1; dist_fact[7] = 3.1;
  271. error = ex_put_concat_node_sets (exoid, ids, num_nodes_per_set,
  272. num_df_per_set, node_ind,
  273. df_ind, node_list, dist_fact);
  274. printf ("after ex_put_concat_node_sets, error = %d\n", error);
  275. error = ex_put_prop(exoid, EX_NODE_SET, 20, "FACE", 4);
  276. printf ("after ex_put_prop, error = %d\n", error);
  277. error = ex_put_prop(exoid, EX_NODE_SET, 21, "FACE", 5);
  278. printf ("after ex_put_prop, error = %d\n", error);
  279. prop_array[0] = 1000;
  280. prop_array[1] = 2000;
  281. error = ex_put_prop_array(exoid, EX_NODE_SET, "VELOCITY", prop_array);
  282. printf ("after ex_put_prop_array, error = %d\n", error);
  283. END COMMENTED OUT SECTION */
  284. /* write individual side sets */
  285. /* side set #1 - quad */
  286. error = ex_put_side_set_param (exoid, 30, 2, 4);
  287. printf ("after ex_put_side_set_param, error = %d\n", error);
  288. elem_list[0] = 2; elem_list[1] = 2;
  289. side_list[0] = 4; side_list[1] = 2;
  290. dist_fact[0] = 30.0; dist_fact[1] = 30.1; dist_fact[2] = 30.2;
  291. dist_fact[3] = 30.3;
  292. error = ex_put_side_set (exoid, 30, elem_list, side_list);
  293. printf ("after ex_put_side_set, error = %d\n", error);
  294. error = ex_put_side_set_dist_fact (exoid, 30, dist_fact);
  295. printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
  296. /* side set #2 - quad, spanning 2 elements */
  297. error = ex_put_side_set_param (exoid, 31, 2, 4);
  298. printf ("after ex_put_side_set_param, error = %d\n", error);
  299. elem_list[0] = 1; elem_list[1] = 2;
  300. side_list[0] = 2; side_list[1] = 3;
  301. dist_fact[0] = 31.0; dist_fact[1] = 31.1; dist_fact[2] = 31.2;
  302. dist_fact[3] = 31.3;
  303. error = ex_put_side_set (exoid, 31, elem_list, side_list);
  304. printf ("after ex_put_side_set, error = %d\n", error);
  305. error = ex_put_side_set_dist_fact (exoid, 31, dist_fact);
  306. printf ("after ex_put_side_set_dist_fact, error = %d\n", error);
  307. /* side set #3 - hex */
  308. error = ex_put_side_set_param (exoid, 32, 7, 0);
  309. printf ("after ex_put_side_set_param, error = %d\n", error);
  310. elem_list[0] = 3; elem_list[1] = 3;
  311. elem_list[2] = 3; elem_list[3] = 3;
  312. elem_list[4] = 3; elem_list[5] = 3;
  313. elem_list[6] = 3;
  314. side_list[0] = 5; side_list[1] = 3;
  315. side_list[2] = 3; side_list[3] = 2;
  316. side_list[4] = 4; side_list[5] = 1;
  317. side_list[6] = 6;
  318. error = ex_put_side_set (exoid, 32, elem_list, side_list);
  319. printf ("after ex_put_side_set, error = %d\n", error);
  320. /* side set #4 - tetras */
  321. error = ex_put_side_set_param (exoid, 33, 4, 0);
  322. printf ("after ex_put_side_set_param, error = %d\n", error);
  323. elem_list[0] = 4; elem_list[1] = 4;
  324. elem_list[2] = 4; elem_list[3] = 4;
  325. side_list[0] = 1; side_list[1] = 2;
  326. side_list[2] = 3; side_list[3] = 4;
  327. error = ex_put_side_set (exoid, 33, elem_list, side_list);
  328. printf ("after ex_put_side_set, error = %d\n", error);
  329. /* side set #5 - wedges */
  330. error = ex_put_side_set_param (exoid, 34, 5, 0);
  331. printf ("after ex_put_side_set_param, error = %d\n", error);
  332. elem_list[0] = 5; elem_list[1] = 5;
  333. elem_list[2] = 5; elem_list[3] = 5;
  334. elem_list[4] = 5;
  335. side_list[0] = 1; side_list[1] = 2;
  336. side_list[2] = 3; side_list[3] = 4;
  337. side_list[4] = 5;
  338. error = ex_put_side_set (exoid, 34, elem_list, side_list);
  339. printf ("after ex_put_side_set, error = %d\n", error);
  340. /* END COMMENTED OUT SECTION */
  341. /* write concatenated side sets; this produces the same information as
  342. * the above code which writes individual side sets
  343. */
  344. /* THIS SECTION IS COMMENTED OUT
  345. ids[0] = 30;
  346. ids[1] = 31;
  347. ids[2] = 32;
  348. ids[3] = 33;
  349. ids[4] = 34;
  350. node_list[0] = 8; node_list[1] = 5;
  351. node_list[2] = 6; node_list[3] = 7;
  352. node_list[4] = 2; node_list[5] = 3;
  353. node_list[6] = 7; node_list[7] = 8;
  354. node_list[8] = 9; node_list[9] = 12;
  355. node_list[10] = 11; node_list[11] = 10;
  356. node_list[12] = 11; node_list[13] = 12;
  357. node_list[14] = 16; node_list[15] = 15;
  358. node_list[16] = 16; node_list[17] = 15;
  359. node_list[18] = 11; node_list[19] = 12;
  360. node_list[20] = 10; node_list[21] = 11;
  361. node_list[22] = 15; node_list[23] = 14;
  362. node_list[24] = 13; node_list[25] = 16;
  363. node_list[26] = 12; node_list[27] = 9;
  364. node_list[28] = 14; node_list[29] = 13;
  365. node_list[30] = 9; node_list[31] = 10;
  366. node_list[32] = 16; node_list[33] = 13;
  367. node_list[34] = 14; node_list[35] = 15;
  368. node_list[36] = 17; node_list[37] = 18;
  369. node_list[38] = 20;
  370. node_list[39] = 18; node_list[40] = 19;
  371. node_list[41] = 20;
  372. node_list[42] = 20; node_list[43] = 19;
  373. node_list[44] = 17;
  374. node_list[45] = 19; node_list[46] = 18;
  375. node_list[47] = 17;
  376. node_list[48] = 25; node_list[49] = 24;
  377. node_list[50] = 21; node_list[51] = 22;
  378. node_list[52] = 26; node_list[53] = 25;
  379. node_list[54] = 22; node_list[55] = 23;
  380. node_list[56] = 26; node_list[57] = 23;
  381. node_list[58] = 21; node_list[59] = 24;
  382. node_list[60] = 23; node_list[61] = 22;
  383. node_list[62] = 21;
  384. node_list[63] = 24; node_list[64] = 25;
  385. node_list[65] = 26;
  386. node_ind[0] = 0;
  387. node_ind[1] = 4;
  388. node_ind[2] = 8;
  389. node_ind[3] = 36;
  390. node_ind[4] = 47;
  391. num_elem_per_set[0] = 2;
  392. num_elem_per_set[1] = 2;
  393. num_elem_per_set[2] = 7;
  394. num_elem_per_set[3] = 4;
  395. num_elem_per_set[4] = 5;
  396. num_nodes_per_set[0] = 4;
  397. num_nodes_per_set[1] = 4;
  398. num_nodes_per_set[2] = 28;
  399. num_nodes_per_set[3] = 12;
  400. num_nodes_per_set[4] = 18;
  401. elem_ind[0] = 0;
  402. elem_ind[1] = 2;
  403. elem_ind[2] = 4;
  404. elem_ind[3] = 11;
  405. elem_ind[4] = 15;
  406. elem_list[0] = 2; elem_list[1] = 2;
  407. elem_list[2] = 1; elem_list[3] = 2;
  408. elem_list[4] = 3; elem_list[5] = 3;
  409. elem_list[6] = 3; elem_list[7] = 3;
  410. elem_list[8] = 3; elem_list[9] = 3;
  411. elem_list[10] = 3; elem_list[11] = 4;
  412. elem_list[12] = 4; elem_list[13] = 4;
  413. elem_list[14] = 4; elem_list[15] = 5;
  414. elem_list[16] = 5; elem_list[17] = 5;
  415. elem_list[18] = 5; elem_list[19] = 5;
  416. error = ex_cvt_nodes_to_sides(exoid,
  417. num_elem_per_set,
  418. num_nodes_per_set,
  419. elem_ind,
  420. node_ind,
  421. elem_list,
  422. node_list,
  423. side_list);
  424. printf ("after ex_cvt_nodes_to_sides, error = %d\n", error);
  425. num_df_per_set[0] = 4;
  426. num_df_per_set[1] = 4;
  427. num_df_per_set[2] = 0;
  428. num_df_per_set[3] = 0;
  429. num_df_per_set[4] = 0;
  430. df_ind[0] = 0;
  431. df_ind[1] = 4;
  432. dist_fact[0] = 30.0; dist_fact[1] = 30.1;
  433. dist_fact[2] = 30.2; dist_fact[3] = 30.3;
  434. dist_fact[4] = 31.0; dist_fact[5] = 31.1;
  435. dist_fact[6] = 31.2; dist_fact[7] = 31.3;
  436. error = ex_put_concat_side_sets (exoid, ids, num_elem_per_set,
  437. num_df_per_set, elem_ind, df_ind,
  438. elem_list, side_list, dist_fact);
  439. printf ("after ex_put_concat_side_sets, error = %d\n", error);
  440. /* END COMMENTED OUT SECTION */
  441. error = ex_put_prop(exoid, EX_SIDE_SET, 30, "COLOR", 100);
  442. printf ("after ex_put_prop, error = %d\n", error);
  443. error = ex_put_prop(exoid, EX_SIDE_SET, 31, "COLOR", 101);
  444. printf ("after ex_put_prop, error = %d\n", error);
  445. /* write QA records */
  446. num_qa_rec = 2;
  447. qa_record[0][0] = "TESTWT";
  448. qa_record[0][1] = "testwt";
  449. qa_record[0][2] = "07/07/93";
  450. qa_record[0][3] = "15:41:33";
  451. qa_record[1][0] = "FASTQ";
  452. qa_record[1][1] = "fastq";
  453. qa_record[1][2] = "07/07/93";
  454. qa_record[1][3] = "16:41:33";
  455. error = ex_put_qa (exoid, num_qa_rec, qa_record);
  456. printf ("after ex_put_qa, error = %d\n", error);
  457. /* write information records */
  458. num_info = 3;
  459. info[0] = "This is the first information record.";
  460. info[1] = "This is the second information record.";
  461. info[2] = "This is the third information record.";
  462. error = ex_put_info (exoid, num_info, info);
  463. printf ("after ex_put_info, error = %d\n", error);
  464. /* write results variables parameters and names */
  465. num_glo_vars = 1;
  466. var_names[0] = "glo_vars";
  467. error = ex_put_var_param (exoid, "g", num_glo_vars);
  468. printf ("after ex_put_var_param, error = %d\n", error);
  469. error = ex_put_var_names (exoid, "g", num_glo_vars, var_names);
  470. printf ("after ex_put_var_names, error = %d\n", error);
  471. num_nod_vars = 2;
  472. var_names[0] = "nod_var0";
  473. var_names[1] = "nod_var1";
  474. error = ex_put_var_param (exoid, "n", num_nod_vars);
  475. printf ("after ex_put_var_param, error = %d\n", error);
  476. error = ex_put_var_names (exoid, "n", num_nod_vars, var_names);
  477. printf ("after ex_put_var_names, error = %d\n", error);
  478. num_ele_vars = 3;
  479. var_names[0] = "ele_var0";
  480. var_names[1] = "ele_var1";
  481. var_names[2] = "ele_var2";
  482. error = ex_put_var_param (exoid, "e", num_ele_vars);
  483. printf ("after ex_put_var_param, error = %d\n", error);
  484. error = ex_put_var_names (exoid, "e", num_ele_vars, var_names);
  485. printf ("after ex_put_var_names, error = %d\n", error);
  486. /* write element variable truth table */
  487. truth_tab = (int *) calloc ((num_elem_blk*num_ele_vars), sizeof(int));
  488. k = 0;
  489. for (i=0; i<num_elem_blk; i++)
  490. {
  491. for (j=0; j<num_ele_vars; j++)
  492. {
  493. truth_tab[k++] = 1;
  494. }
  495. }
  496. error = ex_put_elem_var_tab (exoid, num_elem_blk, num_ele_vars, truth_tab);
  497. printf ("after ex_put_elem_var_tab, error = %d\n", error);
  498. free (truth_tab);
  499. /* for each time step, write the analysis results;
  500. * the code below fills the arrays glob_var_vals,
  501. * nodal_var_vals, and elem_var_vals with values for debugging purposes;
  502. * obviously the analysis code will populate these arrays
  503. */
  504. whole_time_step = 1;
  505. num_time_steps = 10;
  506. glob_var_vals = (float *) calloc (num_glo_vars, CPU_word_size);
  507. nodal_var_vals = (float *) calloc (num_nodes, CPU_word_size);
  508. elem_var_vals = (float *) calloc (4, CPU_word_size);
  509. for (i=0; i<num_time_steps; i++)
  510. {
  511. time_value = (float)(i+1)/100.;
  512. /* write time value */
  513. error = ex_put_time (exoid, whole_time_step, &time_value);
  514. printf ("after ex_put_time, error = %d\n", error);
  515. /* write global variables */
  516. for (j=0; j<num_glo_vars; j++)
  517. {
  518. glob_var_vals[j] = (float)(j+2) * time_value;
  519. }
  520. error = ex_put_glob_vars (exoid, whole_time_step, num_glo_vars,
  521. glob_var_vals);
  522. printf ("after ex_put_glob_vars, error = %d\n", error);
  523. /* write nodal variables */
  524. for (k=1; k<=num_nod_vars; k++)
  525. {
  526. for (j=0; j<num_nodes; j++)
  527. {
  528. nodal_var_vals[j] = (float)k + ((float)(j+1) * time_value);
  529. }
  530. error = ex_put_nodal_var (exoid, whole_time_step, k, num_nodes,
  531. nodal_var_vals);
  532. printf ("after ex_put_nodal_var, error = %d\n", error);
  533. }
  534. /* write element variables */
  535. for (k=1; k<=num_ele_vars; k++)
  536. {
  537. for (j=0; j<num_elem_blk; j++)
  538. {
  539. for (m=0; m<num_elem_in_block[j]; m++)
  540. {
  541. elem_var_vals[m] = (float)(k+1) + (float)(j+2) +
  542. ((float)(m+1)*time_value);
  543. /* printf("elem_var_vals[%d]: %f\n",m,elem_var_vals[m]); */
  544. }
  545. error = ex_put_elem_var (exoid, whole_time_step, k, ebids[j],
  546. num_elem_in_block[j], elem_var_vals);
  547. printf ("after ex_put_elem_var, error = %d\n", error);
  548. }
  549. }
  550. whole_time_step++;
  551. /* update the data file; this should be done at the end of every time step
  552. * to ensure that no data is lost if the analysis dies
  553. */
  554. error = ex_update (exoid);
  555. printf ("after ex_update, error = %d\n", error);
  556. }
  557. free(glob_var_vals);
  558. free(nodal_var_vals);
  559. free(elem_var_vals);
  560. /* close the EXODUS files
  561. */
  562. error = ex_close (exoid);
  563. printf ("after ex_close, error = %d\n", error);
  564. return 0;
  565. }